file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
Hacl.Impl.K256.PointMul.fst
Hacl.Impl.K256.PointMul.point_mul_g_double_vartime_noalloc
val point_mul_g_double_vartime_noalloc: out:point -> scalar1:qelem -> q1:point -> scalar2:qelem -> q2:point -> table2:lbuffer uint64 (32ul *! 15ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q /\ point_inv h q1 /\ point_eval h q1 == S.g /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2)))
val point_mul_g_double_vartime_noalloc: out:point -> scalar1:qelem -> q1:point -> scalar2:qelem -> q2:point -> table2:lbuffer uint64 (32ul *! 15ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q /\ point_inv h q1 /\ point_eval h q1 == S.g /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2)))
let point_mul_g_double_vartime_noalloc out scalar1 q1 scalar2 q2 table2 = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in [@inline_let] let bLen = 4ul in [@inline_let] let bBits = 256ul in assert_norm (pow2 (v l) == v table_len); let h0 = ST.get () in recall_contents precomp_basepoint_table_w5 precomp_basepoint_table_lseq_w5; let h1 = ST.get () in precomp_basepoint_table_lemma_w5 (); assert (table_inv_w5 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w5)); assert (table_inv_w5 (as_seq h1 q2) (as_seq h1 table2)); ME.mk_lexp_double_fw_tables len ctx_len k l table_len table_inv_w5 table_inv_w5 (BE.lprecomp_get_vartime len ctx_len k l table_len) (BE.lprecomp_get_vartime len ctx_len k l table_len) (null uint64) q1 bLen bBits scalar1 q2 scalar2 (to_const precomp_basepoint_table_w5) (to_const table2) out; SE.exp_double_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q1) 256 (qas_nat h0 scalar1) (point_eval h0 q2) (qas_nat h0 scalar2) 5
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 45, "end_line": 230, "start_col": 0, "start_line": 204 }
module Hacl.Impl.K256.PointMul open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.K256 open Hacl.K256.Scalar open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group include Hacl.K256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 15ul 16ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 15ul 32ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len let point_mul out scalar q = let h0 = ST.get () in SE.exp_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q) 256 (qas_nat h0 scalar) 4; BE.lexp_fw_consttime 15ul 0ul mk_k256_concrete_ops 4ul (null uint64) q 4ul 256ul scalar out val precomp_get_consttime: BE.pow_a_to_small_b_st U64 15ul 0ul mk_k256_concrete_ops 4ul 16ul (BE.table_inv_precomp 15ul 0ul mk_k256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) //SPT256.exp_as_exp_four_nat256_precomp S.mk_k256_comm_monoid //(S.to_aff_point (point_eval h0 q1)) (qas_nat h0 scalar)) let point_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.q} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b))) let lemma_exp_four_fw_local b = let cm = S.mk_k256_comm_monoid in let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in let res = LE.exp_four_fw cm g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 in assert (res == SPT256.exp_as_exp_four_nat256_precomp cm g_aff (BD.bn_v b)); SPT256.lemma_point_mul_base_precomp4 cm g_aff (BD.bn_v b); assert (res == LE.pow cm g_aff (BD.bn_v b)); SE.exp_fw_lemma S.mk_k256_concrete_ops S.g 256 (BD.bn_v b) 4; LE.exp_fw_lemma cm g_aff 256 (BD.bn_v b) 4; assert (S.to_aff_point (S.point_mul_g (BD.bn_v b)) == LE.pow cm g_aff (BD.bn_v b)) [@CInline] let point_mul_g out scalar = push_frame (); let h0 = ST.get () in let q1 = create 15ul (u64 0) in make_g q1; let q2 = mk_proj_g_pow2_64 () in let q3 = mk_proj_g_pow2_128 () in let q4 = mk_proj_g_pow2_192 () in proj_g_pow2_64_lseq_lemma (); proj_g_pow2_128_lseq_lemma (); proj_g_pow2_192_lseq_lemma (); point_mul_g_noalloc out scalar q1 q2 q3 q4; lemma_exp_four_fw_local (as_seq h0 scalar); pop_frame () //------------------------- inline_for_extraction noextract val point_mul_g_double_vartime_noalloc: out:point -> scalar1:qelem -> q1:point -> scalar2:qelem -> q2:point -> table2:lbuffer uint64 (32ul *! 15ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ qas_nat h scalar1 < S.q /\ qas_nat h scalar2 < S.q /\ point_inv h q1 /\ point_eval h q1 == S.g /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_double_g (qas_nat h0 scalar1) (qas_nat h0 scalar2) (point_eval h0 q2)))
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.K256.PointMul.fst" }
[ { "abbrev": false, "full_module": "Hacl.K256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
out: Hacl.Impl.K256.Point.point -> scalar1: Hacl.K256.Scalar.qelem -> q1: Hacl.Impl.K256.Point.point -> scalar2: Hacl.K256.Scalar.qelem -> q2: Hacl.Impl.K256.Point.point -> table2: Lib.Buffer.lbuffer Lib.IntTypes.uint64 (32ul *! 15ul) -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.K256.Scalar.qelem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Spec.Exponentiation.exp_double_fw_lemma", "Spec.K256.PointOps.proj_point", "Spec.K256.mk_k256_concrete_ops", "Hacl.Impl.K256.Point.point_eval", "Hacl.K256.Scalar.qas_nat", "Prims.unit", "Hacl.Impl.MultiExponentiation.mk_lexp_double_fw_tables", "Lib.IntTypes.U64", "Hacl.Impl.K256.PointMul.table_inv_w5", "Hacl.Impl.Exponentiation.lprecomp_get_vartime", "Lib.Buffer.null", "Lib.Buffer.MUT", "Lib.Buffer.to_const", "Lib.Buffer.CONST", "Hacl.K256.PrecompTable.precomp_basepoint_table_w5", "Prims._assert", "Lib.Buffer.as_seq", "Hacl.K256.PrecompTable.precomp_basepoint_table_lemma_w5", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.recall_contents", "Hacl.K256.PrecompTable.precomp_basepoint_table_lseq_w5", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Prims.pow2", "Lib.IntTypes.v", "FStar.UInt32.t", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "FStar.UInt32.uint_to_t", "Hacl.Impl.K256.Group.mk_k256_concrete_ops" ]
[]
false
true
false
false
false
let point_mul_g_double_vartime_noalloc out scalar1 q1 scalar2 q2 table2 =
[@@ inline_let ]let len = 15ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_k256_concrete_ops in [@@ inline_let ]let l = 5ul in [@@ inline_let ]let table_len = 32ul in [@@ inline_let ]let bLen = 4ul in [@@ inline_let ]let bBits = 256ul in assert_norm (pow2 (v l) == v table_len); let h0 = ST.get () in recall_contents precomp_basepoint_table_w5 precomp_basepoint_table_lseq_w5; let h1 = ST.get () in precomp_basepoint_table_lemma_w5 (); assert (table_inv_w5 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w5)); assert (table_inv_w5 (as_seq h1 q2) (as_seq h1 table2)); ME.mk_lexp_double_fw_tables len ctx_len k l table_len table_inv_w5 table_inv_w5 (BE.lprecomp_get_vartime len ctx_len k l table_len) (BE.lprecomp_get_vartime len ctx_len k l table_len) (null uint64) q1 bLen bBits scalar1 q2 scalar2 (to_const precomp_basepoint_table_w5) (to_const table2) out; SE.exp_double_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q1) 256 (qas_nat h0 scalar1) (point_eval h0 q2) (qas_nat h0 scalar2) 5
false
FStar.LexicographicOrdering.fst
FStar.LexicographicOrdering.lex_to_lex_t
val lex_to_lex_t (#a:Type u#a) (#b:a -> Type u#b) (r_a:binrel u#a u#ra a) (r_b:(x:a -> binrel u#b u#rb (b x))) (t1 t2:(x:a & b x)) (p:lex_aux r_a r_b t1 t2) : squash (lex_t r_a r_b t1 t2)
val lex_to_lex_t (#a:Type u#a) (#b:a -> Type u#b) (r_a:binrel u#a u#ra a) (r_b:(x:a -> binrel u#b u#rb (b x))) (t1 t2:(x:a & b x)) (p:lex_aux r_a r_b t1 t2) : squash (lex_t r_a r_b t1 t2)
let lex_to_lex_t #a #b r_a r_b t1 t2 p = let left (p:squash (r_a (dfst t1) (dfst t2))) : squash (lex_t r_a r_b t1 t2) = bind_squash p (fun p -> return_squash (Left_lex #a #b #r_a #r_b (dfst t1) (dfst t2) (dsnd t1) (dsnd t2) p)) in let right (p:(dfst t1 == dfst t2 /\ (squash (r_b (dfst t1) (dsnd t1) (dsnd t2))))) : squash (lex_t r_a r_b t1 t2) = bind_squash p (fun p -> match p with | Prims.Pair (_:dfst t1 == dfst t2) p2 -> bind_squash p2 (fun p2 -> return_squash (Right_lex #a #b #r_a #r_b (dfst t1) (dsnd t1) (dsnd t2) p2))) in bind_squash p (fun p -> match p with | Prims.Left p1 -> left p1 | Prims.Right p2 -> right p2)
{ "file_name": "ulib/FStar.LexicographicOrdering.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 120, "start_col": 0, "start_line": 103 }
(* Copyright 2021 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Authors: Aseem Rastogi and Nikhil Swamy *) module FStar.LexicographicOrdering #push-options "--warn_error -242" //no inner let recs in SMT open FStar.ReflexiveTransitiveClosure open FStar.WellFounded /// A helper lemma about reflexive transitive closure let closure_transitive (#a:Type u#a) (#r_a:binrel u#a u#ra a) (x y z:a) : Lemma (requires closure r_a x y /\ squash (r_a y z)) (ensures closure r_a x z) [SMTPat (closure r_a x y); SMTPat (r_a y z)] = assert (closure r_a y z) /// The main workhorse for the proof of lex_t well-foundedness /// /// Given x:a and (y:b x), along with proof of their accessibility, /// this function provides a proof of accessibility for all t s.t. lex_t t (| x, y |) /// /// The proof is by induction on the accessibility proofs of x and y /// In the Left_lex case, we do the induction on the accessibility of x, /// and in the Right_lex case, on the accessibility of y /// /// Note also that the proof _does not_ rely on the in-built lexicographic ordering in F* /// /// An interesting aspect of the proof is the wf_b argument, /// that provides a proof for the well-foundedness of r_b, /// but note that we only require it on elements of a that are related to x in the /// transitive closure of r_a let rec lex_t_wf_aux (#a:Type u#a) (#b:a -> Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:(x:a -> binrel u#b u#rb (b x))) (x:a) (acc_x:acc r_a x) //x and accessibility of x (wf_b:(x0:a{closure r_a x0 x} -> well_founded (r_b x0))) //well-foundedness of r_b (y:b x) (acc_y:acc (r_b x) y) //y and accessibility of y (t:(x:a & b x)) //another element t, (p_t:lex_t r_a r_b t (| x, y |)) //that is related to (| x, y |) : Tot (acc (lex_t r_a r_b) t) //returns the accessibility proof for t (decreases acc_x) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ _ _ _ -> //inner induction that keeps x same, but recurses on acc_y let rec lex_t_wf_aux_y (y:b x) (acc_y:acc (r_b x) y) (t:(x:a & b x)) (p_t:lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_y) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ y_t _ p_b -> AccIntro (lex_t_wf_aux_y y_t (match acc_y with | AccIntro f -> f y_t p_b)) in lex_t_wf_aux_y y acc_y t p_t let lex_t_wf #_ #_ #_ #_ wf_a wf_b = fun (| x, y |) -> AccIntro (lex_t_wf_aux x (wf_a x) wf_b y (wf_b x y)) open FStar.Squash (* * Given lex_sq, we can output a squashed instance of lex
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.WellFounded.fst.checked", "FStar.Squash.fsti.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.LexicographicOrdering.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": null }, { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r_a: FStar.WellFounded.binrel a -> r_b: (x: a -> FStar.WellFounded.binrel (b x)) -> t1: Prims.dtuple2 a (fun x -> b x) -> t2: Prims.dtuple2 a (fun x -> b x) -> p: FStar.LexicographicOrdering.lex_aux r_a r_b t1 t2 -> Prims.squash (FStar.LexicographicOrdering.lex_t r_a r_b t1 t2)
Prims.Tot
[ "total" ]
[]
[ "FStar.WellFounded.binrel", "Prims.dtuple2", "FStar.LexicographicOrdering.lex_aux", "FStar.Squash.bind_squash", "Prims.sum", "Prims.squash", "FStar.Pervasives.dfst", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.dsnd", "FStar.LexicographicOrdering.lex_t", "Prims.pair", "Prims.Mkdtuple2", "FStar.Squash.return_squash", "FStar.LexicographicOrdering.Right_lex", "FStar.LexicographicOrdering.Left_lex" ]
[]
false
false
true
false
false
let lex_to_lex_t #a #b r_a r_b t1 t2 p =
let left (p: squash (r_a (dfst t1) (dfst t2))) : squash (lex_t r_a r_b t1 t2) = bind_squash p (fun p -> return_squash (Left_lex #a #b #r_a #r_b (dfst t1) (dfst t2) (dsnd t1) (dsnd t2) p)) in let right (p: (dfst t1 == dfst t2 /\ (squash (r_b (dfst t1) (dsnd t1) (dsnd t2))))) : squash (lex_t r_a r_b t1 t2) = bind_squash p (function | Prims.Pair (_: dfst t1 == dfst t2) p2 -> bind_squash p2 (fun p2 -> return_squash (Right_lex #a #b #r_a #r_b (dfst t1) (dsnd t1) (dsnd t2) p2))) in bind_squash p (function | Prims.Left p1 -> left p1 | Prims.Right p2 -> right p2)
false
FStar.LexicographicOrdering.fst
FStar.LexicographicOrdering.lex_t_wf_aux
val lex_t_wf_aux (#a: Type u#a) (#b: (a -> Type u#b)) (#r_a: binrel u#a u#ra a) (#r_b: (x: a -> binrel u#b u#rb (b x))) (x: a) (acc_x: acc r_a x) (wf_b: (x0: a{closure r_a x0 x} -> well_founded (r_b x0))) (y: b x) (acc_y: acc (r_b x) y) (t: (x: a & b x)) (p_t: lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_x)
val lex_t_wf_aux (#a: Type u#a) (#b: (a -> Type u#b)) (#r_a: binrel u#a u#ra a) (#r_b: (x: a -> binrel u#b u#rb (b x))) (x: a) (acc_x: acc r_a x) (wf_b: (x0: a{closure r_a x0 x} -> well_founded (r_b x0))) (y: b x) (acc_y: acc (r_b x) y) (t: (x: a & b x)) (p_t: lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_x)
let rec lex_t_wf_aux (#a:Type u#a) (#b:a -> Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:(x:a -> binrel u#b u#rb (b x))) (x:a) (acc_x:acc r_a x) //x and accessibility of x (wf_b:(x0:a{closure r_a x0 x} -> well_founded (r_b x0))) //well-foundedness of r_b (y:b x) (acc_y:acc (r_b x) y) //y and accessibility of y (t:(x:a & b x)) //another element t, (p_t:lex_t r_a r_b t (| x, y |)) //that is related to (| x, y |) : Tot (acc (lex_t r_a r_b) t) //returns the accessibility proof for t (decreases acc_x) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ _ _ _ -> //inner induction that keeps x same, but recurses on acc_y let rec lex_t_wf_aux_y (y:b x) (acc_y:acc (r_b x) y) (t:(x:a & b x)) (p_t:lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_y) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ y_t _ p_b -> AccIntro (lex_t_wf_aux_y y_t (match acc_y with | AccIntro f -> f y_t p_b)) in lex_t_wf_aux_y y acc_y t p_t
{ "file_name": "ulib/FStar.LexicographicOrdering.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 92, "start_col": 0, "start_line": 51 }
(* Copyright 2021 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Authors: Aseem Rastogi and Nikhil Swamy *) module FStar.LexicographicOrdering #push-options "--warn_error -242" //no inner let recs in SMT open FStar.ReflexiveTransitiveClosure open FStar.WellFounded /// A helper lemma about reflexive transitive closure let closure_transitive (#a:Type u#a) (#r_a:binrel u#a u#ra a) (x y z:a) : Lemma (requires closure r_a x y /\ squash (r_a y z)) (ensures closure r_a x z) [SMTPat (closure r_a x y); SMTPat (r_a y z)] = assert (closure r_a y z) /// The main workhorse for the proof of lex_t well-foundedness /// /// Given x:a and (y:b x), along with proof of their accessibility, /// this function provides a proof of accessibility for all t s.t. lex_t t (| x, y |) /// /// The proof is by induction on the accessibility proofs of x and y /// In the Left_lex case, we do the induction on the accessibility of x, /// and in the Right_lex case, on the accessibility of y /// /// Note also that the proof _does not_ rely on the in-built lexicographic ordering in F* /// /// An interesting aspect of the proof is the wf_b argument, /// that provides a proof for the well-foundedness of r_b, /// but note that we only require it on elements of a that are related to x in the /// transitive closure of r_a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.WellFounded.fst.checked", "FStar.Squash.fsti.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.LexicographicOrdering.fst" }
[ { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": null }, { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> acc_x: FStar.WellFounded.acc r_a x -> wf_b: (x0: a{FStar.ReflexiveTransitiveClosure.closure r_a x0 x} -> FStar.WellFounded.well_founded (r_b x0)) -> y: b x -> acc_y: FStar.WellFounded.acc (r_b x) y -> t: Prims.dtuple2 a (fun x -> b x) -> p_t: FStar.LexicographicOrdering.lex_t r_a r_b t (| x, y |) -> Prims.Tot (FStar.WellFounded.acc (FStar.LexicographicOrdering.lex_t r_a r_b) t)
Prims.Tot
[ "total", "" ]
[]
[ "FStar.WellFounded.binrel", "FStar.WellFounded.acc", "FStar.ReflexiveTransitiveClosure.closure", "FStar.WellFounded.well_founded", "Prims.dtuple2", "FStar.LexicographicOrdering.lex_t", "Prims.Mkdtuple2", "FStar.WellFounded.AccIntro", "FStar.LexicographicOrdering.lex_t_wf_aux" ]
[ "recursion" ]
false
false
false
false
false
let rec lex_t_wf_aux (#a: Type u#a) (#b: (a -> Type u#b)) (#r_a: binrel u#a u#ra a) (#r_b: (x: a -> binrel u#b u#rb (b x))) (x: a) (acc_x: acc r_a x) (wf_b: (x0: a{closure r_a x0 x} -> well_founded (r_b x0))) (y: b x) (acc_y: acc (r_b x) y) (t: (x: a & b x)) (p_t: lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_x) =
match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ _ _ _ -> let rec lex_t_wf_aux_y (y: b x) (acc_y: acc (r_b x) y) (t: (x: a & b x)) (p_t: lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_y) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ y_t _ p_b -> AccIntro (lex_t_wf_aux_y y_t (match acc_y with | AccIntro f -> f y_t p_b)) in lex_t_wf_aux_y y acc_y t p_t
false
FStar.LexicographicOrdering.fst
FStar.LexicographicOrdering.lex_t_non_dep_wf
val lex_t_non_dep_wf (#a:Type u#a) (#b:Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:binrel u#b u#rb b) (wf_a:well_founded r_a) (wf_b:well_founded r_b) : well_founded (lex_t_non_dep r_a r_b)
val lex_t_non_dep_wf (#a:Type u#a) (#b:Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:binrel u#b u#rb b) (wf_a:well_founded r_a) (wf_b:well_founded r_b) : well_founded (lex_t_non_dep r_a r_b)
let lex_t_non_dep_wf #a #b #r_a #r_b wf_a wf_b = let rec get_acc (t:a & b) (p:acc (lex_t r_a (fun _ -> r_b)) (tuple_to_dep_tuple t)) : Tot (acc (lex_t_non_dep r_a r_b) t) (decreases p) = let get_acc_aux (t1:a & b) (p_dep:lex_t_non_dep r_a r_b t1 t) : (p1:acc (lex_t r_a (fun _ -> r_b)) (tuple_to_dep_tuple t1){p1 << p}) = match p with | AccIntro f -> f (tuple_to_dep_tuple t1) p_dep in AccIntro (fun t1 p1 -> get_acc t1 (get_acc_aux t1 p1)) in fun t -> get_acc t (lex_t_wf wf_a (fun _ -> wf_b) (tuple_to_dep_tuple t))
{ "file_name": "ulib/FStar.LexicographicOrdering.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 75, "end_line": 132, "start_col": 0, "start_line": 123 }
(* Copyright 2021 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Authors: Aseem Rastogi and Nikhil Swamy *) module FStar.LexicographicOrdering #push-options "--warn_error -242" //no inner let recs in SMT open FStar.ReflexiveTransitiveClosure open FStar.WellFounded /// A helper lemma about reflexive transitive closure let closure_transitive (#a:Type u#a) (#r_a:binrel u#a u#ra a) (x y z:a) : Lemma (requires closure r_a x y /\ squash (r_a y z)) (ensures closure r_a x z) [SMTPat (closure r_a x y); SMTPat (r_a y z)] = assert (closure r_a y z) /// The main workhorse for the proof of lex_t well-foundedness /// /// Given x:a and (y:b x), along with proof of their accessibility, /// this function provides a proof of accessibility for all t s.t. lex_t t (| x, y |) /// /// The proof is by induction on the accessibility proofs of x and y /// In the Left_lex case, we do the induction on the accessibility of x, /// and in the Right_lex case, on the accessibility of y /// /// Note also that the proof _does not_ rely on the in-built lexicographic ordering in F* /// /// An interesting aspect of the proof is the wf_b argument, /// that provides a proof for the well-foundedness of r_b, /// but note that we only require it on elements of a that are related to x in the /// transitive closure of r_a let rec lex_t_wf_aux (#a:Type u#a) (#b:a -> Type u#b) (#r_a:binrel u#a u#ra a) (#r_b:(x:a -> binrel u#b u#rb (b x))) (x:a) (acc_x:acc r_a x) //x and accessibility of x (wf_b:(x0:a{closure r_a x0 x} -> well_founded (r_b x0))) //well-foundedness of r_b (y:b x) (acc_y:acc (r_b x) y) //y and accessibility of y (t:(x:a & b x)) //another element t, (p_t:lex_t r_a r_b t (| x, y |)) //that is related to (| x, y |) : Tot (acc (lex_t r_a r_b) t) //returns the accessibility proof for t (decreases acc_x) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ _ _ _ -> //inner induction that keeps x same, but recurses on acc_y let rec lex_t_wf_aux_y (y:b x) (acc_y:acc (r_b x) y) (t:(x:a & b x)) (p_t:lex_t r_a r_b t (| x, y |)) : Tot (acc (lex_t r_a r_b) t) (decreases acc_y) = match p_t with | Left_lex x_t _ y_t _ p_a -> AccIntro (lex_t_wf_aux x_t (match acc_x with | AccIntro f -> f x_t p_a) wf_b y_t (wf_b x_t y_t)) | Right_lex _ y_t _ p_b -> AccIntro (lex_t_wf_aux_y y_t (match acc_y with | AccIntro f -> f y_t p_b)) in lex_t_wf_aux_y y acc_y t p_t let lex_t_wf #_ #_ #_ #_ wf_a wf_b = fun (| x, y |) -> AccIntro (lex_t_wf_aux x (wf_a x) wf_b y (wf_b x y)) open FStar.Squash (* * Given lex_sq, we can output a squashed instance of lex *) let lex_to_lex_t #a #b r_a r_b t1 t2 p = let left (p:squash (r_a (dfst t1) (dfst t2))) : squash (lex_t r_a r_b t1 t2) = bind_squash p (fun p -> return_squash (Left_lex #a #b #r_a #r_b (dfst t1) (dfst t2) (dsnd t1) (dsnd t2) p)) in let right (p:(dfst t1 == dfst t2 /\ (squash (r_b (dfst t1) (dsnd t1) (dsnd t2))))) : squash (lex_t r_a r_b t1 t2) = bind_squash p (fun p -> match p with | Prims.Pair (_:dfst t1 == dfst t2) p2 -> bind_squash p2 (fun p2 -> return_squash (Right_lex #a #b #r_a #r_b (dfst t1) (dsnd t1) (dsnd t2) p2))) in bind_squash p (fun p -> match p with | Prims.Left p1 -> left p1 | Prims.Right p2 -> right p2)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.WellFounded.fst.checked", "FStar.Squash.fsti.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.LexicographicOrdering.fst" }
[ { "abbrev": false, "full_module": "FStar.Squash", "short_module": null }, { "abbrev": false, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": null }, { "abbrev": false, "full_module": "FStar.WellFounded", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
wf_a: FStar.WellFounded.well_founded r_a -> wf_b: FStar.WellFounded.well_founded r_b -> FStar.WellFounded.well_founded (FStar.LexicographicOrdering.lex_t_non_dep r_a r_b)
Prims.Tot
[ "total" ]
[]
[ "FStar.WellFounded.binrel", "FStar.WellFounded.well_founded", "FStar.Pervasives.Native.tuple2", "FStar.LexicographicOrdering.lex_t_wf", "FStar.LexicographicOrdering.tuple_to_dep_tuple", "FStar.WellFounded.acc", "FStar.LexicographicOrdering.lex_t_non_dep", "Prims.dtuple2", "FStar.LexicographicOrdering.lex_t", "FStar.WellFounded.AccIntro", "Prims.precedes" ]
[]
false
false
false
false
false
let lex_t_non_dep_wf #a #b #r_a #r_b wf_a wf_b =
let rec get_acc (t: a & b) (p: acc (lex_t r_a (fun _ -> r_b)) (tuple_to_dep_tuple t)) : Tot (acc (lex_t_non_dep r_a r_b) t) (decreases p) = let get_acc_aux (t1: a & b) (p_dep: lex_t_non_dep r_a r_b t1 t) : (p1: acc (lex_t r_a (fun _ -> r_b)) (tuple_to_dep_tuple t1) {p1 << p}) = match p with | AccIntro f -> f (tuple_to_dep_tuple t1) p_dep in AccIntro (fun t1 p1 -> get_acc t1 (get_acc_aux t1 p1)) in fun t -> get_acc t (lex_t_wf wf_a (fun _ -> wf_b) (tuple_to_dep_tuple t))
false
Vale.Transformers.InstructionReorder.fst
Vale.Transformers.InstructionReorder.lemma_machine_eval_ins_st_equiv_states
val lemma_machine_eval_ins_st_equiv_states (i: ins) (s1 s2: machine_state) : Lemma (requires (equiv_states s1 s2)) (ensures (equiv_states (run (machine_eval_ins_st i) s1) (run (machine_eval_ins_st i) s2)))
val lemma_machine_eval_ins_st_equiv_states (i: ins) (s1 s2: machine_state) : Lemma (requires (equiv_states s1 s2)) (ensures (equiv_states (run (machine_eval_ins_st i) s1) (run (machine_eval_ins_st i) s2)))
let lemma_machine_eval_ins_st_equiv_states (i : ins) (s1 s2 : machine_state) : Lemma (requires (equiv_states s1 s2)) (ensures ( equiv_states (run (machine_eval_ins_st i) s1) (run (machine_eval_ins_st i) s2))) = let s1_orig, s2_orig = s1, s2 in let s1_final = run (machine_eval_ins_st i) s1 in let s2_final = run (machine_eval_ins_st i) s2 in match i with | Instr it oprs ann -> lemma_eval_instr_equiv_states it oprs ann s1 s2 | Push _ _ -> assert_spinoff (equiv_states_ext s1_final s2_final) | Pop dst t -> let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in let s1 = proof_run s1 (check (valid_src_operand64_and_taint stack_op)) in let s2 = proof_run s2 (check (valid_src_operand64_and_taint stack_op)) in // assert (equiv_states s1 s2); let new_dst1 = eval_operand stack_op s1 in let new_dst2 = eval_operand stack_op s2 in // assert (new_dst1 == new_dst2); let new_rsp1 = (eval_reg_64 rRsp s1 + 8) % pow2_64 in let new_rsp2 = (eval_reg_64 rRsp s2 + 8) % pow2_64 in // assert (new_rsp1 == new_rsp2); let s1 = proof_run s1 (update_operand64_preserve_flags dst new_dst1) in let s2 = proof_run s2 (update_operand64_preserve_flags dst new_dst2) in assert (equiv_states_ext s1 s2); let s1 = proof_run s1 (free_stack (new_rsp1 - 8) new_rsp1) in let s2 = proof_run s2 (free_stack (new_rsp2 - 8) new_rsp2) in // assert (equiv_states s1 s2); let s1 = proof_run s1 (update_rsp new_rsp1) in let s2 = proof_run s2 (update_rsp new_rsp2) in assert (equiv_states_ext s1 s2); assert_spinoff (equiv_states s1_final s2_final) | Alloc _ -> assert_spinoff (equiv_states_ext s1_final s2_final) | Dealloc _ -> assert_spinoff (equiv_states_ext s1_final s2_final)
{ "file_name": "vale/code/lib/transformers/Vale.Transformers.InstructionReorder.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 404, "start_col": 0, "start_line": 365 }
(** This module defines a transformer that performs safe instruction reordering. Example: The following set of instructions can be reordered in any order without any observable change in behavior: mov rax, 10 mov rbx, 3 Usage: Actual vale-tool or user-facing code should probably use the even nicer interface provided by the [Vale.Transformers.Transform] module. To use this module, you need to generate a [transformation_hints] object (a nice default is provided in this module via [find_transformation_hints], but users of this module can write their own, without needing to change any proofs), that can then be applied to a [codes] object (say [c1]) via [perform_reordering_with_hints] which tells you if this is a safe reordering, and if so, it produces the transformed [codes] object. If it is not considered to be safe, then the transformer gives a (human-readable) reason for why it doesn't consider it a safe reordering. If the transformation is safe and was indeed performed, then you can use [lemma_perform_reordering_with_hints] to reason about the reordered code having semantically equivalent behavior as the untransformed code. *) module Vale.Transformers.InstructionReorder /// Open all the relevant modules open Vale.X64.Bytes_Code_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open Vale.X64.Machine_Semantics_s open Vale.X64.Machine_s open Vale.X64.Print_s open Vale.Def.PossiblyMonad open Vale.Transformers.Locations open Vale.Transformers.BoundedInstructionEffects module L = FStar.List.Tot /// Some convenience functions let rec locations_of_locations_with_values (lv:locations_with_values) : locations = match lv with | [] -> [] | (|l,v|) :: lv -> l :: locations_of_locations_with_values lv /// Given two read/write sets corresponding to two neighboring /// instructions, we can say whether exchanging those two instructions /// should be allowed. let write_same_constants (c1 c2:locations_with_values) : pbool = for_all (fun (x1:location_with_value) -> for_all (fun (x2:location_with_value) -> let (| l1, v1 |) = x1 in let (| l2, v2 |) = x2 in (if l1 = l2 then v1 = v2 else true) /- "not writing same constants" ) c2 ) c1 let aux_write_exchange_allowed (w2:locations) (c1 c2:locations_with_values) (x:location) : pbool = let cv1, cv2 = locations_of_locations_with_values c1, locations_of_locations_with_values c2 in (disjoint_location_from_locations x w2) ||. ((x `L.mem` cv1 && x `L.mem` cv2) /- "non constant write") let write_exchange_allowed (w1 w2:locations) (c1 c2:locations_with_values) : pbool = write_same_constants c1 c2 &&. for_all (aux_write_exchange_allowed w2 c1 c2) w1 &&. (* REVIEW: Just to make the symmetry proof easier, we write the other way around too. However, this makes things not as fast as they _could_ be. *) for_all (aux_write_exchange_allowed w1 c2 c1) w2 let rw_exchange_allowed (rw1 rw2 : rw_set) : pbool = let r1, w1, c1 = rw1.loc_reads, rw1.loc_writes, rw1.loc_constant_writes in let r2, w2, c2 = rw2.loc_reads, rw2.loc_writes, rw2.loc_constant_writes in (disjoint_locations r1 w2 /+< "read set of 1st not disjoint from write set of 2nd because ") &&. (disjoint_locations r2 w1 /+< "read set of 2nd not disjoint from write set of 1st because ") &&. (write_exchange_allowed w1 w2 c1 c2 /+< "write sets not disjoint because ") let ins_exchange_allowed (i1 i2 : ins) : pbool = ( match i1, i2 with | Instr _ _ _, Instr _ _ _ -> (rw_exchange_allowed (rw_set_of_ins i1) (rw_set_of_ins i2)) | _, _ -> ffalse "non-generic instructions: conservatively disallowed exchange" ) /+> normal (" for instructions " ^ print_ins i1 gcc ^ " and " ^ print_ins i2 gcc) let rec lemma_write_same_constants_symmetric (c1 c2:locations_with_values) : Lemma (ensures (!!(write_same_constants c1 c2) = !!(write_same_constants c2 c1))) = match c1, c2 with | [], [] -> () | x :: xs, [] -> lemma_write_same_constants_symmetric xs [] | [], y :: ys -> lemma_write_same_constants_symmetric [] ys | x :: xs, y :: ys -> lemma_write_same_constants_symmetric c1 ys; lemma_write_same_constants_symmetric xs c2; lemma_write_same_constants_symmetric xs ys let lemma_write_exchange_allowed_symmetric (w1 w2:locations) (c1 c2:locations_with_values) : Lemma (ensures (!!(write_exchange_allowed w1 w2 c1 c2) = !!(write_exchange_allowed w2 w1 c2 c1))) = lemma_write_same_constants_symmetric c1 c2 let lemma_ins_exchange_allowed_symmetric (i1 i2 : ins) : Lemma (requires ( !!(ins_exchange_allowed i1 i2))) (ensures ( !!(ins_exchange_allowed i2 i1))) = let rw1, rw2 = rw_set_of_ins i1, rw_set_of_ins i2 in let r1, w1, c1 = rw1.loc_reads, rw1.loc_writes, rw1.loc_constant_writes in let r2, w2, c2 = rw2.loc_reads, rw2.loc_writes, rw2.loc_constant_writes in lemma_write_exchange_allowed_symmetric w1 w2 c1 c2 /// First, we must define what it means for two states to be /// equivalent. Here, we basically say they must be exactly the same. let equiv_states (s1 s2 : machine_state) : GTot Type0 = (s1.ms_ok == s2.ms_ok) /\ (s1.ms_regs == s2.ms_regs) /\ (cf s1.ms_flags = cf s2.ms_flags) /\ (overflow s1.ms_flags = overflow s2.ms_flags) /\ (s1.ms_heap == s2.ms_heap) /\ (s1.ms_stack == s2.ms_stack) /\ (s1.ms_stackTaint == s2.ms_stackTaint) (** Same as [equiv_states] but uses extensionality to "think harder"; useful at lower-level details of the proof. *) let equiv_states_ext (s1 s2 : machine_state) : GTot Type0 = let open FStar.FunctionalExtensionality in (feq s1.ms_regs s2.ms_regs) /\ (s1.ms_heap == s2.ms_heap) /\ (Map.equal s1.ms_stack.stack_mem s2.ms_stack.stack_mem) /\ (Map.equal s1.ms_stackTaint s2.ms_stackTaint) /\ (equiv_states s1 s2) (** A weaker version of [equiv_states] that makes all non-ok states equivalent. Since non-ok states indicate something "gone-wrong" in execution, we can safely say that the rest of the state is irrelevant. *) let equiv_states_or_both_not_ok (s1 s2:machine_state) = (equiv_states s1 s2) \/ ((not s1.ms_ok) /\ (not s2.ms_ok)) (** Convenience wrapper around [equiv_states] *) unfold let equiv_ostates (s1 s2 : option machine_state) : GTot Type0 = (Some? s1 = Some? s2) /\ (Some? s1 ==> (equiv_states (Some?.v s1) (Some?.v s2))) (** An [option state] is said to be erroring if it is either [None] or if it is [Some] but is not ok. *) unfold let erroring_option_state (s:option machine_state) = match s with | None -> true | Some s -> not (s.ms_ok) (** [equiv_option_states s1 s2] means that [s1] and [s2] are equivalent [option machine_state]s iff both have same erroring behavior and if they are non-erroring, they are [equiv_states]. *) unfold let equiv_option_states (s1 s2:option machine_state) = (erroring_option_state s1 == erroring_option_state s2) /\ (not (erroring_option_state s1) ==> equiv_states (Some?.v s1) (Some?.v s2)) /// If evaluation starts from a set of equivalent states, and the /// exact same thing is evaluated, then the final states are still /// equivalent. unfold let proof_run (s:machine_state) (f:st unit) : machine_state = let (), s1 = f s in { s1 with ms_ok = s1.ms_ok && s.ms_ok } let rec lemma_instr_apply_eval_args_equiv_states (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s1 s2:machine_state) : Lemma (requires (equiv_states s1 s2)) (ensures ( (instr_apply_eval_args outs args f oprs s1) == (instr_apply_eval_args outs args f oprs s2))) = match args with | [] -> () | i :: args -> let (v, oprs) : option (instr_val_t i) & _ = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s1, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s1, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in match v with | None -> () | Some v -> lemma_instr_apply_eval_args_equiv_states outs args (f v) oprs s1 s2 #push-options "--z3rlimit 10" let rec lemma_instr_apply_eval_inouts_equiv_states (outs inouts:list instr_out) (args:list instr_operand) (f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s1 s2:machine_state) : Lemma (requires (equiv_states s1 s2)) (ensures ( (instr_apply_eval_inouts outs inouts args f oprs s1) == (instr_apply_eval_inouts outs inouts args f oprs s2))) = match inouts with | [] -> lemma_instr_apply_eval_args_equiv_states outs args f oprs s1 s2 | (Out, i) :: inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in lemma_instr_apply_eval_inouts_equiv_states outs inouts args (coerce f) oprs s1 s2 | (InOut, i)::inouts -> let (v, oprs) : option (instr_val_t i) & _ = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s1, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s1, coerce oprs) in let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in match v with | None -> () | Some v -> lemma_instr_apply_eval_inouts_equiv_states outs inouts args (f v) oprs s1 s2 #pop-options #push-options "--z3rlimit 10 --max_fuel 1 --max_ifuel 0" let lemma_instr_write_output_implicit_equiv_states (i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig1 s1 s_orig2 s2:machine_state) : Lemma (requires ( (equiv_states s_orig1 s_orig2) /\ (equiv_states s1 s2))) (ensures ( (equiv_states (instr_write_output_implicit i v s_orig1 s1) (instr_write_output_implicit i v s_orig2 s2)))) = let snew1, snew2 = (instr_write_output_implicit i v s_orig1 s1), (instr_write_output_implicit i v s_orig2 s2) in assert (equiv_states_ext snew1 snew2) (* OBSERVE *) let lemma_instr_write_output_explicit_equiv_states (i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig1 s1 s_orig2 s2:machine_state) : Lemma (requires ( (equiv_states s_orig1 s_orig2) /\ (equiv_states s1 s2))) (ensures ( (equiv_states (instr_write_output_explicit i v o s_orig1 s1) (instr_write_output_explicit i v o s_orig2 s2)))) = let snew1, snew2 = (instr_write_output_explicit i v o s_orig1 s1), (instr_write_output_explicit i v o s_orig2 s2) in assert (equiv_states_ext snew1 snew2) (* OBSERVE *) #pop-options let rec lemma_instr_write_outputs_equiv_states (outs:list instr_out) (args:list instr_operand) (vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig1 s1:machine_state) (s_orig2 s2:machine_state) : Lemma (requires ( (equiv_states s_orig1 s_orig2) /\ (equiv_states s1 s2))) (ensures ( (equiv_states (instr_write_outputs outs args vs oprs s_orig1 s1) (instr_write_outputs outs args vs oprs s_orig2 s2)))) = match outs with | [] -> () | (_, i)::outs -> ( let ((v:instr_val_t i), (vs:instr_ret_t outs)) = match outs with | [] -> (vs, ()) | _::_ -> let vs = coerce vs in (fst vs, snd vs) in match i with | IOpEx i -> let oprs = coerce oprs in lemma_instr_write_output_explicit_equiv_states i v (fst oprs) s_orig1 s1 s_orig2 s2; let s1 = instr_write_output_explicit i v (fst oprs) s_orig1 s1 in let s2 = instr_write_output_explicit i v (fst oprs) s_orig2 s2 in lemma_instr_write_outputs_equiv_states outs args vs (snd oprs) s_orig1 s1 s_orig2 s2 | IOpIm i -> lemma_instr_write_output_implicit_equiv_states i v s_orig1 s1 s_orig2 s2; let s1 = instr_write_output_implicit i v s_orig1 s1 in let s2 = instr_write_output_implicit i v s_orig2 s2 in lemma_instr_write_outputs_equiv_states outs args vs (coerce oprs) s_orig1 s1 s_orig2 s2 ) let lemma_eval_instr_equiv_states (it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it) (s1 s2:machine_state) : Lemma (requires (equiv_states s1 s2)) (ensures ( equiv_ostates (eval_instr it oprs ann s1) (eval_instr it oprs ann s2))) = let InstrTypeRecord #outs #args #havoc_flags' i = it in let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in lemma_instr_apply_eval_inouts_equiv_states outs outs args (instr_eval i) oprs s1 s2; assert (vs1 == vs2); let s1_new = match havoc_flags' with | HavocFlags -> {s1 with ms_flags = havoc_flags} | PreserveFlags -> s1 in let s2_new = match havoc_flags' with | HavocFlags -> {s2 with ms_flags = havoc_flags} | PreserveFlags -> s2 in assert (overflow s1_new.ms_flags == overflow s2_new.ms_flags); assert (cf s1_new.ms_flags == cf s2_new.ms_flags); assert (equiv_states s1_new s2_new); let os1 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s1_new) vs1 in let os2 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s2_new) vs2 in match vs1 with | None -> () | Some vs -> lemma_instr_write_outputs_equiv_states outs args vs oprs s1 s1_new s2 s2_new #push-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1" (* REVIEW: This proof is INSANELY annoying to deal with due to the [Pop]. TODO: Figure out why it is slowing down so much. It practically brings F* to a standstill even when editing, and it acts
{ "checked_file": "/", "dependencies": [ "Vale.X64.Print_s.fst.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Transformers.Locations.fsti.checked", "Vale.Transformers.BoundedInstructionEffects.fsti.checked", "Vale.Def.PossiblyMonad.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.Pure.fst.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Vale.Transformers.InstructionReorder.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Vale.Transformers.BoundedInstructionEffects", "short_module": null }, { "abbrev": false, "full_module": "Vale.Transformers.Locations", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.PossiblyMonad", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Print_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Transformers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Transformers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Vale.X64.Machine_Semantics_s.ins -> s1: Vale.X64.Machine_Semantics_s.machine_state -> s2: Vale.X64.Machine_Semantics_s.machine_state -> FStar.Pervasives.Lemma (requires Vale.Transformers.InstructionReorder.equiv_states s1 s2) (ensures Vale.Transformers.InstructionReorder.equiv_states (Vale.X64.Machine_Semantics_s.run (Vale.X64.Machine_Semantics_s.machine_eval_ins_st i) s1) (Vale.X64.Machine_Semantics_s.run (Vale.X64.Machine_Semantics_s.machine_eval_ins_st i) s2) )
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Machine_Semantics_s.ins", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Instruction_s.instr_t_record", "Vale.X64.Instruction_s.instr_operands_t", "Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs", "Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.Transformers.InstructionReorder.lemma_eval_instr_equiv_states", "Vale.X64.Machine_s.operand64", "Vale.Arch.HeapTypes_s.taint", "FStar.Pervasives.assert_spinoff", "Vale.Transformers.InstructionReorder.equiv_states_ext", "Vale.Transformers.InstructionReorder.equiv_states", "Prims.unit", "Prims._assert", "Vale.Transformers.InstructionReorder.proof_run", "Vale.X64.Machine_Semantics_s.update_rsp", "Vale.X64.Machine_Semantics_s.free_stack", "Prims.op_Subtraction", "Vale.X64.Machine_Semantics_s.update_operand64_preserve_flags", "Prims.int", "Prims.op_Modulus", "Prims.op_Addition", "Vale.X64.Machine_Semantics_s.eval_reg_64", "Vale.X64.Machine_s.rRsp", "Vale.X64.Machine_s.pow2_64", "Vale.Def.Words_s.nat64", "Vale.X64.Machine_Semantics_s.eval_operand", "Vale.X64.Machine_Semantics_s.check", "Vale.X64.Machine_Semantics_s.valid_src_operand64_and_taint", "Vale.X64.Machine_s.operand", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.OStack", "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Machine_s.maddr", "Vale.X64.Machine_s.MReg", "Vale.X64.Machine_s.Reg", "Vale.X64.Machine_Semantics_s.run", "Vale.X64.Machine_Semantics_s.machine_eval_ins_st", "FStar.Pervasives.Native.tuple2", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let lemma_machine_eval_ins_st_equiv_states (i: ins) (s1 s2: machine_state) : Lemma (requires (equiv_states s1 s2)) (ensures (equiv_states (run (machine_eval_ins_st i) s1) (run (machine_eval_ins_st i) s2))) =
let s1_orig, s2_orig = s1, s2 in let s1_final = run (machine_eval_ins_st i) s1 in let s2_final = run (machine_eval_ins_st i) s2 in match i with | Instr it oprs ann -> lemma_eval_instr_equiv_states it oprs ann s1 s2 | Push _ _ -> assert_spinoff (equiv_states_ext s1_final s2_final) | Pop dst t -> let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in let s1 = proof_run s1 (check (valid_src_operand64_and_taint stack_op)) in let s2 = proof_run s2 (check (valid_src_operand64_and_taint stack_op)) in let new_dst1 = eval_operand stack_op s1 in let new_dst2 = eval_operand stack_op s2 in let new_rsp1 = (eval_reg_64 rRsp s1 + 8) % pow2_64 in let new_rsp2 = (eval_reg_64 rRsp s2 + 8) % pow2_64 in let s1 = proof_run s1 (update_operand64_preserve_flags dst new_dst1) in let s2 = proof_run s2 (update_operand64_preserve_flags dst new_dst2) in assert (equiv_states_ext s1 s2); let s1 = proof_run s1 (free_stack (new_rsp1 - 8) new_rsp1) in let s2 = proof_run s2 (free_stack (new_rsp2 - 8) new_rsp2) in let s1 = proof_run s1 (update_rsp new_rsp1) in let s2 = proof_run s2 (update_rsp new_rsp2) in assert (equiv_states_ext s1 s2); assert_spinoff (equiv_states s1_final s2_final) | Alloc _ -> assert_spinoff (equiv_states_ext s1_final s2_final) | Dealloc _ -> assert_spinoff (equiv_states_ext s1_final s2_final)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.match_returns_ascription_cmp
val match_returns_ascription_cmp : comparator_for match_returns_ascription
val match_returns_ascription_cmp : comparator_for match_returns_ascription
let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 379, "start_col": 0, "start_line": 242 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Reflection.V2.TermEq.comparator_for FStar.Stubs.Reflection.Types.match_returns_ascription
Prims.Tot
[ "total" ]
[ "term_cmp", "arg_cmp", "aqual_cmp", "match_returns_ascription_cmp", "binder_cmp", "comp_cmp", "br_cmp", "pat_cmp", "pat_arg_cmp" ]
[ "FStar.Stubs.Reflection.Types.match_returns_ascription", "FStar.Stubs.Reflection.Types.binder", "FStar.Pervasives.either", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.Types.comp", "FStar.Pervasives.Native.option", "Prims.bool", "FStar.Reflection.V2.TermEq.op_Amp_Amp_Amp", "FStar.Pervasives.Native.tuple2", "Prims.l_or", "Prims.precedes", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.TermEq.binder_cmp", "FStar.Reflection.V2.TermEq.either_dec_cmp", "FStar.Reflection.V2.TermEq.term_cmp", "FStar.Reflection.V2.TermEq.comp_cmp", "FStar.Reflection.V2.TermEq.opt_dec_cmp", "FStar.Reflection.V2.TermEq.eq_cmp", "FStar.Reflection.V2.TermEq.cmpres" ]
[ "mutual recursion" ]
false
false
false
true
false
let rec match_returns_ascription_cmp asc1 asc2 =
let b1, (tc1, tacopt1, eq1) = asc1 in let b2, (tc2, tacopt2, eq2) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.br_cmp
val br_cmp : comparator_for branch
val br_cmp : comparator_for branch
let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 379, "start_col": 0, "start_line": 242 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Reflection.V2.TermEq.comparator_for FStar.Stubs.Reflection.V2.Data.branch
Prims.Tot
[ "total" ]
[ "term_cmp", "arg_cmp", "aqual_cmp", "match_returns_ascription_cmp", "binder_cmp", "comp_cmp", "br_cmp", "pat_cmp", "pat_arg_cmp" ]
[ "FStar.Stubs.Reflection.V2.Data.branch", "FStar.Reflection.V2.TermEq.op_Amp_Amp_Amp", "FStar.Stubs.Reflection.V2.Data.pattern", "FStar.Stubs.Reflection.Types.term", "FStar.Pervasives.Native.fst", "FStar.Pervasives.Native.snd", "FStar.Reflection.V2.TermEq.pat_cmp", "FStar.Reflection.V2.TermEq.term_cmp", "FStar.Reflection.V2.TermEq.cmpres" ]
[ "mutual recursion" ]
false
false
false
true
false
let rec br_cmp br1 br2 =
pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.pat_arg_cmp
val pat_arg_cmp : comparator_for (pattern & bool)
val pat_arg_cmp : comparator_for (pattern & bool)
let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 379, "start_col": 0, "start_line": 242 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Reflection.V2.TermEq.comparator_for (FStar.Stubs.Reflection.V2.Data.pattern * Prims.bool)
Prims.Tot
[ "total" ]
[ "term_cmp", "arg_cmp", "aqual_cmp", "match_returns_ascription_cmp", "binder_cmp", "comp_cmp", "br_cmp", "pat_cmp", "pat_arg_cmp" ]
[ "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.V2.Data.pattern", "Prims.bool", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.TermEq.op_Amp_Amp_Amp", "FStar.Reflection.V2.TermEq.pat_cmp", "FStar.Reflection.V2.TermEq.eq_cmp", "FStar.Reflection.V2.TermEq.cmpres" ]
[ "mutual recursion" ]
false
false
false
true
false
let rec pat_arg_cmp (p1, b1) (p2, b2) =
pat_cmp p1 p2 &&& eq_cmp b1 b2
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.pat_cmp
val pat_cmp : comparator_for pattern
val pat_cmp : comparator_for pattern
let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 379, "start_col": 0, "start_line": 242 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Reflection.V2.TermEq.comparator_for FStar.Stubs.Reflection.V2.Data.pattern
Prims.Tot
[ "total" ]
[ "term_cmp", "arg_cmp", "aqual_cmp", "match_returns_ascription_cmp", "binder_cmp", "comp_cmp", "br_cmp", "pat_cmp", "pat_arg_cmp" ]
[ "FStar.Stubs.Reflection.V2.Data.pattern", "FStar.Pervasives.Native.Mktuple2", "FStar.Sealed.sealed", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.ppname_t", "FStar.Reflection.V2.TermEq.Eq", "Prims.unit", "FStar.Sealed.sealed_singl", "Prims.string", "FStar.Stubs.Reflection.V2.Data.vconst", "FStar.Reflection.V2.TermEq.const_cmp", "FStar.Pervasives.Native.option", "FStar.Reflection.V2.TermEq.opt_dec_cmp", "FStar.Reflection.V2.TermEq.term_cmp", "FStar.Stubs.Reflection.Types.fv", "FStar.Stubs.Reflection.V2.Data.universes", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.bool", "FStar.Reflection.V2.TermEq.op_Amp_Amp_Amp", "FStar.Stubs.Reflection.Types.universe", "Prims.l_or", "Prims.precedes", "FStar.Reflection.V2.TermEq.fv_cmp", "FStar.Reflection.V2.TermEq.list_dec_cmp", "FStar.Reflection.V2.TermEq.univ_cmp", "FStar.Reflection.V2.TermEq.pat_arg_cmp", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres" ]
[ "mutual recursion" ]
false
false
false
true
false
let rec pat_cmp p1 p2 =
match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.comp_cmp
val comp_cmp : comparator_for comp
val comp_cmp : comparator_for comp
let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 379, "start_col": 0, "start_line": 242 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Reflection.V2.TermEq.comparator_for FStar.Stubs.Reflection.Types.comp
Prims.Tot
[ "total" ]
[ "term_cmp", "arg_cmp", "aqual_cmp", "match_returns_ascription_cmp", "binder_cmp", "comp_cmp", "br_cmp", "pat_cmp", "pat_arg_cmp" ]
[ "FStar.Stubs.Reflection.Types.comp", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.comp_view", "FStar.Stubs.Reflection.Types.typ", "FStar.Reflection.V2.TermEq.term_cmp", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.TermEq.op_Amp_Amp_Amp", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.V2.Data.universes", "FStar.Stubs.Reflection.Types.name", "Prims.list", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Stubs.Reflection.Types.universe", "FStar.Reflection.V2.TermEq.list_dec_cmp", "FStar.Reflection.V2.TermEq.univ_cmp", "FStar.Reflection.V2.TermEq.eq_cmp", "FStar.Reflection.V2.TermEq.arg_cmp", "FStar.Reflection.V2.TermEq.Neq", "FStar.Reflection.V2.TermEq.cmpres", "Prims.unit", "FStar.Stubs.Reflection.V2.Builtins.pack_inspect_comp_inv", "Prims.precedes", "FStar.Stubs.Reflection.V2.Builtins.inspect_comp" ]
[ "mutual recursion" ]
false
false
false
true
false
let rec comp_cmp c1 c2 =
let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.lemma_label_bool
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma (requires label r msg b) (ensures b) [SMTPat (label r msg b)]
val lemma_label_bool (r:range) (msg:string) (b:bool) : Lemma (requires label r msg b) (ensures b) [SMTPat (label r msg b)]
let lemma_label_bool r msg b = lemma_label_Type0 r msg b
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 56, "end_line": 13, "start_col": 0, "start_line": 13 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> msg: Prims.string -> b: Prims.bool -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCodes.label r msg b) (ensures b) [SMTPat (Vale.X64.QuickCodes.label r msg b)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Range.range", "Prims.string", "Prims.bool", "Vale.X64.QuickCodes.lemma_label_Type0", "Prims.b2t", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_label_bool r msg b =
lemma_label_Type0 r msg b
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.empty_list_is_small
val empty_list_is_small (#a:Type) (x:list a) : Lemma ([] #a == x \/ [] #a << x)
val empty_list_is_small (#a:Type) (x:list a) : Lemma ([] #a == x \/ [] #a << x)
let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 18, "start_col": 0, "start_line": 15 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.list a -> FStar.Pervasives.Lemma (ensures [] == x \/ [] << x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "Vale.X64.QuickCodes.empty_list_is_small", "Prims.unit" ]
[ "recursion" ]
false
false
true
false
false
let rec empty_list_is_small #a x =
match x with | [] -> () | h :: t -> empty_list_is_small t
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.state_mod_eq
val state_mod_eq : m: Vale.X64.QuickCode.mod_t -> s1: Vale.X64.State.vale_state -> s2: Vale.X64.State.vale_state -> Prims.logical
let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 58, "end_line": 30, "start_col": 0, "start_line": 20 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: Vale.X64.QuickCode.mod_t -> s1: Vale.X64.State.vale_state -> s2: Vale.X64.State.vale_state -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.QuickCode.mod_t", "Vale.X64.State.vale_state", "Prims.l_True", "Prims.eq2", "Prims.bool", "Vale.X64.State.__proj__Mkvale_state__item__vs_ok", "Vale.X64.Machine_s.reg", "Vale.X64.Machine_s.t_reg", "Vale.X64.State.eval_reg", "Vale.X64.Flags.t", "Vale.X64.State.__proj__Mkvale_state__item__vs_flags", "Vale.Arch.HeapImpl.vale_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap", "Vale.X64.State.__proj__Mkvale_state__item__vs_heap", "Vale.Arch.HeapImpl.vale_heap_layout", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout", "Vale.X64.Decls.heaplet_id", "Vale.Lib.Map16.sel", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets", "Vale.X64.Stack_i.vale_stack", "Vale.X64.State.__proj__Mkvale_state__item__vs_stack", "Vale.X64.Memory.memtaint", "Vale.X64.State.__proj__Mkvale_state__item__vs_stackTaint", "Prims.logical" ]
[]
false
false
false
true
true
let state_mod_eq (m: mod_t) (s1 s2: vale_state) =
match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.update_state_mods_from1
val update_state_mods_from1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
val update_state_mods_from1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s')
let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 74, "end_line": 51, "start_col": 0, "start_line": 47 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mods: Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> m0: Vale.X64.QuickCode.mod_t -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCodes.state_mod_eq m0 s' (Vale.X64.QuickCode.update_state_mods mods s' s)) (ensures Vale.X64.QuickCodes.mods_contains1 mods m0 \/ Vale.X64.QuickCodes.state_mod_eq m0 s s')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.mod_t", "Prims.op_Negation", "Vale.X64.QuickCodes.mods_contains1", "Vale.X64.QuickCodes.update_state_mods_not1", "Prims.bool", "Prims.unit", "Vale.X64.QuickCodes.state_mod_eq", "Vale.X64.QuickCode.update_state_mods", "Prims.squash", "Prims.l_or", "Prims.b2t", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let update_state_mods_from1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') =
if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.update_state_mods_refl
val update_state_mods_refl (mods: mods_t) (s: vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s)
val update_state_mods_refl (mods: mods_t) (s: vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s)
let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 44, "end_line": 37, "start_col": 0, "start_line": 32 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mods: Vale.X64.QuickCode.mods_t -> s: Vale.X64.State.vale_state -> FStar.Pervasives.Lemma (ensures Vale.X64.State.state_eq (Vale.X64.QuickCode.update_state_mods mods s s) s)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.mod_t", "Prims.list", "Vale.X64.QuickCodes.update_state_mods_refl", "Prims.unit", "Prims.l_True", "Prims.squash", "Vale.X64.State.state_eq", "Vale.X64.QuickCode.update_state_mods", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec update_state_mods_refl (mods: mods_t) (s: vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) =
match mods with | [] -> () | _ :: mods -> update_state_mods_refl mods s
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.update_state_mods_weaken
val update_state_mods_weaken (mods mods': mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s')
val update_state_mods_weaken (mods mods': mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s')
let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 136, "start_col": 0, "start_line": 127 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mods: Vale.X64.QuickCode.mods_t -> mods': Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCode.update_state_mods mods s' s == s' /\ Vale.X64.QuickCodes.mods_contains mods' mods) (ensures Vale.X64.QuickCode.update_state_mods mods' s' s == s')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.update_state_mods_to", "Prims.unit", "FStar.Classical.forall_intro", "Vale.X64.QuickCode.mod_t", "Prims.l_or", "Prims.b2t", "Vale.X64.QuickCodes.mods_contains1", "Vale.X64.QuickCodes.state_mod_eq", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.X64.QuickCodes.update_state_mods_weaken1", "Vale.X64.QuickCodes.update_state_mods_from", "Prims.l_and", "Prims.eq2", "Vale.X64.QuickCode.update_state_mods", "Vale.X64.QuickCodes.mods_contains" ]
[]
false
false
true
false
false
let update_state_mods_weaken (mods mods': mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') =
update_state_mods_from mods s' s; let f1 (m0: mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.update_state_mods_from
val update_state_mods_from (mods: mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s'))
val update_state_mods_from (mods: mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s'))
let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 76, "start_col": 0, "start_line": 66 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mods: Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCode.update_state_mods mods s' s == s') (ensures forall (m0: Vale.X64.QuickCode.mod_t). {:pattern Vale.X64.QuickCodes.mods_contains1 mods m0\/Vale.X64.QuickCodes.state_mod_eq m0 s s'} Vale.X64.QuickCodes.mods_contains1 mods m0 \/ Vale.X64.QuickCodes.state_mod_eq m0 s s')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "FStar.Classical.forall_intro", "Vale.X64.QuickCode.mod_t", "Prims.l_or", "Prims.b2t", "Vale.X64.QuickCodes.mods_contains1", "Vale.X64.QuickCodes.state_mod_eq", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.X64.QuickCodes.update_state_mods_from1", "Prims.eq2", "Vale.X64.QuickCode.update_state_mods", "Prims.l_Forall" ]
[]
false
false
true
false
false
let update_state_mods_from (mods: mods_t) (s' s: vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s')) =
let f1 (m0: mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.update_state_mods_to
val update_state_mods_to (mods: mods_t) (s' s: vale_state) : Lemma (requires (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s')) (ensures state_eq s' (update_state_mods mods s' s))
val update_state_mods_to (mods: mods_t) (s' s: vale_state) : Lemma (requires (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s')) (ensures state_eq s' (update_state_mods mods s' s))
let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in ()
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 107, "start_col": 0, "start_line": 78 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mods: Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> FStar.Pervasives.Lemma (requires forall (m0: Vale.X64.QuickCode.mod_t). {:pattern Vale.X64.QuickCodes.mods_contains1 mods m0\/Vale.X64.QuickCodes.state_mod_eq m0 s s'} Vale.X64.QuickCodes.mods_contains1 mods m0 \/ Vale.X64.QuickCodes.state_mod_eq m0 s s') (ensures Vale.X64.State.state_eq s' (Vale.X64.QuickCode.update_state_mods mods s' s))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.Arch.HeapImpl.heaplet_id", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Vale.Arch.HeapImpl.vale_heap", "Vale.Lib.Map16.sel", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets", "Vale.X64.State.__proj__Mkvale_state__item__vs_heap", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil", "Vale.X64.QuickCode.Mod_mem_heaplet", "Vale.X64.Machine_s.reg", "Vale.X64.Machine_s.t_reg", "Vale.X64.Regs.sel", "Vale.X64.State.__proj__Mkvale_state__item__vs_regs", "Vale.X64.QuickCode.Mod_reg", "Vale.X64.QuickCode.Mod_stackTaint", "Vale.X64.QuickCode.Mod_stack", "Vale.X64.QuickCode.Mod_mem_layout", "Vale.X64.QuickCode.Mod_mem", "Vale.X64.QuickCode.Mod_flags", "Vale.X64.QuickCode.Mod_ok", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCodes.state_mod_eq", "Vale.X64.QuickCodes.update_state_mods_to1", "Vale.X64.QuickCode.update_state_mods", "Prims.l_Forall", "Prims.l_or", "Prims.b2t", "Vale.X64.QuickCodes.mods_contains1", "Vale.X64.State.state_eq" ]
[]
false
false
true
false
false
let update_state_mods_to (mods: mods_t) (s' s: vale_state) : Lemma (requires (forall (m0: mod_t). {:pattern mods_contains1 mods m0\/state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s')) (ensures state_eq s' (update_state_mods mods s' s)) =
let s'' = update_state_mods mods s' s in let f1 (m0: mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r: reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n: heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in ()
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.update_state_mods_weaken1
val update_state_mods_weaken1 (mods mods': mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
val update_state_mods_weaken1 (mods mods': mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s'))
let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 125, "start_col": 0, "start_line": 117 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mods: Vale.X64.QuickCode.mods_t -> mods': Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> m0: Vale.X64.QuickCode.mod_t -> FStar.Pervasives.Lemma (requires (Vale.X64.QuickCodes.mods_contains1 mods m0 \/ Vale.X64.QuickCodes.state_mod_eq m0 s s') /\ Vale.X64.QuickCodes.mods_contains mods' mods) (ensures Vale.X64.QuickCodes.mods_contains1 mods' m0 \/ Vale.X64.QuickCodes.state_mod_eq m0 s s')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.mod_t", "Prims.list", "Prims.op_AmpAmp", "Vale.X64.QuickCodes.mods_contains", "Vale.X64.QuickCodes.mods_contains1", "Vale.X64.QuickCodes.update_state_mods_weaken1", "Prims.bool", "Prims.unit", "Prims.l_and", "Prims.l_or", "Prims.b2t", "Vale.X64.QuickCodes.state_mod_eq", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec update_state_mods_weaken1 (mods mods': mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) =
match mods with | [] -> () | _ :: mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.update_state_mods_to1
val update_state_mods_to1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s))
val update_state_mods_to1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s))
let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 64, "start_col": 0, "start_line": 53 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mods: Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> m0: Vale.X64.QuickCode.mod_t -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCodes.mods_contains1 mods m0 \/ Vale.X64.QuickCodes.state_mod_eq m0 s s') (ensures Vale.X64.QuickCodes.state_mod_eq m0 s' (Vale.X64.QuickCode.update_state_mods mods s' s))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.mod_t", "Prims.list", "FStar.Classical.or_elim", "Prims.l_not", "Prims.squash", "Prims.unit", "Prims.l_True", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.X64.QuickCodes.update_state_mods_to1", "Prims.l_or", "Vale.X64.QuickCodes.state_mod_eq", "Vale.X64.QuickCode.update_state_mods", "Prims.logical", "Prims.eq2", "Prims.b2t", "Vale.X64.QuickCodes.mods_contains1" ]
[ "recursion" ]
false
false
true
false
false
let rec update_state_mods_to1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) =
match mods with | [] -> () | r :: mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_: squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_: squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_: squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.qInlineIf_proof
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k) (ensures fun (sM, f0, g) -> eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
val qInlineIf_proof (#a:Type) (#c1:code) (#c2:code) (b:bool) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_InlineIf b qc1 qc2 mods s0 k) (ensures fun (sM, f0, g) -> eval_code (if_code b c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) )
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 238, "start_col": 0, "start_line": 226 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Prims.bool -> qc1: Vale.X64.QuickCode.quickCode a c1 -> qc2: Vale.X64.QuickCode.quickCode a c2 -> mods: Vale.X64.QuickCode.mods_t -> s0: Vale.X64.Decls.va_state -> k: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * a)
Prims.Ghost
[]
[]
[ "Vale.X64.QuickCodes.code", "Prims.bool", "Vale.X64.QuickCode.quickCode", "Vale.X64.QuickCode.mods_t", "Vale.X64.Decls.va_state", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Prims.unit", "Vale.X64.QuickCodes.update_state_mods_weaken", "Vale.X64.QuickCode.__proj__QProc__item__mods", "FStar.Pervasives.Native.tuple3", "Vale.X64.QuickCode.__proj__QProc__item__proof" ]
[]
false
false
false
false
false
let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
if b then (let sM, f0, g = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g)) else (let sM, f0, g = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g))
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.update_state_mods_trans
val update_state_mods_trans (mods: mods_t) (s0 s1 s2: vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2)
val update_state_mods_trans (mods: mods_t) (s0 s1 s2: vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2)
let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 115, "start_col": 0, "start_line": 109 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mods: Vale.X64.QuickCode.mods_t -> s0: Vale.X64.State.vale_state -> s1: Vale.X64.State.vale_state -> s2: Vale.X64.State.vale_state -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCode.update_state_mods mods s1 s0 == s1 /\ Vale.X64.QuickCode.update_state_mods mods s2 s1 == s2) (ensures Vale.X64.QuickCode.update_state_mods mods s2 s0 == s2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.update_state_mods_to", "Prims.unit", "Vale.X64.QuickCodes.update_state_mods_from", "Prims.l_and", "Prims.eq2", "Vale.X64.QuickCode.update_state_mods", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let update_state_mods_trans (mods: mods_t) (s0 s1 s2: vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) =
update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.qblock_proof
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_block qcs mods s0 k) (ensures fun (sM, f0, g) -> eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
val qblock_proof (#a:Type) (#cs:codes) (qcs:va_state -> GTot (quickCodes a cs)) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_block qcs mods s0 k) (ensures fun (sM, f0, g) -> eval_code (block cs) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 224, "start_col": 0, "start_line": 223 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
qcs: (_: Vale.X64.Decls.va_state -> Prims.GTot (Vale.X64.QuickCodes.quickCodes a cs)) -> mods: Vale.X64.QuickCode.mods_t -> s0: Vale.X64.Decls.va_state -> k: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * a)
Prims.Ghost
[]
[]
[ "Vale.X64.QuickCodes.codes", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.QuickCode.mods_t", "Vale.X64.QuickCodes.wp_sound", "FStar.Pervasives.Native.tuple3", "Vale.X64.Decls.va_fuel" ]
[]
false
false
false
false
false
let qblock_proof #a #cs qcs mods s0 k =
wp_sound cs (qcs s0) mods k s0
false
Spec.HMAC_DRBG.Test.Vectors.fst
Spec.HMAC_DRBG.Test.Vectors.is_supported_alg
val is_supported_alg : _: Spec.Hash.Definitions.hash_alg -> Prims.bool
let is_supported_alg = function | SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true | _ -> false
{ "file_name": "specs/drbg/Spec.HMAC_DRBG.Test.Vectors.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 15, "start_col": 0, "start_line": 13 }
module Spec.HMAC_DRBG.Test.Vectors open Lib.Meta open Spec.Hash.Definitions #set-options "--fuel 0 --ifuel 0" /// /// HMAC-DRBG test vectors from NIST CAVP /// https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/random-number-generators#DRBG ///
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Meta.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Spec.HMAC_DRBG.Test.Vectors.fst" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Spec.HMAC_DRBG.Test", "short_module": null }, { "abbrev": false, "full_module": "Spec.HMAC_DRBG.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Spec.Hash.Definitions.hash_alg -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.hash_alg", "Prims.bool" ]
[]
false
false
false
true
false
let is_supported_alg =
function | SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true | _ -> false
false
Spec.HMAC_DRBG.Test.Vectors.fst
Spec.HMAC_DRBG.Test.Vectors.supported_alg
val supported_alg : Type0
let supported_alg = a:hash_alg{ is_supported_alg a }
{ "file_name": "specs/drbg/Spec.HMAC_DRBG.Test.Vectors.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 17, "start_col": 0, "start_line": 17 }
module Spec.HMAC_DRBG.Test.Vectors open Lib.Meta open Spec.Hash.Definitions #set-options "--fuel 0 --ifuel 0" /// /// HMAC-DRBG test vectors from NIST CAVP /// https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/random-number-generators#DRBG /// let is_supported_alg = function | SHA1 | SHA2_256 | SHA2_384 | SHA2_512 -> true | _ -> false
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Meta.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Spec.HMAC_DRBG.Test.Vectors.fst" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Spec.HMAC_DRBG.Test", "short_module": null }, { "abbrev": false, "full_module": "Spec.HMAC_DRBG.Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.HMAC_DRBG.Test.Vectors.is_supported_alg" ]
[]
false
false
false
true
true
let supported_alg =
a: hash_alg{is_supported_alg a}
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.wp_sound
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp cs qcs mods k s0) (ensures fun (sN, fN, gN) -> eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN )
val wp_sound (#a:Type0) (cs:codes) (qcs:quickCodes a cs) (mods:mods_t) (k:va_state -> a -> Type0) (s0:va_state) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp cs qcs mods k s0) (ensures fun (sN, fN, gN) -> eval (Block cs) s0 fN sN /\ update_state_mods mods sN s0 == sN /\ state_inv sN /\ k sN gN )
let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 221, "start_col": 0, "start_line": 164 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Vale.X64.QuickCodes.codes -> qcs: Vale.X64.QuickCodes.quickCodes a cs -> mods: Vale.X64.QuickCode.mods_t -> k: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> s0: Vale.X64.Decls.va_state -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * a)
Prims.Ghost
[]
[]
[ "Vale.X64.QuickCodes.codes", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.QuickCode.mods_t", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_lemma_empty_total", "Prims.Nil", "Vale.X64.Decls.va_code", "Prims.unit", "Vale.X64.QuickCodes.update_state_mods_refl", "Vale.X64.QuickCodes.code", "FStar.Range.range", "Prims.string", "Vale.X64.QuickCode.quickCode", "Vale.X64.QuickCode.quickProc_wp", "Vale.X64.QuickCode.t_proof", "Prims.list", "Vale.X64.QuickCodes.update_state_mods_trans", "Vale.X64.QuickCodes.update_state_mods_weaken", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.X64.Decls.va_lemma_merge_total", "Prims.Cons", "Vale.X64.QuickCodes.wp_sound", "Vale.X64.QuickCodes.wp_Seq_t", "Vale.X64.QuickCodes.wp_Seq", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.QuickCodes.wp_Bind_t", "Vale.X64.QuickCodes.wp_Bind", "FStar.Monotonic.Pure.is_monotonic", "FStar.Monotonic.Pure.as_pure_wp", "Vale.X64.QuickCodes.call_QPURE", "Prims.squash", "FStar.Pervasives.pattern", "Vale.X64.QuickCodes.k_AssertBy", "Vale.X64.QuickCodes.empty_list_is_small" ]
[ "recursion" ]
false
false
false
false
false
let rec wp_sound #a cs qcs mods k s0 =
let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let sN, fN = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c :: cs = cs in let k' = wp_Seq cs qcs mods k in let sM, fM, gM = proof s0 k' in let sN, fN, gN = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c :: cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c :: cs = cs in let k' = wp_Bind cs qcs mods k in let sM, fM, gM = proof s0 k' in let sN, fN, gN = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c :: cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c :: cs = cs in let sM, fM = va_lemma_empty_total s0 [] in let sN, fN, gN = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c :: cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c :: cs = cs in let sM, fM = va_lemma_empty_total s0 [] in let g = l () in let sN, fN, gN = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c :: cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.qAssertLemma
val qAssertLemma (p:Type0) : tAssertLemma p
val qAssertLemma (p:Type0) : tAssertLemma p
let qAssertLemma p = fun () -> ()
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 310, "start_col": 0, "start_line": 310 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Type0 -> Vale.X64.QuickCodes.tAssertLemma p
Prims.Tot
[ "total" ]
[]
[ "Prims.unit" ]
[]
false
false
false
true
false
let qAssertLemma p =
fun () -> ()
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.update_state_mods_not1
val update_state_mods_not1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s))
val update_state_mods_not1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s))
let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 45, "start_col": 0, "start_line": 39 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mods: Vale.X64.QuickCode.mods_t -> s': Vale.X64.State.vale_state -> s: Vale.X64.State.vale_state -> m0: Vale.X64.QuickCode.mod_t -> FStar.Pervasives.Lemma (requires Prims.op_Negation (Vale.X64.QuickCodes.mods_contains1 mods m0)) (ensures Vale.X64.QuickCodes.state_mod_eq m0 s (Vale.X64.QuickCode.update_state_mods mods s' s))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.mod_t", "Prims.list", "Vale.X64.QuickCodes.update_state_mods_not1", "Prims.unit", "Prims.b2t", "Prims.op_Negation", "Vale.X64.QuickCodes.mods_contains1", "Prims.squash", "Vale.X64.QuickCodes.state_mod_eq", "Vale.X64.QuickCode.update_state_mods", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec update_state_mods_not1 (mods: mods_t) (s' s: vale_state) (m0: mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) =
match mods with | [] -> () | _ :: mods -> update_state_mods_not1 mods s' s m0
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.qIf_proof
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k) (ensures fun (sM, f0, g) -> eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
val qIf_proof (#a:Type) (#c1:code) (#c2:code) (b:cmp) (qc1:quickCode a c1) (qc2:quickCode a c2) (mods:mods_t) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_If b qc1 qc2 mods s0 k) (ensures fun (sM, f0, g) -> eval_code (IfElse (cmp_to_ocmp b) c1 c2) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) )
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 266, "start_col": 0, "start_line": 240 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) )
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.QuickCodes.cmp -> qc1: Vale.X64.QuickCode.quickCode a c1 -> qc2: Vale.X64.QuickCode.quickCode a c2 -> mods: Vale.X64.QuickCode.mods_t -> s0: Vale.X64.Decls.va_state -> k: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * a)
Prims.Ghost
[]
[]
[ "Vale.X64.QuickCodes.code", "Vale.X64.QuickCodes.cmp", "Vale.X64.QuickCode.quickCode", "Vale.X64.QuickCode.mods_t", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.eval_cmp", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Prims.unit", "Vale.X64.QuickCodes.update_state_mods_trans", "Vale.X64.QuickCodes.update_state_mods_weaken", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.X64.Decls.va_lemma_ifElseTrue_total", "Vale.X64.QuickCodes.cmp_to_ocmp", "FStar.Pervasives.Native.tuple3", "Vale.X64.QuickCode.__proj__QProc__item__proof", "Prims.bool", "Vale.X64.Decls.va_lemma_ifElseFalse_total", "Vale.X64.QuickCodes.update_state_mods_to", "Vale.X64.State.Mkvale_state", "Vale.X64.State.__proj__Mkvale_state__item__vs_ok", "Vale.X64.State.__proj__Mkvale_state__item__vs_regs", "Vale.X64.Decls.havoc_flags", "Vale.X64.State.__proj__Mkvale_state__item__vs_heap", "Vale.X64.State.__proj__Mkvale_state__item__vs_stack", "Vale.X64.State.__proj__Mkvale_state__item__vs_stackTaint", "Vale.X64.Machine_s.operand64", "Prims.b2t", "Prims.op_Negation", "Prims.op_BarBar", "Vale.X64.Machine_s.uu___is_OMem", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.uu___is_OStack", "Vale.X64.Decls.lemma_cmp_eq", "Vale.X64.Decls.lemma_valid_cmp_eq", "Vale.X64.Decls.lemma_cmp_ne", "Vale.X64.Decls.lemma_valid_cmp_ne", "Vale.X64.Decls.lemma_cmp_le", "Vale.X64.Decls.lemma_valid_cmp_le", "Vale.X64.Decls.lemma_cmp_ge", "Vale.X64.Decls.lemma_valid_cmp_ge", "Vale.X64.Decls.lemma_cmp_lt", "Vale.X64.Decls.lemma_valid_cmp_lt", "Vale.X64.Decls.lemma_cmp_gt", "Vale.X64.Decls.lemma_valid_cmp_gt" ]
[]
false
false
false
false
false
let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k =
(match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2); let s1 = { s0 with vs_flags = havoc_flags } in update_state_mods_to mods s1 s0; if eval_cmp s0 b then (let sM, f0, g = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g)) else (let sM, f0, g = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g))
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.call_QPURE
val call_QPURE (#a: Type0) (#cs: codes) (r: range) (msg: string) (pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l: (unit -> PURE unit (as_pure_wp pre))) (qcs: quickCodes a cs) (mods: mods_t) (k: (vale_state -> a -> Type0)) (s0: vale_state) : Lemma (requires (forall (p: (unit -> GTot Type0)). {:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0)
val call_QPURE (#a: Type0) (#cs: codes) (r: range) (msg: string) (pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l: (unit -> PURE unit (as_pure_wp pre))) (qcs: quickCodes a cs) (mods: mods_t) (k: (vale_state -> a -> Type0)) (s0: vale_state) : Lemma (requires (forall (p: (unit -> GTot Type0)). {:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0)
let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l ()
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 6, "end_line": 147, "start_col": 0, "start_line": 138 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> msg: Prims.string -> pre: (_: (_: Prims.unit -> Prims.GTot Type0) -> Prims.GTot Type0) {FStar.Monotonic.Pure.is_monotonic pre} -> l: (_: Prims.unit -> Prims.PURE Prims.unit) -> qcs: Vale.X64.QuickCodes.quickCodes a cs -> mods: Vale.X64.QuickCode.mods_t -> k: (_: Vale.X64.State.vale_state -> _: a -> Type0) -> s0: Vale.X64.State.vale_state -> FStar.Pervasives.Lemma (requires forall (p: (_: Prims.unit -> Prims.GTot Type0)). {:pattern pre p} (Vale.X64.QuickCodes.wp cs qcs mods k s0 ==> p ()) ==> Vale.X64.QuickCodes.label r msg (pre p)) (ensures Vale.X64.QuickCodes.wp cs qcs mods k s0)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.QuickCodes.codes", "FStar.Range.range", "Prims.string", "Prims.unit", "FStar.Monotonic.Pure.is_monotonic", "FStar.Monotonic.Pure.as_pure_wp", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Prims.l_Forall", "Prims.l_imp", "Vale.X64.QuickCodes.wp", "Vale.X64.QuickCodes.label", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let call_QPURE (#a: Type0) (#cs: codes) (r: range) (msg: string) (pre: ((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l: (unit -> PURE unit (as_pure_wp pre))) (qcs: quickCodes a cs) (mods: mods_t) (k: (vale_state -> a -> Type0)) (s0: vale_state) : Lemma (requires (forall (p: (unit -> GTot Type0)). {:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) =
l ()
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.qAssertSquashLemma
val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p
val qAssertSquashLemma (p:Type0) : tAssertSquashLemma p
let qAssertSquashLemma p = fun () -> ()
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 312, "start_col": 0, "start_line": 312 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Type0 -> Vale.X64.QuickCodes.tAssertSquashLemma p
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "Prims.squash" ]
[]
false
false
false
true
false
let qAssertSquashLemma p =
fun () -> ()
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.wp_sound_code
val wp_sound_code (#a:Type0) (c:code) (qc:quickCode a c) (k:va_state -> a -> Type0) (s0:va_state) : Ghost (va_state & fuel & a) (requires t_require s0 /\ QProc?.wp qc s0 k) (ensures fun (sN, fN, gN) -> eval_code c s0 fN sN /\ update_state_mods qc.mods sN s0 == sN /\ state_inv sN /\ k sN gN)
val wp_sound_code (#a:Type0) (c:code) (qc:quickCode a c) (k:va_state -> a -> Type0) (s0:va_state) : Ghost (va_state & fuel & a) (requires t_require s0 /\ QProc?.wp qc s0 k) (ensures fun (sN, fN, gN) -> eval_code c s0 fN sN /\ update_state_mods qc.mods sN s0 == sN /\ state_inv sN /\ k sN gN)
let wp_sound_code #a c qc k s0 = let QProc c _ wp proof = qc in proof s0 k
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 12, "end_line": 319, "start_col": 0, "start_line": 317 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> () let qAssumeLemma p = fun () -> assume p let qAssertSquashLemma p = fun () -> () //let qAssertByLemma #a p qcs mods s0 = // fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: Vale.X64.QuickCodes.code -> qc: Vale.X64.QuickCode.quickCode a c -> k: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> s0: Vale.X64.Decls.va_state -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.QuickCodes.fuel) * a)
Prims.Ghost
[]
[]
[ "Vale.X64.QuickCodes.code", "Vale.X64.QuickCode.quickCode", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_code", "Vale.X64.QuickCode.mods_t", "Vale.X64.QuickCode.quickProc_wp", "Vale.X64.QuickCode.t_proof", "FStar.Pervasives.Native.tuple3", "Vale.X64.QuickCodes.fuel" ]
[]
false
false
false
false
false
let wp_sound_code #a c qc k s0 =
let QProc c _ wp proof = qc in proof s0 k
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.lemma_state_match
val lemma_state_match (s0:va_state) (s1:va_state) : Lemma (requires state_match s0 s1) (ensures state_eq s0 s1)
val lemma_state_match (s0:va_state) (s1:va_state) : Lemma (requires state_match s0 s1) (ensures state_eq s0 s1)
let lemma_state_match s0 s1 = lemma_regs_match s0.vs_regs s1.vs_regs n_reg_files; assert (Regs.equal s0.vs_regs s1.vs_regs)
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 43, "end_line": 337, "start_col": 0, "start_line": 335 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> () let qAssumeLemma p = fun () -> assume p let qAssertSquashLemma p = fun () -> () //let qAssertByLemma #a p qcs mods s0 = // fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in () let wp_sound_code #a c qc k s0 = let QProc c _ wp proof = qc in proof s0 k let rec lemma_regs_match_file (r0:Regs.t) (r1:Regs.t) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i:nat).{:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then lemma_regs_match_file r0 r1 rf (k - 1) let rec lemma_regs_match (r0:Regs.t) (r1:Regs.t) (k:nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i j:nat).{:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then (lemma_regs_match_file r0 r1 (k - 1) (n_regs (k - 1)); lemma_regs_match r0 r1 (k - 1))
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s0: Vale.X64.Decls.va_state -> s1: Vale.X64.Decls.va_state -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCodes.state_match s0 s1) (ensures Vale.X64.State.state_eq s0 s1)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Decls.va_state", "Prims._assert", "Vale.X64.Regs.equal", "Vale.X64.State.__proj__Mkvale_state__item__vs_regs", "Prims.unit", "Vale.X64.QuickCodes.lemma_regs_match", "Vale.X64.Machine_s.n_reg_files" ]
[]
true
false
true
false
false
let lemma_state_match s0 s1 =
lemma_regs_match s0.vs_regs s1.vs_regs n_reg_files; assert (Regs.equal s0.vs_regs s1.vs_regs)
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.qWhile_proof_rec
val qWhile_proof_rec (#a #d: Type) (#c: code) (b: cmp) (qc: (a -> quickCode a c)) (mods: mods_t) (inv: (vale_state -> a -> Type0)) (dec: (vale_state -> a -> d)) (s0 s1: vale_state) (g1: a) (f1: fuel) (k: (vale_state -> a -> Type0)) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2) (decreases (dec s1 g1))
val qWhile_proof_rec (#a #d: Type) (#c: code) (b: cmp) (qc: (a -> quickCode a c)) (mods: mods_t) (inv: (vale_state -> a -> Type0)) (dec: (vale_state -> a -> d)) (s0 s1: vale_state) (g1: a) (f1: fuel) (k: (vale_state -> a -> Type0)) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2) (decreases (dec s1 g1))
let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) )
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 302, "start_col": 0, "start_line": 268 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) )
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.QuickCodes.cmp -> qc: (_: a -> Vale.X64.QuickCode.quickCode a c) -> mods: Vale.X64.QuickCode.mods_t -> inv: (_: Vale.X64.State.vale_state -> _: a -> Type0) -> dec: (_: Vale.X64.State.vale_state -> _: a -> d) -> s0: Vale.X64.State.vale_state -> s1: Vale.X64.State.vale_state -> g1: a -> f1: Vale.X64.QuickCodes.fuel -> k: (_: Vale.X64.State.vale_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.State.vale_state * Vale.X64.Decls.va_fuel) * a)
Prims.Ghost
[ "" ]
[]
[ "Vale.X64.QuickCodes.code", "Vale.X64.QuickCodes.cmp", "Vale.X64.QuickCode.quickCode", "Vale.X64.QuickCode.mods_t", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.fuel", "Vale.X64.QuickCodes.eval_cmp", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCodes.qWhile_proof_rec", "Prims.unit", "Vale.X64.QuickCodes.update_state_mods_trans", "Vale.X64.QuickCodes.update_state_mods_weaken", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.X64.Decls.va_lemma_whileMerge_total", "Vale.X64.Machine_s.While", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "FStar.Pervasives.Native.tuple3", "Vale.X64.QuickCode.__proj__QProc__item__proof", "FStar.Pervasives.Native.tuple2", "Vale.X64.Decls.va_lemma_whileTrue_total", "Vale.X64.QuickCode.quickProc_wp", "Vale.X64.QuickCode.__proj__QProc__item__wp", "Vale.X64.QuickCodes.wp_While_inv", "Prims.bool", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.Decls.va_lemma_whileFalse_total", "Vale.X64.QuickCodes.update_state_mods_to", "Vale.X64.State.Mkvale_state", "Vale.X64.State.__proj__Mkvale_state__item__vs_ok", "Vale.X64.State.__proj__Mkvale_state__item__vs_regs", "Vale.X64.Decls.havoc_flags", "Vale.X64.State.__proj__Mkvale_state__item__vs_heap", "Vale.X64.State.__proj__Mkvale_state__item__vs_stack", "Vale.X64.State.__proj__Mkvale_state__item__vs_stackTaint", "Vale.X64.QuickCodes.cmp_to_ocmp", "Prims.l_and", "Vale.X64.Decls.state_inv", "Vale.X64.QuickCodes.wp_While", "Vale.X64.Decls.eval_while_inv", "Prims.eq2", "Vale.X64.QuickCode.update_state_mods", "Vale.X64.Decls.eval_code" ]
[ "recursion" ]
false
false
false
false
false
let rec qWhile_proof_rec (#a #d: Type) (#c: code) (b: cmp) (qc: (a -> quickCode a c)) (mods: mods_t) (inv: (vale_state -> a -> Type0)) (dec: (vale_state -> a -> d)) (s0 s1: vale_state) (g1: a) (f1: fuel) (k: (vale_state -> a -> Type0)) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2) (decreases (dec s1 g1)) =
let ob = cmp_to_ocmp b in let s1' = { s1 with vs_flags = havoc_flags } in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then (let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let s2, f2 = va_lemma_whileTrue_total ob c s0 s1 f1 in let sc, fc, gc = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k) else (let s2, f2 = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1))
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.wp_sound_code_wrap
val wp_sound_code_wrap (#a: Type0) (c: code) (qc: quickCode a c) (s0: vale_state) (k: (s0': vale_state{s0 == s0'} -> vale_state -> a -> Type0)) : Ghost (vale_state & fuel & a) (t_require s0 /\ wp_sound_code_pre qc s0 k) (wp_sound_code_post qc s0 k)
val wp_sound_code_wrap (#a: Type0) (c: code) (qc: quickCode a c) (s0: vale_state) (k: (s0': vale_state{s0 == s0'} -> vale_state -> a -> Type0)) : Ghost (vale_state & fuel & a) (t_require s0 /\ wp_sound_code_pre qc s0 k) (wp_sound_code_post qc s0 k)
let wp_sound_code_wrap (#a:Type0) (c:code) (qc:quickCode a c) (s0:vale_state) (k:(s0':vale_state{s0 == s0'}) -> vale_state -> a -> Type0) : Ghost (vale_state & fuel & a) (t_require s0 /\ wp_sound_code_pre qc s0 k) (wp_sound_code_post qc s0 k) = wp_sound_code c qc (k s0) s0
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 344, "start_col": 0, "start_line": 339 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> () let qAssumeLemma p = fun () -> assume p let qAssertSquashLemma p = fun () -> () //let qAssertByLemma #a p qcs mods s0 = // fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in () let wp_sound_code #a c qc k s0 = let QProc c _ wp proof = qc in proof s0 k let rec lemma_regs_match_file (r0:Regs.t) (r1:Regs.t) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i:nat).{:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then lemma_regs_match_file r0 r1 rf (k - 1) let rec lemma_regs_match (r0:Regs.t) (r1:Regs.t) (k:nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i j:nat).{:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then (lemma_regs_match_file r0 r1 (k - 1) (n_regs (k - 1)); lemma_regs_match r0 r1 (k - 1)) let lemma_state_match s0 s1 = lemma_regs_match s0.vs_regs s1.vs_regs n_reg_files; assert (Regs.equal s0.vs_regs s1.vs_regs)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: Vale.X64.QuickCodes.code -> qc: Vale.X64.QuickCode.quickCode a c -> s0: Vale.X64.State.vale_state -> k: (s0': Vale.X64.State.vale_state{s0 == s0'} -> _: Vale.X64.State.vale_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.State.vale_state * Vale.X64.QuickCodes.fuel) * a)
Prims.Ghost
[]
[]
[ "Vale.X64.QuickCodes.code", "Vale.X64.QuickCode.quickCode", "Vale.X64.State.vale_state", "Prims.eq2", "Vale.X64.QuickCodes.wp_sound_code", "FStar.Pervasives.Native.tuple3", "Vale.X64.QuickCodes.fuel", "Prims.l_and", "Vale.X64.QuickCode.t_require", "Vale.X64.QuickCodes.wp_sound_code_pre", "Vale.X64.QuickCodes.wp_sound_code_post" ]
[]
false
false
false
false
false
let wp_sound_code_wrap (#a: Type0) (c: code) (qc: quickCode a c) (s0: vale_state) (k: (s0': vale_state{s0 == s0'} -> vale_state -> a -> Type0)) : Ghost (vale_state & fuel & a) (t_require s0 /\ wp_sound_code_pre qc s0 k) (wp_sound_code_post qc s0 k) =
wp_sound_code c qc (k s0) s0
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.lemma_regs_match_file
val lemma_regs_match_file (r0 r1: Regs.t) (rf: reg_file_id) (k: nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i: nat). {:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1)))
val lemma_regs_match_file (r0 r1: Regs.t) (rf: reg_file_id) (k: nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i: nat). {:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1)))
let rec lemma_regs_match_file (r0:Regs.t) (r1:Regs.t) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i:nat).{:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then lemma_regs_match_file r0 r1 rf (k - 1)
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 54, "end_line": 326, "start_col": 0, "start_line": 321 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> () let qAssumeLemma p = fun () -> assume p let qAssertSquashLemma p = fun () -> () //let qAssertByLemma #a p qcs mods s0 = // fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in () let wp_sound_code #a c qc k s0 = let QProc c _ wp proof = qc in proof s0 k
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r0: Vale.X64.Regs.t -> r1: Vale.X64.Regs.t -> rf: Vale.X64.Machine_s.reg_file_id -> k: Prims.nat{k <= Vale.X64.Machine_s.n_regs rf} -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCodes.regs_match_file r0 r1 rf k) (ensures forall (i: Prims.nat). {:pattern Vale.X64.Machine_s.Reg rf i} i < k ==> (let r = Vale.X64.Machine_s.Reg rf i in Vale.X64.Regs.sel r r0 == Vale.X64.Regs.sel r r1))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Regs.t", "Vale.X64.Machine_s.reg_file_id", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Vale.X64.Machine_s.n_regs", "Prims.op_GreaterThan", "Vale.X64.QuickCodes.lemma_regs_match_file", "Prims.op_Subtraction", "Prims.bool", "Prims.unit", "Vale.X64.QuickCodes.regs_match_file", "Prims.squash", "Prims.l_Forall", "Prims.l_imp", "Prims.op_LessThan", "Prims.eq2", "Vale.X64.Machine_s.t_reg", "Vale.X64.Regs.sel", "Vale.X64.Machine_s.reg", "Vale.X64.Machine_s.Reg", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec lemma_regs_match_file (r0 r1: Regs.t) (rf: reg_file_id) (k: nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i: nat). {:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1))) =
if k > 0 then lemma_regs_match_file r0 r1 rf (k - 1)
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.qWhile_proof
val qWhile_proof (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0) (dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k) (ensures fun (sM, f0, g) -> eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
val qWhile_proof (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:va_state -> a -> Type0) (dec:va_state -> a -> d) (g0:a) (s0:va_state) (k:va_state -> a -> Type0) : Ghost (va_state & va_fuel & a) (requires t_require s0 /\ wp_While b qc mods inv dec g0 s0 k) (ensures fun (sM, f0, g) -> eval_code (While (cmp_to_ocmp b) c) s0 f0 sM /\ update_state_mods mods sM s0 == sM /\ state_inv sM /\ k sM g )
let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 308, "start_col": 0, "start_line": 304 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) )
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Vale.X64.QuickCodes.cmp -> qc: (_: a -> Vale.X64.QuickCode.quickCode a c) -> mods: Vale.X64.QuickCode.mods_t -> inv: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> dec: (_: Vale.X64.Decls.va_state -> _: a -> d) -> g0: a -> s0: Vale.X64.Decls.va_state -> k: (_: Vale.X64.Decls.va_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * a)
Prims.Ghost
[]
[]
[ "Vale.X64.QuickCodes.code", "Vale.X64.QuickCodes.cmp", "Vale.X64.QuickCode.quickCode", "Vale.X64.QuickCode.mods_t", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCodes.qWhile_proof_rec", "Prims.unit", "Vale.X64.QuickCodes.update_state_mods_refl", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_lemma_while_total", "Vale.X64.Decls.ocmp", "Vale.X64.QuickCodes.cmp_to_ocmp" ]
[]
false
false
false
false
false
let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k =
let ob = cmp_to_ocmp b in let s1, f1 = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.va_wp_sound_code_norm
val va_wp_sound_code_norm (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) : Ghost (va_state & fuel & a) (t_require s0 /\ normal (wp_sound_code_pre qc s0 k)) (wp_sound_code_post qc s0 k)
val va_wp_sound_code_norm (#a:Type0) (c:code) (qc:quickCode a c) (s0:va_state) (k:(s0':va_state{s0 == s0'}) -> va_state -> a -> Type0) : Ghost (va_state & fuel & a) (t_require s0 /\ normal (wp_sound_code_pre qc s0 k)) (wp_sound_code_post qc s0 k)
let va_wp_sound_code_norm #a c qc s0 k = assert_normal (wp_sound_code_pre qc s0 k); wp_sound_code_wrap c qc s0 k
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 354, "start_col": 0, "start_line": 352 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> () let qAssumeLemma p = fun () -> assume p let qAssertSquashLemma p = fun () -> () //let qAssertByLemma #a p qcs mods s0 = // fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in () let wp_sound_code #a c qc k s0 = let QProc c _ wp proof = qc in proof s0 k let rec lemma_regs_match_file (r0:Regs.t) (r1:Regs.t) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i:nat).{:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then lemma_regs_match_file r0 r1 rf (k - 1) let rec lemma_regs_match (r0:Regs.t) (r1:Regs.t) (k:nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i j:nat).{:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then (lemma_regs_match_file r0 r1 (k - 1) (n_regs (k - 1)); lemma_regs_match r0 r1 (k - 1)) let lemma_state_match s0 s1 = lemma_regs_match s0.vs_regs s1.vs_regs n_reg_files; assert (Regs.equal s0.vs_regs s1.vs_regs) let wp_sound_code_wrap (#a:Type0) (c:code) (qc:quickCode a c) (s0:vale_state) (k:(s0':vale_state{s0 == s0'}) -> vale_state -> a -> Type0) : Ghost (vale_state & fuel & a) (t_require s0 /\ wp_sound_code_pre qc s0 k) (wp_sound_code_post qc s0 k) = wp_sound_code c qc (k s0) s0 let assert_normal (p:Type) : Lemma (requires normal p) (ensures p) = ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: Vale.X64.QuickCodes.code -> qc: Vale.X64.QuickCode.quickCode a c -> s0: Vale.X64.Decls.va_state -> k: (s0': Vale.X64.Decls.va_state{s0 == s0'} -> _: Vale.X64.Decls.va_state -> _: a -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.QuickCodes.fuel) * a)
Prims.Ghost
[]
[]
[ "Vale.X64.QuickCodes.code", "Vale.X64.QuickCode.quickCode", "Vale.X64.Decls.va_state", "Prims.eq2", "Vale.X64.QuickCodes.wp_sound_code_wrap", "Prims.unit", "Vale.X64.QuickCodes.assert_normal", "Vale.X64.QuickCodes.wp_sound_code_pre", "FStar.Pervasives.Native.tuple3", "Vale.X64.QuickCodes.fuel" ]
[]
false
false
false
false
false
let va_wp_sound_code_norm #a c qc s0 k =
assert_normal (wp_sound_code_pre qc s0 k); wp_sound_code_wrap c qc s0 k
false
Vale.X64.QuickCodes.fst
Vale.X64.QuickCodes.lemma_regs_match
val lemma_regs_match (r0 r1: Regs.t) (k: nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i: nat) (j: nat). {:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1)))
val lemma_regs_match (r0 r1: Regs.t) (k: nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i: nat) (j: nat). {:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1)))
let rec lemma_regs_match (r0:Regs.t) (r1:Regs.t) (k:nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i j:nat).{:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then (lemma_regs_match_file r0 r1 (k - 1) (n_regs (k - 1)); lemma_regs_match r0 r1 (k - 1))
{ "file_name": "vale/code/arch/x64/Vale.X64.QuickCodes.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 102, "end_line": 333, "start_col": 0, "start_line": 328 }
module Vale.X64.QuickCodes open FStar.Mul open Vale.Arch.HeapImpl open FStar.Range module Map16 = Vale.Lib.Map16 #reset-options "--initial_ifuel 1 --z3rlimit 30" let lemma_label_Type0 (r:range) (msg:string) (p:Type0) : Lemma (requires True) (ensures label r msg p ==> p) = () let lemma_label_bool r msg b = lemma_label_Type0 r msg b let rec empty_list_is_small #a x = match x with | [] -> () | h::t -> empty_list_is_small t let state_mod_eq (m:mod_t) (s1 s2:vale_state) = match m with | Mod_None -> True | Mod_ok -> s1.vs_ok == s2.vs_ok | Mod_reg r -> eval_reg r s1 == eval_reg r s2 | Mod_flags -> s1.vs_flags == s2.vs_flags | Mod_mem -> s1.vs_heap.vf_heap == s2.vs_heap.vf_heap | Mod_mem_layout -> s1.vs_heap.vf_layout == s2.vs_heap.vf_layout | Mod_mem_heaplet n -> Map16.sel s1.vs_heap.vf_heaplets n == Map16.sel s2.vs_heap.vf_heaplets n | Mod_stack -> s1.vs_stack == s2.vs_stack | Mod_stackTaint -> s1.vs_stackTaint == s2.vs_stackTaint let rec update_state_mods_refl (mods:mods_t) (s:vale_state) : Lemma (ensures state_eq (update_state_mods mods s s) s) = match mods with | [] -> () | _::mods -> update_state_mods_refl mods s let rec update_state_mods_not1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires not (mods_contains1 mods m0)) (ensures state_mod_eq m0 s (update_state_mods mods s' s)) = match mods with | [] -> () | _::mods -> update_state_mods_not1 mods s' s m0 let update_state_mods_from1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires state_mod_eq m0 s' (update_state_mods mods s' s)) (ensures mods_contains1 mods m0 \/ state_mod_eq m0 s s') = if not (mods_contains1 mods m0) then update_state_mods_not1 mods s' s m0 let rec update_state_mods_to1 (mods:mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires mods_contains1 mods m0 \/ state_mod_eq m0 s s') (ensures state_mod_eq m0 s' (update_state_mods mods s' s)) = match mods with | [] -> () | r::mods' -> let b = r =!= m0 \/ state_mod_eq m0 s s' in let goal (_:squash (b \/ ~b)) : Type0 = state_mod_eq m0 s' (update_state_mods mods s' s) in let l1 (_:squash b) : Lemma (goal ()) = update_state_mods_to1 mods' s' s m0 in let l2 (_:squash (~b)) : Lemma (goal ()) = () in FStar.Classical.or_elim #b #(~b) #goal l1 l2 let update_state_mods_from (mods:mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s') (ensures ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) = let f1 (m0:mod_t) : Lemma (mods_contains1 mods m0 \/ state_mod_eq m0 s s') = update_state_mods_from1 mods s' s m0 in FStar.Classical.forall_intro f1 let update_state_mods_to (mods:mods_t) (s' s:vale_state) : Lemma (requires ( forall (m0:mod_t).{:pattern mods_contains1 mods m0 \/ state_mod_eq m0 s s'} mods_contains1 mods m0 \/ state_mod_eq m0 s s' )) (ensures state_eq s' (update_state_mods mods s' s)) = let s'' = update_state_mods mods s' s in let f1 (m0:mod_t) : Lemma (state_mod_eq m0 s' s'') = update_state_mods_to1 mods s' s m0 in f1 Mod_ok; f1 Mod_flags; f1 Mod_mem; f1 Mod_mem_layout; f1 Mod_stack; f1 Mod_stackTaint; let f1_reg (r:reg) : Lemma (ensures Regs.sel r s'.vs_regs == Regs.sel r s''.vs_regs) [SMTPat (Regs.sel r s'.vs_regs)] = f1 (Mod_reg r) in let f1_heaplet (n:heaplet_id) : Lemma (ensures Map16.sel s'.vs_heap.vf_heaplets n == Map16.sel s''.vs_heap.vf_heaplets n) [SMTPat (Map16.sel s'.vs_heap.vf_heaplets n)] = f1 (Mod_mem_heaplet n) in () let update_state_mods_trans (mods:mods_t) (s0 s1 s2:vale_state) : Lemma (requires update_state_mods mods s1 s0 == s1 /\ update_state_mods mods s2 s1 == s2) (ensures update_state_mods mods s2 s0 == s2) = update_state_mods_from mods s1 s0; update_state_mods_from mods s2 s1; update_state_mods_to mods s2 s0 let rec update_state_mods_weaken1 (mods mods':mods_t) (s' s:vale_state) (m0:mod_t) : Lemma (requires (mods_contains1 mods m0 \/ state_mod_eq m0 s s') /\ mods_contains mods' mods) (ensures (mods_contains1 mods' m0 \/ state_mod_eq m0 s s')) = match mods with | [] -> () | _::mods -> if mods_contains mods' mods && mods_contains1 mods m0 then update_state_mods_weaken1 mods mods' s' s m0 let update_state_mods_weaken (mods mods':mods_t) (s' s:vale_state) : Lemma (requires update_state_mods mods s' s == s' /\ mods_contains mods' mods) (ensures update_state_mods mods' s' s == s') = update_state_mods_from mods s' s; let f1 (m0:mod_t) : Lemma (mods_contains1 mods' m0 \/ state_mod_eq m0 s s') = update_state_mods_weaken1 mods mods' s' s m0 in FStar.Classical.forall_intro f1; update_state_mods_to mods' s' s let call_QPURE (#a:Type0) (#cs:codes) (r:range) (msg:string) (pre:((unit -> GTot Type0) -> GTot Type0){is_monotonic pre}) (l:unit -> PURE unit (as_pure_wp pre)) (qcs:quickCodes a cs) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Lemma (requires (forall (p:unit -> GTot Type0).{:pattern pre p} (wp cs qcs mods k s0 ==> p ()) ==> label r msg (pre p))) (ensures wp cs qcs mods k s0) = l () (* let call_QBindPURE (#a #b:Type0) (#cs:codes) (r:range) (msg:string) (pre:((b -> GTot Type0) -> GTot Type0)) (l:unit -> PURE b pre) (qcs:vale_state -> b -> GTot (quickCodes a cs)) (mods:mods_t) (k:vale_state -> a -> Type0) (s0:vale_state) : Ghost b (requires (forall (p:b -> GTot Type0).{:pattern pre p} (forall (g:b).{:pattern guard_free (p g)} wp cs (qcs s0 g) mods k s0 ==> p g) ==> label r msg (pre p))) (ensures fun g -> (wp cs (qcs s0 g) mods k s0)) = l () *) let rec wp_sound #a cs qcs mods k s0 = let qcs0 = qcs in match qcs with | QEmpty g -> update_state_mods_refl mods s0; let (sN, fN) = va_lemma_empty_total s0 [] in (sN, fN, g) | QSeq _ _ qc qcs -> let QProc _ _ wp1' proof = qc in let c::cs = cs in let k' = wp_Seq cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs qcs mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QBind _ _ qc qcs -> let QProc c' _ wp1' proof = qc in let c::cs = cs in let k' = wp_Bind cs qcs mods k in let (sM, fM, gM) = proof s0 k' in let (sN, fN, gN) = wp_sound cs (qcs sM gM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in update_state_mods_weaken qc.mods mods sM s0; update_state_mods_trans mods s0 sM sN; (sN, fN', gN) | QGetState f -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let (sN, fN, gN) = wp_sound cs (f sM) mods k sM in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QPURE r msg pre l qcs' -> call_QPURE r msg pre l qcs' mods k s0; wp_sound cs qcs' mods k s0 (* | QBindPURE b r msg pre l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = call_QBindPURE r msg pre l qcs' mods k s0 in let (sN, fN, gN) = wp_sound cs (qcs' s0 g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) *) | QLemma _ _ pre post l qcs' -> l (); wp_sound cs qcs' mods k s0 | QGhost b _ _ pre post l qcs' -> let c::cs = cs in let (sM, fM) = va_lemma_empty_total s0 [] in let g = l () in let (sN, fN, gN) = wp_sound cs (qcs' g) mods k s0 in let fN' = va_lemma_merge_total (c::cs) s0 fM sM fN sN in (sN, fN', gN) | QAssertBy r msg p qcsBy qcs -> empty_list_is_small cs; let _ = wp_sound [] qcsBy mods (k_AssertBy p) s0 in wp_sound cs qcs mods k s0 let qblock_proof #a #cs qcs mods s0 k = wp_sound cs (qcs s0) mods k s0 let qInlineIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = if b then ( let (sM, f0, g) = QProc?.proof qc1 s0 k in update_state_mods_weaken qc1.mods mods sM s0; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s0 k in update_state_mods_weaken qc2.mods mods sM s0; (sM, f0, g) ) let qIf_proof #a #c1 #c2 b qc1 qc2 mods s0 k = ( match b with | Cmp_eq o1 o2 -> lemma_valid_cmp_eq s0 o1 o2; lemma_cmp_eq s0 o1 o2 | Cmp_ne o1 o2 -> lemma_valid_cmp_ne s0 o1 o2; lemma_cmp_ne s0 o1 o2 | Cmp_le o1 o2 -> lemma_valid_cmp_le s0 o1 o2; lemma_cmp_le s0 o1 o2 | Cmp_ge o1 o2 -> lemma_valid_cmp_ge s0 o1 o2; lemma_cmp_ge s0 o1 o2 | Cmp_lt o1 o2 -> lemma_valid_cmp_lt s0 o1 o2; lemma_cmp_lt s0 o1 o2 | Cmp_gt o1 o2 -> lemma_valid_cmp_gt s0 o1 o2; lemma_cmp_gt s0 o1 o2 ); let s1 = {s0 with vs_flags = havoc_flags} in update_state_mods_to mods s1 s0; if eval_cmp s0 b then ( let (sM, f0, g) = QProc?.proof qc1 s1 k in va_lemma_ifElseTrue_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc1.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) else ( let (sM, f0, g) = QProc?.proof qc2 s1 k in va_lemma_ifElseFalse_total (cmp_to_ocmp b) c1 c2 s0 f0 sM; update_state_mods_weaken qc2.mods mods sM s1; update_state_mods_trans mods s0 s1 sM; (sM, f0, g) ) let rec qWhile_proof_rec (#a #d:Type) (#c:code) (b:cmp) (qc:a -> quickCode a c) (mods:mods_t) (inv:vale_state -> a -> Type0) (dec:vale_state -> a -> d) (s0 s1:vale_state) (g1:a) (f1:fuel) (k:vale_state -> a -> Type0) : Ghost (vale_state & va_fuel & a) (requires state_inv s1 /\ wp_While b qc mods inv dec g1 s1 k /\ eval_while_inv (While (cmp_to_ocmp b) c) s0 f1 s1 /\ update_state_mods mods s1 s0 == s1) (ensures fun (s2, f2, g2) -> eval_code (While (cmp_to_ocmp b) c) s0 f2 s2 /\ update_state_mods mods s2 s0 == s2 /\ state_inv s2 /\ k s2 g2 ) (decreases (dec s1 g1)) = let ob = cmp_to_ocmp b in let s1' = {s1 with vs_flags = havoc_flags} in update_state_mods_to mods s1' s1; update_state_mods_trans mods s0 s1 s1'; if eval_cmp s1 b then ( let inv2 = wp_While_inv qc mods inv dec s1 g1 in let wp = QProc?.wp (qc g1) in let (s2, f2) = va_lemma_whileTrue_total ob c s0 s1 f1 in let (sc, fc, gc) = QProc?.proof (qc g1) s2 inv2 in let fN = va_lemma_whileMerge_total (While ob c) s0 f2 s1 fc sc in update_state_mods_weaken (qc g1).mods mods sc s2; update_state_mods_trans mods s0 s2 sc; qWhile_proof_rec b qc mods inv dec s0 sc gc fN k ) else ( let (s2, f2) = va_lemma_whileFalse_total ob c s0 s1 f1 in (s2, f2, g1) ) let qWhile_proof #a #d #c b qc mods inv dec g0 s0 k = let ob = cmp_to_ocmp b in let (s1, f1) = va_lemma_while_total ob c s0 in update_state_mods_refl mods s0; qWhile_proof_rec b qc mods inv dec s0 s1 g0 f1 k let qAssertLemma p = fun () -> () let qAssumeLemma p = fun () -> assume p let qAssertSquashLemma p = fun () -> () //let qAssertByLemma #a p qcs mods s0 = // fun () -> let _ = wp_sound [] qcs mods (fun _ _ -> p) s0 in () let wp_sound_code #a c qc k s0 = let QProc c _ wp proof = qc in proof s0 k let rec lemma_regs_match_file (r0:Regs.t) (r1:Regs.t) (rf:reg_file_id) (k:nat{k <= n_regs rf}) : Lemma (requires regs_match_file r0 r1 rf k) (ensures (forall (i:nat).{:pattern (Reg rf i)} i < k ==> (let r = Reg rf i in Regs.sel r r0 == Regs.sel r r1))) = if k > 0 then lemma_regs_match_file r0 r1 rf (k - 1)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Regs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.QuickCodes.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r0: Vale.X64.Regs.t -> r1: Vale.X64.Regs.t -> k: Prims.nat{k <= Vale.X64.Machine_s.n_reg_files} -> FStar.Pervasives.Lemma (requires Vale.X64.QuickCodes.regs_match r0 r1 k) (ensures forall (i: Prims.nat) (j: Prims.nat). {:pattern Vale.X64.Machine_s.Reg i j} i < k /\ j < Vale.X64.Machine_s.n_regs i ==> (let r = Vale.X64.Machine_s.Reg i j in Vale.X64.Regs.sel r r0 == Vale.X64.Regs.sel r r1))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Regs.t", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Vale.X64.Machine_s.n_reg_files", "Prims.op_GreaterThan", "Vale.X64.QuickCodes.lemma_regs_match", "Prims.op_Subtraction", "Prims.unit", "Vale.X64.QuickCodes.lemma_regs_match_file", "Vale.X64.Machine_s.n_regs", "Prims.bool", "Vale.X64.QuickCodes.regs_match", "Prims.squash", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "Prims.op_LessThan", "Prims.eq2", "Vale.X64.Machine_s.t_reg", "Vale.X64.Regs.sel", "Vale.X64.Machine_s.reg", "Vale.X64.Machine_s.Reg", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec lemma_regs_match (r0 r1: Regs.t) (k: nat{k <= n_reg_files}) : Lemma (requires regs_match r0 r1 k) (ensures (forall (i: nat) (j: nat). {:pattern (Reg i j)} i < k /\ j < n_regs i ==> (let r = Reg i j in Regs.sel r r0 == Regs.sel r r1))) =
if k > 0 then (lemma_regs_match_file r0 r1 (k - 1) (n_regs (k - 1)); lemma_regs_match r0 r1 (k - 1))
false
Hacl.Impl.K256.PointMul.fst
Hacl.Impl.K256.PointMul.point_mul_g_noalloc
val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4))
val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4))
let point_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 142, "start_col": 0, "start_line": 95 }
module Hacl.Impl.K256.PointMul open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.K256 open Hacl.K256.Scalar open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group include Hacl.K256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 15ul 16ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 15ul 32ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len let point_mul out scalar q = let h0 = ST.get () in SE.exp_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q) 256 (qas_nat h0 scalar) 4; BE.lexp_fw_consttime 15ul 0ul mk_k256_concrete_ops 4ul (null uint64) q 4ul 256ul scalar out val precomp_get_consttime: BE.pow_a_to_small_b_st U64 15ul 0ul mk_k256_concrete_ops 4ul 16ul (BE.table_inv_precomp 15ul 0ul mk_k256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) //SPT256.exp_as_exp_four_nat256_precomp S.mk_k256_comm_monoid //(S.to_aff_point (point_eval h0 q1)) (qas_nat h0 scalar))
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.K256.PointMul.fst" }
[ { "abbrev": false, "full_module": "Hacl.K256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
out: Hacl.Impl.K256.Point.point -> scalar: Hacl.K256.Scalar.qelem -> q1: Hacl.Impl.K256.Point.point -> q2: Hacl.Impl.K256.Point.point -> q3: Hacl.Impl.K256.Point.point -> q4: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.K256.Scalar.qelem", "Hacl.Impl.MultiExponentiation.mk_lexp_four_fw_tables", "Lib.IntTypes.U64", "Hacl.Impl.K256.PointMul.table_inv_w4", "Hacl.Impl.K256.PointMul.precomp_get_consttime", "Lib.Buffer.null", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Lib.Buffer.to_const", "Lib.Buffer.CONST", "Hacl.K256.PrecompTable.precomp_basepoint_table_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_64_table_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_128_table_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_192_table_w4", "Prims.unit", "Hacl.Spec.PrecompBaseTable256.lemma_decompose_nat256_as_four_u64_lbignum", "Lib.Buffer.as_seq", "Hacl.K256.Scalar.qnlimb", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t", "Prims._assert", "Hacl.K256.PrecompTable.precomp_g_pow2_192_table_lemma_w4", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.recall_contents", "Hacl.K256.PrecompTable.precomp_g_pow2_192_table_lseq_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_128_table_lemma_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_128_table_lseq_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_64_table_lemma_w4", "Hacl.K256.PrecompTable.precomp_g_pow2_64_table_lseq_w4", "Hacl.K256.PrecompTable.precomp_basepoint_table_lemma_w4", "Hacl.K256.PrecompTable.precomp_basepoint_table_lseq_w4", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "Hacl.Impl.K256.Group.mk_k256_concrete_ops" ]
[]
false
true
false
false
false
let point_mul_g_noalloc out scalar q1 q2 q3 q4 =
[@@ inline_let ]let len = 15ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_k256_concrete_ops in [@@ inline_let ]let l = 4ul in [@@ inline_let ]let table_len = 16ul in [@@ inline_let ]let bLen = 1ul in [@@ inline_let ]let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_lemma_pattern_args
val faithful_lemma_pattern_args (#b: _) (top1 top2: b) (pats1: list (pattern & bool) {pats1 << top1}) (pats2: list (pattern & bool) {pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1)
val faithful_lemma_pattern_args (#b: _) (top1 top2: b) (pats1: list (pattern & bool) {pats1 << top1}) (pats2: list (pattern & bool) {pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1)
let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 811, "start_col": 0, "start_line": 614 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
top1: b -> top2: b -> pats1: Prims.list (FStar.Stubs.Reflection.V2.Data.pattern * Prims.bool) {pats1 << top1} -> pats2: Prims.list (FStar.Stubs.Reflection.V2.Data.pattern * Prims.bool) {pats2 << top2} -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.allP top1 FStar.Reflection.V2.TermEq.faithful_pattern_arg pats1 /\ FStar.Reflection.V2.TermEq.allP top2 FStar.Reflection.V2.TermEq.faithful_pattern_arg pats2) (ensures FStar.Reflection.V2.TermEq.defined (FStar.Reflection.V2.TermEq.list_dec_cmp top1 top2 FStar.Reflection.V2.TermEq.pat_arg_cmp pats1 pats2)) (decreases pats1)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[ "faithful_lemma", "faithful_lemma_pattern", "faithful_lemma_pattern_arg", "faithful_lemma_pattern_args", "faithful_lemma_branch", "faithful_lemma_branches", "faithful_lemma_arg", "faithful_lemma_binder", "faithful_lemma_qual", "faithful_lemma_attrs_dec", "faithful_lemma_comp" ]
[ "Prims.list", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.V2.Data.pattern", "Prims.bool", "Prims.precedes", "FStar.Reflection.V2.TermEq.defined_list_dec", "FStar.Reflection.V2.TermEq.pat_arg_cmp", "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "FStar.List.Tot.Base.memP", "FStar.Reflection.V2.TermEq.defined", "FStar.Classical.Sugar.implies_intro", "Prims.squash", "FStar.Reflection.V2.TermEq.faithful_lemma_pattern_arg", "FStar.Reflection.V2.TermEq.allP", "FStar.Reflection.V2.TermEq.faithful_pattern_arg", "FStar.Reflection.V2.TermEq.list_dec_cmp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec faithful_lemma_pattern_args #b (top1: b) (top2: b) (pats1: list (pattern & bool) {pats1 << top1}) (pats2: list (pattern & bool) {pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) =
introduce forall x y . L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y . L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. (faithful_lemma_pattern_arg x y))); defined_list_dec top1 top2 pat_arg_cmp pats1 pats2
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_lemma_arg
val faithful_lemma_arg (a1 a2: argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2))
val faithful_lemma_arg (a1 a2: argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2))
let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 811, "start_col": 0, "start_line": 614 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a1: FStar.Stubs.Reflection.V2.Data.argv -> a2: FStar.Stubs.Reflection.V2.Data.argv -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.faithful_arg a1 /\ FStar.Reflection.V2.TermEq.faithful_arg a2) (ensures FStar.Reflection.V2.TermEq.defined (FStar.Reflection.V2.TermEq.arg_cmp a1 a2))
FStar.Pervasives.Lemma
[ "lemma" ]
[ "faithful_lemma", "faithful_lemma_pattern", "faithful_lemma_pattern_arg", "faithful_lemma_pattern_args", "faithful_lemma_branch", "faithful_lemma_branches", "faithful_lemma_arg", "faithful_lemma_binder", "faithful_lemma_qual", "faithful_lemma_attrs_dec", "faithful_lemma_comp" ]
[ "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Pervasives.Native.snd", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.TermEq.faithful_lemma", "FStar.Pervasives.Native.tuple2", "Prims.unit", "FStar.Pervasives.Native.fst", "Prims.l_and", "FStar.Reflection.V2.TermEq.faithful_arg", "Prims.squash", "FStar.Reflection.V2.TermEq.defined", "FStar.Reflection.V2.TermEq.arg_cmp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec faithful_lemma_arg (a1 a2: argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) =
faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ())
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_lemma_binder
val faithful_lemma_binder (b1 b2: binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2))
val faithful_lemma_binder (b1 b2: binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2))
let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 811, "start_col": 0, "start_line": 614 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b1: FStar.Stubs.Reflection.Types.binder -> b2: FStar.Stubs.Reflection.Types.binder -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.faithful_binder b1 /\ FStar.Reflection.V2.TermEq.faithful_binder b2) (ensures FStar.Reflection.V2.TermEq.defined (FStar.Reflection.V2.TermEq.binder_cmp b1 b2))
FStar.Pervasives.Lemma
[ "lemma" ]
[ "faithful_lemma", "faithful_lemma_pattern", "faithful_lemma_pattern_arg", "faithful_lemma_pattern_args", "faithful_lemma_branch", "faithful_lemma_branches", "faithful_lemma_arg", "faithful_lemma_binder", "faithful_lemma_qual", "faithful_lemma_attrs_dec", "faithful_lemma_comp" ]
[ "FStar.Stubs.Reflection.Types.binder", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "FStar.Reflection.V2.TermEq._cmpres", "Prims.l_or", "FStar.Reflection.V2.TermEq.valid", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.aqualv", "Prims.list", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.__proj__Mkbinder_view__item__sort", "FStar.Stubs.Reflection.V2.Data.__proj__Mkbinder_view__item__qual", "FStar.Stubs.Reflection.V2.Data.__proj__Mkbinder_view__item__attrs", "FStar.Reflection.V2.TermEq.op_Amp_Amp_Amp", "FStar.Reflection.V2.TermEq.term_cmp", "FStar.Reflection.V2.TermEq.aqual_cmp", "FStar.Reflection.V2.TermEq.list_dec_cmp", "FStar.Reflection.V2.TermEq.binder_cmp", "FStar.Reflection.V2.TermEq.faithful_lemma_attrs_dec", "FStar.Reflection.V2.TermEq.faithful_lemma", "FStar.Reflection.V2.TermEq.faithful_lemma_qual", "FStar.Stubs.Reflection.V2.Data.binder_view", "Prims.precedes", "FStar.Stubs.Reflection.V2.Builtins.inspect_binder", "Prims.l_and", "FStar.Reflection.V2.TermEq.faithful_binder", "Prims.squash", "FStar.Reflection.V2.TermEq.defined", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec faithful_lemma_binder (b1 b2: binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) =
let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ((term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); ()
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_lemma_qual
val faithful_lemma_qual (q1 q2: aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2))
val faithful_lemma_qual (q1 q2: aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2))
let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 811, "start_col": 0, "start_line": 614 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
q1: FStar.Stubs.Reflection.V2.Data.aqualv -> q2: FStar.Stubs.Reflection.V2.Data.aqualv -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.faithful_qual q1 /\ FStar.Reflection.V2.TermEq.faithful_qual q2) (ensures FStar.Reflection.V2.TermEq.defined (FStar.Reflection.V2.TermEq.aqual_cmp q1 q2))
FStar.Pervasives.Lemma
[ "lemma" ]
[ "faithful_lemma", "faithful_lemma_pattern", "faithful_lemma_pattern_arg", "faithful_lemma_pattern_args", "faithful_lemma_branch", "faithful_lemma_branches", "faithful_lemma_arg", "faithful_lemma_binder", "faithful_lemma_qual", "faithful_lemma_attrs_dec", "faithful_lemma_comp" ]
[ "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.TermEq.faithful_lemma", "FStar.Pervasives.Native.tuple2", "Prims.unit", "Prims.l_and", "FStar.Reflection.V2.TermEq.faithful_qual", "Prims.squash", "FStar.Reflection.V2.TermEq.defined", "FStar.Reflection.V2.TermEq.aqual_cmp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec faithful_lemma_qual (q1 q2: aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) =
match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_lemma_comp
val faithful_lemma_comp (c1 c2: comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2))
val faithful_lemma_comp (c1 c2: comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2))
let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 811, "start_col": 0, "start_line": 614 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c1: FStar.Stubs.Reflection.Types.comp -> c2: FStar.Stubs.Reflection.Types.comp -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.faithful_comp c1 /\ FStar.Reflection.V2.TermEq.faithful_comp c2) (ensures FStar.Reflection.V2.TermEq.defined (FStar.Reflection.V2.TermEq.comp_cmp c1 c2))
FStar.Pervasives.Lemma
[ "lemma" ]
[ "faithful_lemma", "faithful_lemma_pattern", "faithful_lemma_pattern_arg", "faithful_lemma_pattern_args", "faithful_lemma_branch", "faithful_lemma_branches", "faithful_lemma_arg", "faithful_lemma_binder", "faithful_lemma_qual", "faithful_lemma_attrs_dec", "faithful_lemma_comp" ]
[ "FStar.Stubs.Reflection.Types.comp", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.comp_view", "FStar.Stubs.Reflection.V2.Builtins.inspect_comp", "FStar.Stubs.Reflection.Types.typ", "FStar.Reflection.V2.TermEq.faithful_lemma", "FStar.Stubs.Reflection.Types.term", "Prims.unit", "FStar.Stubs.Reflection.V2.Data.universes", "FStar.Stubs.Reflection.Types.name", "Prims.list", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Reflection.V2.TermEq.comp_eq_C_Eff", "FStar.Reflection.V2.TermEq.defined_list_dec", "FStar.Reflection.V2.TermEq.term_cmp", "FStar.Classical.Sugar.forall_intro", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "FStar.List.Tot.Base.memP", "FStar.Reflection.V2.TermEq.defined", "FStar.Classical.Sugar.implies_intro", "Prims.squash", "FStar.Reflection.V2.TermEq.arg_cmp", "FStar.Reflection.V2.TermEq.faithful_lemma_arg", "FStar.Reflection.V2.TermEq.univ_faithful_lemma_list", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.TermEq.faithful_comp", "FStar.Reflection.V2.TermEq.comp_cmp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec faithful_lemma_comp (c1 c2: comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) =
match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y . L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y . L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. (faithful_lemma_arg x y))); defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y . L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y . L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. (faithful_lemma x y))); defined_list_dec c1 c2 term_cmp dec1 dec2; comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> ()
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_lemma_pattern
val faithful_lemma_pattern (p1 p2: pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2))
val faithful_lemma_pattern (p1 p2: pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2))
let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 811, "start_col": 0, "start_line": 614 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p1: FStar.Stubs.Reflection.V2.Data.pattern -> p2: FStar.Stubs.Reflection.V2.Data.pattern -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.faithful_pattern p1 /\ FStar.Reflection.V2.TermEq.faithful_pattern p2) (ensures FStar.Reflection.V2.TermEq.defined (FStar.Reflection.V2.TermEq.pat_cmp p1 p2))
FStar.Pervasives.Lemma
[ "lemma" ]
[ "faithful_lemma", "faithful_lemma_pattern", "faithful_lemma_pattern_arg", "faithful_lemma_pattern_args", "faithful_lemma_branch", "faithful_lemma_branches", "faithful_lemma_arg", "faithful_lemma_binder", "faithful_lemma_qual", "faithful_lemma_attrs_dec", "faithful_lemma_comp" ]
[ "FStar.Stubs.Reflection.V2.Data.pattern", "FStar.Pervasives.Native.Mktuple2", "FStar.Sealed.sealed", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.ppname_t", "FStar.Stubs.Reflection.V2.Data.vconst", "FStar.Reflection.V2.TermEq.faithful_lemma", "FStar.Stubs.Reflection.Types.fv", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.V2.Data.universes", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.bool", "Prims.unit", "FStar.Reflection.V2.TermEq.pat_eq_Pat_Cons", "FStar.Reflection.V2.TermEq.faithful_lemma_pattern_args", "Prims.squash", "FStar.Reflection.V2.TermEq.defined", "FStar.Reflection.V2.TermEq.opt_dec_cmp", "FStar.Stubs.Reflection.Types.universe", "FStar.Reflection.V2.TermEq.list_dec_cmp", "FStar.Reflection.V2.TermEq.univ_cmp", "FStar.Reflection.V2.TermEq.univ_faithful_lemma_list", "FStar.Reflection.V2.TermEq.faithful_Pat_Cons", "Prims.l_and", "FStar.Reflection.V2.TermEq.faithful_pattern", "FStar.Reflection.V2.TermEq.pat_cmp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec faithful_lemma_pattern (p1 p2: pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) =
match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> faithful_Pat_Cons p1 head1 univs1 subpats1; faithful_Pat_Cons p2 head2 univs2 subpats2; let aux:squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> ()
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_lemma_branch
val faithful_lemma_branch (br1 br2: branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2))
val faithful_lemma_branch (br1 br2: branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2))
let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 811, "start_col": 0, "start_line": 614 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
br1: FStar.Stubs.Reflection.V2.Data.branch -> br2: FStar.Stubs.Reflection.V2.Data.branch -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.faithful_branch br1 /\ FStar.Reflection.V2.TermEq.faithful_branch br2) (ensures FStar.Reflection.V2.TermEq.defined (FStar.Reflection.V2.TermEq.br_cmp br1 br2))
FStar.Pervasives.Lemma
[ "lemma" ]
[ "faithful_lemma", "faithful_lemma_pattern", "faithful_lemma_pattern_arg", "faithful_lemma_pattern_args", "faithful_lemma_branch", "faithful_lemma_branches", "faithful_lemma_arg", "faithful_lemma_binder", "faithful_lemma_qual", "faithful_lemma_attrs_dec", "faithful_lemma_comp" ]
[ "FStar.Stubs.Reflection.V2.Data.branch", "FStar.Reflection.V2.TermEq.faithful_lemma", "FStar.Pervasives.Native.snd", "FStar.Stubs.Reflection.V2.Data.pattern", "FStar.Stubs.Reflection.Types.term", "Prims.unit", "FStar.Reflection.V2.TermEq.faithful_lemma_pattern", "FStar.Pervasives.Native.fst", "Prims.l_and", "FStar.Reflection.V2.TermEq.faithful_branch", "Prims.squash", "FStar.Reflection.V2.TermEq.defined", "FStar.Reflection.V2.TermEq.br_cmp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec faithful_lemma_branch (br1 br2: branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) =
faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2)
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_lemma_pattern_arg
val faithful_lemma_pattern_arg (pb1 pb2: pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2))
val faithful_lemma_pattern_arg (pb1 pb2: pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2))
let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 811, "start_col": 0, "start_line": 614 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pb1: (FStar.Stubs.Reflection.V2.Data.pattern * Prims.bool) -> pb2: (FStar.Stubs.Reflection.V2.Data.pattern * Prims.bool) -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.faithful_pattern_arg pb1 /\ FStar.Reflection.V2.TermEq.faithful_pattern_arg pb2) (ensures FStar.Reflection.V2.TermEq.defined (FStar.Reflection.V2.TermEq.pat_arg_cmp pb1 pb2))
FStar.Pervasives.Lemma
[ "lemma" ]
[ "faithful_lemma", "faithful_lemma_pattern", "faithful_lemma_pattern_arg", "faithful_lemma_pattern_args", "faithful_lemma_branch", "faithful_lemma_branches", "faithful_lemma_arg", "faithful_lemma_binder", "faithful_lemma_qual", "faithful_lemma_attrs_dec", "faithful_lemma_comp" ]
[ "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.V2.Data.pattern", "Prims.bool", "FStar.Reflection.V2.TermEq.faithful_lemma_pattern", "Prims.unit", "Prims.l_and", "FStar.Reflection.V2.TermEq.faithful_pattern_arg", "Prims.squash", "FStar.Reflection.V2.TermEq.defined", "FStar.Reflection.V2.TermEq.pat_arg_cmp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec faithful_lemma_pattern_arg (pb1 pb2: pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) =
let p1, _ = pb1 in let p2, _ = pb2 in faithful_lemma_pattern p1 p2
false
PulseCore.Observability.fst
PulseCore.Observability.at_most_one_observable
val at_most_one_observable : o1: PulseCore.Observability.observability -> o2: PulseCore.Observability.observability -> Prims.bool
let at_most_one_observable o1 o2 = match o1, o2 with | Observable, Observable -> false | _ -> true
{ "file_name": "lib/pulse_core/PulseCore.Observability.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 23, "start_col": 0, "start_line": 20 }
module PulseCore.Observability (* obs > unobs >----. | v ghost > neutral > ghost non_info ghost info , neutral info |> ghost info ghost non_info, neutral info |> neutral info ghost info , neutral non_info |> ghost non_info ghost non_info, neutral non_info |> ghost non_info neutral _, ghost a |> ghost a *) type observability = | Neutral | Observable | Unobservable
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "PulseCore.Observability.fst" }
[ { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
o1: PulseCore.Observability.observability -> o2: PulseCore.Observability.observability -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "PulseCore.Observability.observability", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "Prims.bool" ]
[]
false
false
false
true
false
let at_most_one_observable o1 o2 =
match o1, o2 with | Observable, Observable -> false | _ -> true
false
PulseCore.Observability.fst
PulseCore.Observability.join_obs
val join_obs : o1: PulseCore.Observability.observability -> o2: PulseCore.Observability.observability -> PulseCore.Observability.observability
let join_obs o1 o2 = match o1, o2 with | Observable, _ | _, Observable -> Observable | Neutral, n | n, Neutral -> n | _ -> Unobservable
{ "file_name": "lib/pulse_core/PulseCore.Observability.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 21, "end_line": 31, "start_col": 0, "start_line": 25 }
module PulseCore.Observability (* obs > unobs >----. | v ghost > neutral > ghost non_info ghost info , neutral info |> ghost info ghost non_info, neutral info |> neutral info ghost info , neutral non_info |> ghost non_info ghost non_info, neutral non_info |> ghost non_info neutral _, ghost a |> ghost a *) type observability = | Neutral | Observable | Unobservable let at_most_one_observable o1 o2 = match o1, o2 with | Observable, Observable -> false | _ -> true
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "PulseCore.Observability.fst" }
[ { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "PulseCore", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
o1: PulseCore.Observability.observability -> o2: PulseCore.Observability.observability -> PulseCore.Observability.observability
Prims.Tot
[ "total" ]
[]
[ "PulseCore.Observability.observability", "FStar.Pervasives.Native.Mktuple2", "PulseCore.Observability.Observable", "FStar.Pervasives.Native.tuple2", "PulseCore.Observability.Unobservable" ]
[]
false
false
false
true
false
let join_obs o1 o2 =
match o1, o2 with | Observable, _ | _, Observable -> Observable | Neutral, n | n, Neutral -> n | _ -> Unobservable
false
FStar.Reflection.V2.TermEq.fst
FStar.Reflection.V2.TermEq.faithful_lemma_branches
val faithful_lemma_branches (#b: _) (top1 top2: b) (brs1: list branch {brs1 << top1}) (brs2: list branch {brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1)
val faithful_lemma_branches (#b: _) (top1 top2: b) (brs1: list branch {brs1 << top1}) (brs2: list branch {brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1)
let rec faithful_lemma (t1 t2 : term) = match inspect_ln t1, inspect_ln t2 with | Tv_Var _, Tv_Var _ | Tv_BVar _, Tv_BVar _ | Tv_FVar _, Tv_FVar _ -> () | Tv_UInst f1 us1, Tv_UInst f2 us2 -> let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in univ_faithful_lemma_list t1 t2 us1 us2; () | Tv_Const c1, Tv_Const c2 -> () | Tv_App h1 a1, Tv_App h2 a2 -> faithful_lemma h1 h2; faithful_lemma_arg a1 a2 | Tv_Abs b1 t1, Tv_Abs b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> faithful_lemma_binder b1 b2; faithful_lemma_comp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_faithful_lemma u1 u2 | Tv_Refine b1 t1, Tv_Refine b2 t2 -> faithful_lemma_binder b1 b2; faithful_lemma t1 t2 | Tv_Let r1 ats1 x1 e1 b1, Tv_Let r2 ats2 x2 e2 b2 -> faithful_lemma_attrs_dec t1 t2 ats1 ats2; faithful_lemma_binder x1 x2; faithful_lemma e1 e2; faithful_lemma b1 b2; (***)term_eq_Tv_Let t1 t2 r1 r2 ats1 ats2 x1 x2 e1 e2 b1 b2; () | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> (***)faithful_Tv_Match t1 sc1 o1 brs1; (***)faithful_Tv_Match t2 sc2 o2 brs2; faithful_lemma sc1 sc2; faithful_lemma_branches t1 t2 brs1 brs2; (***)term_eq_Tv_Match t1 t2 sc1 sc2 o1 o2 brs1 brs2; () | Tv_AscribedT e1 t1 tacopt1 eq1, Tv_AscribedT e2 t2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma t1 t2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> faithful_lemma e1 e2; faithful_lemma_comp c1 c2; (match tacopt1, tacopt2 with | Some t1, Some t2 -> faithful_lemma t1 t2 | _ -> ()); () | Tv_Unknown, Tv_Unknown -> () | _ -> assert (defined (term_cmp t1 t2)) (* rest of the cases trivial *) and faithful_lemma_pattern (p1 p2 : pattern) : Lemma (requires faithful_pattern p1 /\ faithful_pattern p2) (ensures defined (pat_cmp p1 p2)) = match p1, p2 with | Pat_Var _ _, Pat_Var _ _ -> () | Pat_Constant _, Pat_Constant _ -> () | Pat_Dot_Term (Some t1), Pat_Dot_Term (Some t2) -> faithful_lemma t1 t2 | Pat_Cons head1 univs1 subpats1, Pat_Cons head2 univs2 subpats2 -> (***)faithful_Pat_Cons p1 head1 univs1 subpats1; (***)faithful_Pat_Cons p2 head2 univs2 subpats2; let aux : squash (defined (opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) univs1 univs2)) = match univs1, univs2 with | Some us1, Some us2 -> univ_faithful_lemma_list p1 p2 us1 us2 | _ -> () in faithful_lemma_pattern_args p1 p2 subpats1 subpats2; (***)pat_eq_Pat_Cons p1 p2 head1 head2 univs1 univs2 subpats1 subpats2; () | _ -> () and faithful_lemma_pattern_arg (pb1 pb2 : pattern & bool) : Lemma (requires faithful_pattern_arg pb1 /\ faithful_pattern_arg pb2) (ensures defined (pat_arg_cmp pb1 pb2)) = let (p1, _) = pb1 in let (p2, _) = pb2 in faithful_lemma_pattern p1 p2 and faithful_lemma_pattern_args #b (top1 top2 : b) (pats1 : list (pattern & bool){pats1 << top1}) (pats2 : list (pattern & bool){pats2 << top2}) : Lemma (requires allP top1 faithful_pattern_arg pats1 /\ allP top2 faithful_pattern_arg pats2) (ensures defined (list_dec_cmp top1 top2 pat_arg_cmp pats1 pats2)) (decreases pats1) = introduce forall x y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce forall y. L.memP x pats1 /\ L.memP y pats2 ==> defined (pat_arg_cmp x y) with (introduce (L.memP x pats1 /\ L.memP y pats2) ==> (defined (pat_arg_cmp x y)) with h. ( faithful_lemma_pattern_arg x y ) ) ) ; defined_list_dec top1 top2 pat_arg_cmp pats1 pats2 and faithful_lemma_branch (br1 br2 : branch) : Lemma (requires faithful_branch br1 /\ faithful_branch br2) (ensures defined (br_cmp br1 br2)) = faithful_lemma_pattern (fst br1) (fst br2); faithful_lemma (snd br1) (snd br2) and faithful_lemma_branches #b (top1 top2 : b) (brs1 : list branch{brs1 << top1}) (brs2 : list branch{brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) = introduce forall x y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y. L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. ( faithful_lemma_branch x y ) ) ) ; defined_list_dec top1 top2 br_cmp brs1 brs2 and faithful_lemma_arg (a1 a2 : argv) : Lemma (requires faithful_arg a1 /\ faithful_arg a2) (ensures defined (arg_cmp a1 a2)) = faithful_lemma (fst a1) (fst a2); (match snd a1, snd a2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> ()) and faithful_lemma_binder (b1 b2 : binder) : Lemma (requires faithful_binder b1 /\ faithful_binder b2) (ensures defined (binder_cmp b1 b2)) = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in faithful_lemma_qual bv1.qual bv2.qual; faithful_lemma bv1.sort bv2.sort; faithful_lemma_attrs_dec b1 b2 bv1.attrs bv2.attrs; assert_norm ( (term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs) == binder_cmp b1 b2); () and faithful_lemma_qual (q1 q2 : aqualv) : Lemma (requires faithful_qual q1 /\ faithful_qual q2) (ensures defined (aqual_cmp q1 q2)) = match q1, q2 with | Q_Meta t1, Q_Meta t2 -> faithful_lemma t1 t2 | _ -> () and faithful_lemma_attrs_dec #b (top1 top2 : b) (at1 : list term{at1 << top1}) (at2 : list term{at2 << top2}) : Lemma (requires faithful_attrs at1 /\ faithful_attrs at2) (ensures defined (list_dec_cmp top1 top2 term_cmp at1 at2)) (decreases at1) = // TODO: factor out introduce forall x y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x at1 /\ L.memP y at2 ==> defined (term_cmp x y) with (introduce (L.memP x at1 /\ L.memP y at2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec top1 top2 term_cmp at1 at2 and faithful_lemma_comp (c1 c2 : comp) : Lemma (requires faithful_comp c1 /\ faithful_comp c2) (ensures defined (comp_cmp c1 c2)) = match inspect_comp c1, inspect_comp c2 with | C_Total t1, C_Total t2 -> faithful_lemma t1 t2 | C_GTotal t1, C_GTotal t2 -> faithful_lemma t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> faithful_lemma pre1 pre2; faithful_lemma post1 post2; faithful_lemma pat1 pat2 | C_Eff us1 e1 r1 args1 dec1, C_Eff us2 e2 r2 args2 dec2 -> univ_faithful_lemma_list c1 c2 us1 us2; faithful_lemma r1 r2; introduce forall x y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce forall y. L.memP x args1 /\ L.memP y args2 ==> defined (arg_cmp x y) with (introduce (L.memP x args1 /\ L.memP y args2) ==> (defined (arg_cmp x y)) with h. ( faithful_lemma_arg x y ) ) ) ; defined_list_dec c1 c2 arg_cmp args1 args2; introduce forall x y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce forall y. L.memP x dec1 /\ L.memP y dec2 ==> defined (term_cmp x y) with (introduce (L.memP x dec1 /\ L.memP y dec2) ==> (defined (term_cmp x y)) with h. ( faithful_lemma x y ) ) ) ; defined_list_dec c1 c2 term_cmp dec1 dec2; (***)comp_eq_C_Eff c1 c2 us1 us2 e1 e2 r1 r2 args1 args2 dec1 dec2; () | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.TermEq.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 811, "start_col": 0, "start_line": 614 }
module FStar.Reflection.V2.TermEq open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Data open FStar.Stubs.Reflection.V2.Builtins module L = FStar.List.Tot (* "SMT may not be able to prove the types of ... and ... to be equal, if the proof fails, try annotating these with the same type" *) #set-options "--warn_error -290" (* This file raised several limitations of the SMT encoding. Lines marked with #2908 are seemingly consequences of issue #2908 and should be removed. In fact many auxiliary lemmas should be removed as they should become obvious. Lines marked with *** should not be needed. *) let rec allP0 #a (pred : a -> Type0) (l : list a) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP0 pred xs let rec allP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (l : list a{l << top \/ l === top}) : Type0 = match l with | [] -> True | x::xs -> pred x /\ allP top pred xs let optP0 #a (pred : a -> Type0) (o : option a) : Type0 = match o with | None -> True | Some x -> pred x let optP #a #b (top:b) (pred : (x:a{x << top}) -> Type0) (o : option a{o << top}) : Type0 = match o with | None -> True | Some x -> pred x let rec memP_allP #a #b (top:b) (pred : (x:a{x << top}) -> Type) (x : a) (l : list a{l << top}) : Lemma (requires allP top pred l /\ L.memP x l) (ensures x << top /\ pred x) [SMTPat (allP top pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP top pred x ys let rec memP_allP0 #a (pred : a -> Type) (x : a) (l : list a) : Lemma (requires allP0 pred l /\ L.memP x l) (ensures pred x) [SMTPat (allP0 pred l); SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_allP0 pred x ys let rec memP_dec #a (x : a) (l : list a) : Lemma (requires L.memP x l) (ensures x << l) [SMTPat (L.memP x l)] = match l with | [] -> () | y::ys -> if StrongExcludedMiddle.strong_excluded_middle (x == y) then () else memP_dec x ys (* FIXME: the only reason these are not exposed is to not contaminate the namespace for most users, especially as `Eq` is already used in Reflection.Formula. But there should not be a problem with using this name fully-qualified. *) private type _cmpres = | Eq | Neq | Unknown // Would it be easier for the proofs to be embedded in the _cmpres? let valid #t (c:_cmpres) (x y : t) = match c with | Eq -> x == y | Neq -> x =!= y | Unknown -> True type cmpres #t (x y : t) = c:_cmpres{valid c x y} type comparator_for (t:Type) = x:t -> y:t -> cmpres x y let (&&&) (#s : Type u#ss) (#t : Type u#tt) (#x #y : s) (#w #z : t) ($c1 : cmpres x y) ($c2 : cmpres w z) : cmpres (x,w) (y,z) = match c1, c2 with | Eq, Eq -> Eq | Neq, _ | _, Neq -> Neq | _ -> Unknown val bv_cmp : comparator_for bv let bv_cmp x1 x2 = let v1 = inspect_bv x1 in let v2 = inspect_bv x2 in pack_inspect_bv x1; pack_inspect_bv x2; sealed_singl v1.sort v2.sort; if v1.index = v2.index then Eq else Neq val namedv_cmp : comparator_for namedv let namedv_cmp x1 x2 = let v1 = inspect_namedv x1 in let v2 = inspect_namedv x2 in pack_inspect_namedv x1; pack_inspect_namedv x2; sealed_singl v1.sort v2.sort; if v1.uniq = v2.uniq then Eq else Neq val fv_cmp : comparator_for fv let fv_cmp f1 f2 = pack_inspect_fv f1; pack_inspect_fv f2; let n1 = inspect_fv f1 in let n2 = inspect_fv f2 in if n1 = n2 then Eq else Neq val opt_cmp : #a:Type -> comparator_for a -> comparator_for (option a) let opt_cmp cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (either a b) let either_cmp cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val pair_cmp : #a:Type -> #b:Type -> comparator_for a -> comparator_for b -> comparator_for (a & b) let pair_cmp cmpa cmpb (a1, b1) (a2, b2) = cmpa a1 a2 &&& cmpb b1 b2 val list_cmp : #a:Type u#aa -> comparator_for a -> comparator_for (list a) let rec list_cmp #a cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_cmp cmp xs ys | _ -> Neq val list_dec_cmp : #a:Type u#aa -> #b:Type u#bb -> top1:b -> top2:b -> f:(x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y) -> l1:(list a) -> l2:(list a){l1 << top1 /\ l2 << top2} -> cmpres l1 l2 let rec list_dec_cmp #a top1 top2 cmp l1 l2 = match l1, l2 with | [], [] -> Eq | x::xs, y::ys -> cmp x y &&& list_dec_cmp top1 top2 cmp xs ys | _ -> Neq val opt_dec_cmp : #a:Type -> #b:Type -> top1:b -> top2:b -> (f : (x:a -> y:a{x << top1 /\ y << top2} -> cmpres x y)) -> o1:(option a){o1 << top1} -> o2:(option a){o2 << top2} -> cmpres o1 o2 let opt_dec_cmp top1 top2 cmp o1 o2 = match o1, o2 with | None, None -> Eq | Some x, Some y -> cmp x y | _ -> Neq val either_dec_cmp : #a:Type -> #b:Type -> #c:Type -> top1:c -> top2:c -> (x:a -> y:a{x<<top1 /\ y<<top2} -> cmpres x y) -> (x:b -> y:b{x<<top1 /\ y<<top2} -> cmpres x y) -> e1 :(either a b){e1 << top1} -> e2 :(either a b){e2 << top2} -> cmpres e1 e2 let either_dec_cmp top1 top2 cmpa cmpb e1 e2 = match e1, e2 with | Inl x, Inl y -> cmpa x y | Inr x, Inr y -> cmpb x y | _ -> Neq val eq_cmp : #a:eqtype -> comparator_for a let eq_cmp x y = if x = y then Eq else Neq val range_cmp : comparator_for range let range_cmp r1 r2 = Sealed.sealed_singl r1 r2; Eq val ident_cmp : comparator_for ident let ident_cmp i1 i2 = let iv1 = inspect_ident i1 in let iv2 = inspect_ident i2 in pack_inspect_ident i1; pack_inspect_ident i2; Sealed.sealed_singl (snd iv1) (snd iv2); eq_cmp (fst iv1) (fst iv2) val univ_cmp : comparator_for universe let rec univ_cmp (u1 u2 : universe) = pack_inspect_universe u1; pack_inspect_universe u2; let uv1 = inspect_universe u1 in let uv2 = inspect_universe u2 in match uv1, uv2 with | Uv_Zero, Uv_Zero -> Eq | Uv_Succ u1, Uv_Succ u2 -> univ_cmp u1 u2 | Uv_Max us1, Uv_Max us2 -> list_dec_cmp u1 u2 univ_cmp us1 us2 | Uv_BVar v1, Uv_BVar v2 -> eq_cmp v1 v2 | Uv_Name n1, Uv_Name n2 -> ident_cmp n1 n2 | Uv_Unif u1, Uv_Unif u2 -> Unknown | Uv_Unk, Uv_Unk -> Eq | _ -> Neq val const_cmp : comparator_for vconst let const_cmp c1 c2 = match c1, c2 with | C_Unit, C_Unit -> Eq | C_Int i1, C_Int i2 -> eq_cmp i1 i2 | C_True, C_True -> Eq | C_False, C_False -> Eq | C_String s1, C_String s2 -> eq_cmp s1 s2 | C_Range r1, C_Range r2 -> range_cmp r1 r2 | C_Reify, C_Reify -> Eq | C_Reflect n1, C_Reflect n2 -> eq_cmp n1 n2 | _ -> Neq (* TODO. Or seal...? *) val ctxu_cmp : comparator_for ctx_uvar_and_subst let ctxu_cmp _ _ = Unknown val term_cmp : comparator_for term val binder_cmp : comparator_for binder val aqual_cmp : comparator_for aqualv val arg_cmp : comparator_for argv val comp_cmp : comparator_for comp val pat_cmp : comparator_for pattern val pat_arg_cmp : comparator_for (pattern & bool) val br_cmp : comparator_for branch val match_returns_ascription_cmp : comparator_for match_returns_ascription let rec term_cmp t1 t2 = pack_inspect_inv t1; pack_inspect_inv t2; let tv1 = inspect_ln t1 in let tv2 = inspect_ln t2 in match tv1, tv2 with | Tv_Unsupp, _ | _, Tv_Unsupp -> Unknown | Tv_Var v1, Tv_Var v2 -> namedv_cmp v1 v2 | Tv_BVar v1, Tv_BVar v2 -> bv_cmp v1 v2 | Tv_FVar f1, Tv_FVar f2 -> fv_cmp f1 f2 | Tv_UInst f1 u1, Tv_UInst f2 u2 -> fv_cmp f1 f2 &&& list_dec_cmp t1 t2 univ_cmp u1 u2 | Tv_App h1 a1, Tv_App h2 a2 -> term_cmp h1 h2 &&& arg_cmp a1 a2 | Tv_Abs b1 e1, Tv_Abs b2 e2 -> binder_cmp b1 b2 &&& term_cmp e1 e2 | Tv_Arrow b1 c1, Tv_Arrow b2 c2 -> binder_cmp b1 b2 &&& comp_cmp c1 c2 | Tv_Type u1, Tv_Type u2 -> univ_cmp u1 u2 | Tv_Refine sb1 r1, Tv_Refine sb2 r2 -> binder_cmp sb1 sb2 &&& term_cmp r1 r2 | Tv_Const c1, Tv_Const c2 -> const_cmp c1 c2 | Tv_Uvar n1 u1, Tv_Uvar n2 u2 -> eq_cmp n1 n2 &&& ctxu_cmp u1 u2 | Tv_Let r1 attrs1 sb1 e1 b1, Tv_Let r2 attrs2 sb2 e2 b2 -> eq_cmp r1 r2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp sb1 sb2 &&& term_cmp e1 e2 &&& term_cmp b1 b2 | Tv_Match sc1 o1 brs1, Tv_Match sc2 o2 brs2 -> term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2 | Tv_AscribedT e1 ta1 tacopt1 eq1, Tv_AscribedT e2 ta2 tacopt2 eq2 -> term_cmp e1 e2 &&& term_cmp ta1 ta2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_AscribedC e1 c1 tacopt1 eq1, Tv_AscribedC e2 c2 tacopt2 eq2 -> term_cmp e1 e2 &&& comp_cmp c1 c2 &&& opt_dec_cmp t1 t2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 | Tv_Unknown, Tv_Unknown -> Eq | _ -> Neq and arg_cmp (a1, q1) (a2, q2) = term_cmp a1 a2 &&& aqual_cmp q1 q2 and aqual_cmp a1 a2 = match a1, a2 with | Q_Implicit, Q_Implicit -> Eq | Q_Explicit, Q_Explicit -> Eq | Q_Meta m1, Q_Meta m2 -> term_cmp m1 m2 | _ -> Neq and match_returns_ascription_cmp asc1 asc2 = let (b1, (tc1, tacopt1, eq1)) = asc1 in let (b2, (tc2, tacopt2, eq2)) = asc2 in binder_cmp b1 b2 &&& either_dec_cmp asc1 asc2 term_cmp comp_cmp tc1 tc2 &&& opt_dec_cmp asc1 asc2 term_cmp tacopt1 tacopt2 &&& eq_cmp eq1 eq2 and binder_cmp b1 b2 = let bv1 = inspect_binder b1 in let bv2 = inspect_binder b2 in pack_inspect_binder b1; pack_inspect_binder b2; term_cmp bv1.sort bv2.sort &&& aqual_cmp bv1.qual bv2.qual &&& list_dec_cmp b1 b2 term_cmp bv1.attrs bv2.attrs and comp_cmp c1 c2 = let cv1 = inspect_comp c1 in let cv2 = inspect_comp c2 in pack_inspect_comp_inv c1; pack_inspect_comp_inv c2; match cv1, cv2 with | C_Total t1, C_Total t2 | C_GTotal t1, C_GTotal t2 -> term_cmp t1 t2 | C_Lemma pre1 post1 pat1, C_Lemma pre2 post2 pat2 -> term_cmp pre1 pre2 &&& term_cmp post1 post2 &&& term_cmp pat1 pat2 | C_Eff us1 ef1 t1 args1 dec1, C_Eff us2 ef2 t2 args2 dec2 -> list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2 | _ -> Neq and br_cmp br1 br2 = //pair_cmp pat_cmp term_cmp br1 br2 pat_cmp (fst br1) (fst br2) &&& term_cmp (snd br1) (snd br2) and pat_cmp p1 p2 = match p1, p2 with | Pat_Var x1 s1, Pat_Var x2 s2 -> sealed_singl x1 x2; sealed_singl s1 s2; Eq | Pat_Constant x1, Pat_Constant x2 -> const_cmp x1 x2 | Pat_Dot_Term x1, Pat_Dot_Term x2 -> opt_dec_cmp p1 p2 term_cmp x1 x2 | Pat_Cons head1 us1 subpats1, Pat_Cons head2 us2 subpats2 -> fv_cmp head1 head2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) us1 us2 &&& list_dec_cmp p1 p2 pat_arg_cmp subpats1 subpats2 | _ -> Neq and pat_arg_cmp (p1, b1) (p2, b2) = pat_cmp p1 p2 &&& eq_cmp b1 b2 let defined r = ~(Unknown? r) let def2 f l1 l2 =(forall x y. L.memP x l1 /\ L.memP y l2 ==> defined (f x y)) let rec defined_list #a (f : comparator_for a) (l1 l2 : list a) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_cmp f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list f xs ys | _ -> () let rec defined_list_dec #a #b (t1 t2 : b) (f : comparator_for a) (l1 : list a{l1 << t1}) (l2 : list a{l2 << t2}) : Lemma (requires (def2 f l1 l2)) (ensures defined (list_dec_cmp t1 t2 f l1 l2)) = match l1, l2 with | [], [] -> () | x::xs, y::ys -> defined_list_dec t1 t2 f xs ys | _ -> () val faithful_univ : universe -> Type0 let rec faithful_univ (u : universe) = match inspect_universe u with | Uv_Unif _ -> False (* We just forbid this *) | Uv_Unk | Uv_Zero | Uv_BVar _ | Uv_Name _ -> True | Uv_Succ u -> faithful_univ u | Uv_Max us -> allP u faithful_univ us let faithful_univ_UvMax (u : universe) (us : list universe) : Lemma (requires inspect_universe u == Uv_Max us /\ faithful_univ u) (ensures allP u faithful_univ us) = assert_norm (faithful_univ u <==> allP u faithful_univ us) // #2908 let univ_eq_UvMax (u1 u2 : universe) (us1 us2 : list universe) : Lemma (requires inspect_universe u1 == Uv_Max us1 /\ inspect_universe u2 == Uv_Max us2) (ensures univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) = assert_norm (univ_cmp u1 u2 == list_dec_cmp u1 u2 univ_cmp us1 us2) // #2908 val univ_faithful_lemma (u1 u2 : universe) : Lemma (requires faithful_univ u1 /\ faithful_univ u2) (ensures defined (univ_cmp u1 u2)) let rec univ_faithful_lemma (u1 u2 : universe) = match inspect_universe u1, inspect_universe u2 with | Uv_Zero, Uv_Zero -> () | Uv_Succ u1, Uv_Succ u2 -> univ_faithful_lemma u1 u2 | Uv_Max us1, Uv_Max us2 -> (****)faithful_univ_UvMax u1 us1; (***)faithful_univ_UvMax u2 us2; univ_faithful_lemma_list u1 u2 us1 us2; (***)univ_eq_UvMax u1 u2 us1 us2; () | Uv_BVar _, Uv_BVar _ -> () | Uv_Name _, Uv_Name _ -> () | _ -> () and univ_faithful_lemma_list #b (u1 u2 : b) (us1 : list universe{us1 << u1}) (us2 : list universe{us2 << u2}) : Lemma (requires allP u1 faithful_univ us1 /\ allP u2 faithful_univ us2) (ensures defined (list_dec_cmp u1 u2 univ_cmp us1 us2)) (decreases us1) = introduce forall x y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce forall y. L.memP x us1 /\ L.memP y us2 ==> defined (univ_cmp x y) with (introduce (L.memP x us1 /\ L.memP y us2) ==> (defined (univ_cmp x y)) with h. ( univ_faithful_lemma x y ) ) ) ; defined_list_dec u1 u2 univ_cmp us1 us2 val faithful : term -> Type0 let rec faithful t = match inspect_ln t with | Tv_Var _ | Tv_BVar _ | Tv_FVar _ | Tv_Unknown | Tv_Const _ -> True | Tv_UInst f us -> allP t faithful_univ us | Tv_Unsupp -> False | Tv_App h a -> faithful h /\ faithful_arg a | Tv_Abs b t -> faithful_binder b /\ faithful t | Tv_Arrow b c -> faithful_binder b /\ faithful_comp c | Tv_Type u -> faithful_univ u | Tv_Refine b phi -> faithful_binder b /\ faithful phi | Tv_Uvar n u -> False | Tv_Let r ats x e b -> faithful_attrs ats /\ faithful_binder x /\ faithful e /\ faithful b | Tv_Match sc o brs -> faithful sc /\ None? o // stopgap /\ allP t faithful_branch brs | Tv_AscribedT e ta tacopt eq -> faithful e /\ faithful ta /\ optP t faithful tacopt | Tv_AscribedC e c tacopt eq -> faithful e /\ faithful_comp c /\ optP t faithful tacopt and faithful_arg (a : argv) : Type0 = faithful (fst a) /\ faithful_qual (snd a) and faithful_qual (q:aqualv) : Type0 = match q with | Q_Implicit -> True | Q_Explicit -> True | Q_Meta m -> faithful m and faithful_binder (b:binder) : Type0 = match inspect_binder b with | {sort=sort; qual=q; attrs=attrs} -> faithful sort /\ faithful_qual q /\ faithful_attrs attrs and faithful_branch (b : branch) : Type0 = let (p, t) = b in faithful_pattern p /\ faithful t and faithful_pattern (p : pattern) : Type0 = match p with | Pat_Constant _ -> True | Pat_Cons head univs subpats -> optP p (allP p faithful_univ) univs /\ allP p faithful_pattern_arg subpats (* non-binding bvs are always OK *) | Pat_Var _ _ -> True | Pat_Dot_Term None -> True | Pat_Dot_Term (Some t) -> faithful t and faithful_pattern_arg (pb : pattern * bool) : Type0 = faithful_pattern (fst pb) and faithful_attrs ats : Type0 = allP ats faithful ats and faithful_comp c = match inspect_comp c with | C_Total t -> faithful t | C_GTotal t -> faithful t | C_Lemma pre post pats -> faithful pre /\ faithful post /\ faithful pats | C_Eff us ef r args decs -> allP c faithful_univ us /\ faithful r /\ allP c faithful_arg args /\ allP c faithful decs val faithful_lemma (t1:term) (t2:term) : Lemma (requires faithful t1 /\ faithful t2) (ensures defined (term_cmp t1 t2)) #push-options "--z3rlimit 40" let faithful_Tv_UInst (t : term) (f : fv) (us : list universe) : Lemma (requires inspect_ln t == Tv_UInst f us /\ faithful t) (ensures allP t faithful_univ us) = () let faithful_Tv_Let (t : term) (recf : bool) (attrs : list term) (b:simple_binder) (ty:typ) (def body : term) : Lemma (requires inspect_ln t == Tv_Let recf attrs b def body /\ faithful t) (ensures faithful_attrs attrs) = () let term_eq_Tv_Let (t1 t2 : term) (recf1 recf2 : bool) (attrs1 attrs2 : list term) (b1 b2:simple_binder) (def1 def2 body1 body2: term) : Lemma (requires inspect_ln t1 == Tv_Let recf1 attrs1 b1 def1 body1 /\ inspect_ln t2 == Tv_Let recf2 attrs2 b2 def2 body2) (ensures term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) = assume (term_cmp t1 t2 == (eq_cmp recf1 recf2 &&& list_dec_cmp t1 t2 term_cmp attrs1 attrs2 &&& binder_cmp b1 b2 &&& term_cmp def1 def2 &&& term_cmp body1 body2)) // #2908, somehow assert_norm also does not work let faithful_Tv_Match (t : term) (sc : term) (o : option match_returns_ascription) (brs : list branch) : Lemma (requires inspect_ln t == Tv_Match sc o brs /\ faithful t) (ensures allP t faithful_branch brs) = assert_norm (faithful t ==> allP t faithful_branch brs) let term_eq_Tv_Match (t1 t2 : term) (sc1 sc2 : term) (o1 o2 : option match_returns_ascription) (brs1 brs2 : list branch) : Lemma (requires inspect_ln t1 == Tv_Match sc1 o1 brs1 /\ inspect_ln t2 == Tv_Match sc2 o2 brs2) (ensures term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) = assume (term_cmp t1 t2 == (term_cmp sc1 sc2 &&& opt_dec_cmp t1 t2 match_returns_ascription_cmp o1 o2 &&& list_dec_cmp t1 t2 br_cmp brs1 brs2)) // #2908, somehow assert_norm also does not work let faithful_Pat_Cons (p : pattern) (f:fv) (ous : option universes) (subpats : list (pattern & bool)) : Lemma (requires p == Pat_Cons f ous subpats /\ faithful_pattern p) (ensures allP p faithful_pattern_arg subpats) = assert_norm (faithful_pattern p ==> allP p faithful_pattern_arg subpats) // #2908 let pat_eq_Pat_Cons (p1 p2 : pattern) (f1 f2 : fv) (ous1 ous2 : option universes) (args1 args2 : list (pattern & bool)) : Lemma (requires p1 == Pat_Cons f1 ous1 args1 /\ p2 == Pat_Cons f2 ous2 args2) (ensures pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) = assert_norm (pat_cmp p1 p2 == (fv_cmp f1 f2 &&& opt_dec_cmp p1 p2 (list_dec_cmp p1 p2 univ_cmp) ous1 ous2 &&& list_dec_cmp p1 p2 pat_arg_cmp args1 args2)) let comp_eq_C_Eff (c1 c2 : comp) (us1 us2 : universes) (ef1 ef2 : name) (t1 t2 : typ) (args1 args2 : list argv) (dec1 dec2 : list term) : Lemma (requires inspect_comp c1 == C_Eff us1 ef1 t1 args1 dec1 /\ inspect_comp c2 == C_Eff us2 ef2 t2 args2 dec2) (ensures comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) = assume (comp_cmp c1 c2 == (list_dec_cmp c1 c2 univ_cmp us1 us2 &&& eq_cmp ef1 ef2 &&& term_cmp t1 t2 &&& list_dec_cmp c1 c2 arg_cmp args1 args2 &&& list_dec_cmp c1 c2 term_cmp dec1 dec2)) // #2908, assert_norm doesn't work
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Sealed.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.TermEq.fst" }
[ { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
top1: b -> top2: b -> brs1: Prims.list FStar.Stubs.Reflection.V2.Data.branch {brs1 << top1} -> brs2: Prims.list FStar.Stubs.Reflection.V2.Data.branch {brs2 << top2} -> FStar.Pervasives.Lemma (requires FStar.Reflection.V2.TermEq.allP top1 FStar.Reflection.V2.TermEq.faithful_branch brs1 /\ FStar.Reflection.V2.TermEq.allP top2 FStar.Reflection.V2.TermEq.faithful_branch brs2) (ensures FStar.Reflection.V2.TermEq.defined (FStar.Reflection.V2.TermEq.list_dec_cmp top1 top2 FStar.Reflection.V2.TermEq.br_cmp brs1 brs2)) (decreases brs1)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[ "faithful_lemma", "faithful_lemma_pattern", "faithful_lemma_pattern_arg", "faithful_lemma_pattern_args", "faithful_lemma_branch", "faithful_lemma_branches", "faithful_lemma_arg", "faithful_lemma_binder", "faithful_lemma_qual", "faithful_lemma_attrs_dec", "faithful_lemma_comp" ]
[ "Prims.list", "FStar.Stubs.Reflection.V2.Data.branch", "Prims.precedes", "FStar.Reflection.V2.TermEq.defined_list_dec", "FStar.Reflection.V2.TermEq.br_cmp", "Prims.unit", "FStar.Classical.Sugar.forall_intro", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "FStar.List.Tot.Base.memP", "FStar.Reflection.V2.TermEq.defined", "FStar.Classical.Sugar.implies_intro", "Prims.squash", "FStar.Reflection.V2.TermEq.faithful_lemma_branch", "FStar.Reflection.V2.TermEq.allP", "FStar.Reflection.V2.TermEq.faithful_branch", "FStar.Reflection.V2.TermEq.list_dec_cmp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec faithful_lemma_branches #b (top1: b) (top2: b) (brs1: list branch {brs1 << top1}) (brs2: list branch {brs2 << top2}) : Lemma (requires allP top1 faithful_branch brs1 /\ allP top2 faithful_branch brs2) (ensures defined (list_dec_cmp top1 top2 br_cmp brs1 brs2)) (decreases brs1) =
introduce forall x y . L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce forall y . L.memP x brs1 /\ L.memP y brs2 ==> defined (br_cmp x y) with (introduce (L.memP x brs1 /\ L.memP y brs2) ==> (defined (br_cmp x y)) with h. (faithful_lemma_branch x y))); defined_list_dec top1 top2 br_cmp brs1 brs2
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.___UINT64BE
val ___UINT64BE:eqtype
val ___UINT64BE:eqtype
let ___UINT64BE : eqtype = U64.t
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 32, "end_line": 214, "start_col": 0, "start_line": 214 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t" ]
[]
false
false
false
true
false
let ___UINT64BE:eqtype =
U64.t
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.___Bool
val ___Bool : Prims.eqtype
let ___Bool = bool
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 189, "start_col": 0, "start_line": 189 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types ////////////////////////////////////////////////////////////////////////////////
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "Prims.bool" ]
[]
false
false
false
true
false
let ___Bool =
bool
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.refine
val refine : t: Type -> f: (_: t -> Prims.bool) -> Type
let refine t (f:t -> bool) = x:t{f x}
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 37, "end_line": 76, "start_col": 0, "start_line": 76 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Type -> f: (_: t -> Prims.bool) -> Type
Prims.Tot
[ "total" ]
[]
[ "Prims.bool", "Prims.b2t" ]
[]
false
false
false
true
true
let refine t (f: (t -> bool)) =
x: t{f x}
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.___UINT16BE
val ___UINT16BE:eqtype
val ___UINT16BE:eqtype
let ___UINT16BE : eqtype = U16.t
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 32, "end_line": 204, "start_col": 0, "start_line": 204 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt16.t" ]
[]
false
false
false
true
false
let ___UINT16BE:eqtype =
U16.t
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.___UINT8BE
val ___UINT8BE:eqtype
val ___UINT8BE:eqtype
let ___UINT8BE : eqtype = FStar.UInt8.t
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 39, "end_line": 199, "start_col": 0, "start_line": 199 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order")
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt8.t" ]
[]
false
false
false
true
false
let ___UINT8BE:eqtype =
FStar.UInt8.t
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.___UINT8
val ___UINT8:eqtype
val ___UINT8:eqtype
let ___UINT8 : eqtype = FStar.UInt8.t
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 37, "end_line": 192, "start_col": 0, "start_line": 192 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt8.t" ]
[]
false
false
false
true
false
let ___UINT8:eqtype =
FStar.UInt8.t
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.___UINT16
val ___UINT16:eqtype
val ___UINT16:eqtype
let ___UINT16 : eqtype = U16.t
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 30, "end_line": 221, "start_col": 0, "start_line": 221 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt16.t" ]
[]
false
false
false
true
false
let ___UINT16:eqtype =
U16.t
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.___UINT32
val ___UINT32:eqtype
val ___UINT32:eqtype
let ___UINT32 : eqtype = U32.t
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 30, "end_line": 226, "start_col": 0, "start_line": 226 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t" ]
[]
false
false
false
true
false
let ___UINT32:eqtype =
U32.t
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.___UINT32BE
val ___UINT32BE:eqtype
val ___UINT32BE:eqtype
let ___UINT32BE : eqtype = U32.t
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 32, "end_line": 209, "start_col": 0, "start_line": 209 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t" ]
[]
false
false
false
true
false
let ___UINT32BE:eqtype =
U32.t
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.parse_unit
val parse_unit:parser kind_unit unit
val parse_unit:parser kind_unit unit
let parse_unit : parser kind_unit unit = parse_ret ()
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 16, "end_line": 237, "start_col": 0, "start_line": 235 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
EverParse3d.Prelude.parser EverParse3d.Kinds.kind_unit Prims.unit
Prims.Tot
[ "total" ]
[]
[ "EverParse3d.Prelude.parse_ret", "Prims.unit" ]
[]
false
false
false
false
false
let parse_unit:parser kind_unit unit =
parse_ret ()
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.___UINT64
val ___UINT64:eqtype
val ___UINT64:eqtype
let ___UINT64 : eqtype = U64.t
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 30, "end_line": 231, "start_col": 0, "start_line": 231 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t" ]
[]
false
false
false
true
false
let ___UINT64:eqtype =
U64.t
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.pow2_values
val pow2_values (x: nat) : Lemma (let p = pow2 x in match x with | 0 -> p = 1 | 1 -> p = 2 | 2 -> p = 4 | 3 -> p = 8 | 4 -> p = 16 | 5 -> p = 32 | 6 -> p = 64 | 7 -> p = 128 | 8 -> p = 256 | _ -> True) [SMTPat (pow2 x)]
val pow2_values (x: nat) : Lemma (let p = pow2 x in match x with | 0 -> p = 1 | 1 -> p = 2 | 2 -> p = 4 | 3 -> p = 8 | 4 -> p = 16 | 5 -> p = 32 | 6 -> p = 64 | 7 -> p = 128 | 8 -> p = 256 | _ -> True) [SMTPat (pow2 x)]
let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8)
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 43, "end_line": 48, "start_col": 0, "start_line": 26 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.nat -> FStar.Pervasives.Lemma (ensures (let p = Prims.pow2 x in (match x with | 0 -> p = 1 | 1 -> p = 2 | 2 -> p = 4 | 3 -> p = 8 | 4 -> p = 16 | 5 -> p = 32 | 6 -> p = 64 | 7 -> p = 128 | 8 -> p = 256 | _ -> Prims.l_True) <: Type0)) [SMTPat (Prims.pow2 x)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "FStar.Pervasives.norm_spec", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "Prims.Nil", "Prims.pos", "Prims.pow2", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat" ]
[]
true
false
true
false
false
let pow2_values (x: nat) : Lemma (let p = pow2 x in match x with | 0 -> p = 1 | 1 -> p = 2 | 2 -> p = 4 | 3 -> p = 8 | 4 -> p = 16 | 5 -> p = 32 | 6 -> p = 64 | 7 -> p = 128 | 8 -> p = 256 | _ -> True) [SMTPat (pow2 x)] =
norm_spec [delta; zeta; primops] (pow2 0); norm_spec [delta; zeta; primops] (pow2 1); norm_spec [delta; zeta; primops] (pow2 2); norm_spec [delta; zeta; primops] (pow2 3); norm_spec [delta; zeta; primops] (pow2 4); norm_spec [delta; zeta; primops] (pow2 5); norm_spec [delta; zeta; primops] (pow2 6); norm_spec [delta; zeta; primops] (pow2 7); norm_spec [delta; zeta; primops] (pow2 8)
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u8_div
val u8_div (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
val u8_div (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y)
let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 17, "end_line": 287, "start_col": 0, "start_line": 283 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt8.t", "FStar.UInt8.div", "FStar.Range.labeled", "Prims.l_not", "Prims.eq2", "Prims.int", "FStar.UInt8.v", "Prims.op_Division" ]
[]
false
false
false
false
false
let u8_div (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) =
UInt8.div x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.max_int_sizes
val max_int_sizes:squash FStar.UInt.(max_int 10 == 1023 /\ max_int 8 == 255)
val max_int_sizes:squash FStar.UInt.(max_int 10 == 1023 /\ max_int 8 == 255)
let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10)
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 36, "end_line": 253, "start_col": 0, "start_line": 247 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields ////////////////////////////////////////////////////////////////////////////////
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.squash (FStar.UInt.max_int 10 == 1023 /\ FStar.UInt.max_int 8 == 255)
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.normalize_term_spec", "Prims.int", "FStar.UInt.max_int" ]
[]
false
false
true
false
false
let max_int_sizes:squash FStar.UInt.(max_int 10 == 1023 /\ max_int 8 == 255) =
let open FStar.UInt in normalize_term_spec (max_int 10)
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u8_add
val u8_add (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
val u8_add (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y)
let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 17, "end_line": 266, "start_col": 0, "start_line": 262 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt8.t", "FStar.UInt8.add", "FStar.Range.labeled", "FStar.UInt.size", "Prims.op_Addition", "FStar.UInt8.v", "FStar.UInt8.n", "Prims.eq2", "Prims.int" ]
[]
false
false
false
false
false
let u8_add (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) =
UInt8.add x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u8_mul
val u8_mul (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size ((UInt8.v x) `Prims.op_Multiply` (UInt8.v y)) UInt8.n)) (ensures fun z -> UInt8.v z == (UInt8.v x) `Prims.op_Multiply` (UInt8.v y))
val u8_mul (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size ((UInt8.v x) `Prims.op_Multiply` (UInt8.v y)) UInt8.n)) (ensures fun z -> UInt8.v z == (UInt8.v x) `Prims.op_Multiply` (UInt8.v y))
let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 17, "end_line": 280, "start_col": 0, "start_line": 276 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt8.t", "FStar.UInt8.mul", "FStar.Range.labeled", "FStar.UInt.size", "Prims.op_Multiply", "FStar.UInt8.v", "FStar.UInt8.n", "Prims.eq2", "Prims.int" ]
[]
false
false
false
false
false
let u8_mul (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size ((UInt8.v x) `Prims.op_Multiply` (UInt8.v y)) UInt8.n)) (ensures fun z -> UInt8.v z == (UInt8.v x) `Prims.op_Multiply` (UInt8.v y)) =
UInt8.mul x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u8_logand
val u8_logand (r: range) (x y: UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> (UInt8.v x) `UInt.logand` (UInt8.v y) == UInt8.v z))
val u8_logand (r: range) (x y: UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> (UInt8.v x) `UInt.logand` (UInt8.v y) == UInt8.v z))
let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 20, "end_line": 303, "start_col": 0, "start_line": 299 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt8.t", "FStar.UInt8.logand", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt8.n", "FStar.UInt.logand", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let u8_logand (r: range) (x y: UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> (UInt8.v x) `UInt.logand` (UInt8.v y) == UInt8.v z)) =
UInt8.logand x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u8_logor
val u8_logor (r: range) (x y: UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> (UInt8.v x) `UInt.logor` (UInt8.v y) == UInt8.v z))
val u8_logor (r: range) (x y: UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> (UInt8.v x) `UInt.logor` (UInt8.v y) == UInt8.v z))
let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 19, "end_line": 319, "start_col": 0, "start_line": 315 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt8.t", "FStar.UInt8.logor", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt8.n", "FStar.UInt.logor", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let u8_logor (r: range) (x y: UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> (UInt8.v x) `UInt.logor` (UInt8.v y) == UInt8.v z)) =
UInt8.logor x y
false
Hacl.Impl.K256.PointMul.fst
Hacl.Impl.K256.PointMul.point_mul_g
val point_mul_g: out:point -> scalar:qelem -> Stack unit (requires fun h -> live h scalar /\ live h out /\ disjoint out scalar /\ qas_nat h scalar < S.q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_g (qas_nat h0 scalar)))
val point_mul_g: out:point -> scalar:qelem -> Stack unit (requires fun h -> live h scalar /\ live h out /\ disjoint out scalar /\ qas_nat h scalar < S.q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ S.to_aff_point (point_eval h1 out) == S.to_aff_point (S.point_mul_g (qas_nat h0 scalar)))
let point_mul_g out scalar = push_frame (); let h0 = ST.get () in let q1 = create 15ul (u64 0) in make_g q1; let q2 = mk_proj_g_pow2_64 () in let q3 = mk_proj_g_pow2_128 () in let q4 = mk_proj_g_pow2_192 () in proj_g_pow2_64_lseq_lemma (); proj_g_pow2_128_lseq_lemma (); proj_g_pow2_192_lseq_lemma (); point_mul_g_noalloc out scalar q1 q2 q3 q4; lemma_exp_four_fw_local (as_seq h0 scalar); pop_frame ()
{ "file_name": "code/k256/Hacl.Impl.K256.PointMul.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 176, "start_col": 0, "start_line": 163 }
module Hacl.Impl.K256.PointMul open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.K256 open Hacl.K256.Scalar open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group include Hacl.K256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 15ul 16ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 15ul 32ul = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len let point_mul out scalar q = let h0 = ST.get () in SE.exp_fw_lemma S.mk_k256_concrete_ops (point_eval h0 q) 256 (qas_nat h0 scalar) 4; BE.lexp_fw_consttime 15ul 0ul mk_k256_concrete_ops 4ul (null uint64) q 4ul 256ul scalar out val precomp_get_consttime: BE.pow_a_to_small_b_st U64 15ul 0ul mk_k256_concrete_ops 4ul 16ul (BE.table_inv_precomp 15ul 0ul mk_k256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:qelem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ qas_nat h scalar < S.q /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (qas_nat h0 scalar) in S.to_aff_point (point_eval h1 out) == LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) //SPT256.exp_as_exp_four_nat256_precomp S.mk_k256_comm_monoid //(S.to_aff_point (point_eval h0 q1)) (qas_nat h0 scalar)) let point_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 15ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_k256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.q} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_k256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b))) let lemma_exp_four_fw_local b = let cm = S.mk_k256_comm_monoid in let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in let res = LE.exp_four_fw cm g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 in assert (res == SPT256.exp_as_exp_four_nat256_precomp cm g_aff (BD.bn_v b)); SPT256.lemma_point_mul_base_precomp4 cm g_aff (BD.bn_v b); assert (res == LE.pow cm g_aff (BD.bn_v b)); SE.exp_fw_lemma S.mk_k256_concrete_ops S.g 256 (BD.bn_v b) 4; LE.exp_fw_lemma cm g_aff 256 (BD.bn_v b) 4; assert (S.to_aff_point (S.point_mul_g (BD.bn_v b)) == LE.pow cm g_aff (BD.bn_v b))
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.K256.PointMul.fst" }
[ { "abbrev": false, "full_module": "Hacl.K256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
out: Hacl.Impl.K256.Point.point -> scalar: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.K256.Scalar.qelem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.K256.PointMul.lemma_exp_four_fw_local", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Hacl.K256.Scalar.qnlimb", "Hacl.Impl.K256.PointMul.point_mul_g_noalloc", "Hacl.K256.PrecompTable.proj_g_pow2_192_lseq_lemma", "Hacl.K256.PrecompTable.proj_g_pow2_128_lseq_lemma", "Hacl.K256.PrecompTable.proj_g_pow2_64_lseq_lemma", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Hacl.K256.PrecompTable.mk_proj_g_pow2_192", "Lib.Buffer.lbuffer", "FStar.UInt32.__uint_to_t", "Hacl.K256.PrecompTable.mk_proj_g_pow2_128", "Hacl.K256.PrecompTable.mk_proj_g_pow2_64", "Hacl.Impl.K256.Point.make_g", "Lib.Buffer.create", "Lib.IntTypes.u64", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let point_mul_g out scalar =
push_frame (); let h0 = ST.get () in let q1 = create 15ul (u64 0) in make_g q1; let q2 = mk_proj_g_pow2_64 () in let q3 = mk_proj_g_pow2_128 () in let q4 = mk_proj_g_pow2_192 () in proj_g_pow2_64_lseq_lemma (); proj_g_pow2_128_lseq_lemma (); proj_g_pow2_192_lseq_lemma (); point_mul_g_noalloc out scalar q1 q2 q3 q4; lemma_exp_four_fw_local (as_seq h0 scalar); pop_frame ()
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u8_rem
val u8_rem (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
val u8_rem (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z))
let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 17, "end_line": 295, "start_col": 0, "start_line": 291 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt8.t", "FStar.UInt8.rem", "FStar.Range.labeled", "Prims.l_not", "Prims.eq2", "Prims.int", "FStar.UInt8.v", "FStar.UInt.uint_t", "FStar.UInt8.n", "FStar.UInt.mod" ]
[]
false
false
false
false
false
let u8_rem (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) =
UInt8.rem x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u8_shift_right
val u8_shift_right (r: range) (a: UInt8.t) (s: UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
val u8_shift_right (r: range) (a: UInt8.t) (s: UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c))
let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 25, "end_line": 335, "start_col": 0, "start_line": 331 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> a: FStar.UInt8.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt8.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt8.t", "FStar.UInt32.t", "FStar.UInt8.shift_right", "FStar.Range.labeled", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "FStar.UInt8.n", "Prims.op_Equality", "FStar.UInt.uint_t", "FStar.UInt.shift_right", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let u8_shift_right (r: range) (a: UInt8.t) (s: UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) =
UInt8.shift_right a s
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u8_lognot
val u8_lognot (r: range) (x: UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
val u8_lognot (r: range) (x: UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z))
let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 327, "start_col": 0, "start_line": 323 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt8.t", "FStar.UInt8.lognot", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt8.n", "FStar.UInt.lognot", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let u8_lognot (r: range) (x: UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) =
UInt8.lognot x
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u8_sub
val u8_sub (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n) ) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
val u8_sub (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n) ) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y)
let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 17, "end_line": 273, "start_col": 0, "start_line": 269 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt8.t", "FStar.UInt8.sub", "FStar.Range.labeled", "FStar.UInt.size", "Prims.op_Subtraction", "FStar.UInt8.v", "FStar.UInt8.n", "Prims.eq2", "Prims.int" ]
[]
false
false
false
false
false
let u8_sub (r: range) (x y: UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n) ) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) =
UInt8.sub x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u16_mul
val u16_mul (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size ((UInt16.v x) `Prims.op_Multiply` (UInt16.v y)) UInt16.n)) (ensures fun z -> UInt16.v z == (UInt16.v x) `Prims.op_Multiply` (UInt16.v y))
val u16_mul (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size ((UInt16.v x) `Prims.op_Multiply` (UInt16.v y)) UInt16.n)) (ensures fun z -> UInt16.v z == (UInt16.v x) `Prims.op_Multiply` (UInt16.v y))
let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 366, "start_col": 0, "start_line": 362 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt16.t", "FStar.UInt16.mul", "FStar.Range.labeled", "FStar.UInt.size", "Prims.op_Multiply", "FStar.UInt16.v", "FStar.UInt16.n", "Prims.eq2", "Prims.int" ]
[]
false
false
false
false
false
let u16_mul (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size ((UInt16.v x) `Prims.op_Multiply` (UInt16.v y)) UInt16.n)) (ensures fun z -> UInt16.v z == (UInt16.v x) `Prims.op_Multiply` (UInt16.v y)) =
UInt16.mul x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u16_sub
val u16_sub (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
val u16_sub (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y)
let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 359, "start_col": 0, "start_line": 355 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt16.t", "FStar.UInt16.sub", "FStar.Range.labeled", "FStar.UInt.size", "Prims.op_Subtraction", "FStar.UInt16.v", "FStar.UInt16.n", "Prims.eq2", "Prims.int" ]
[]
false
false
false
false
false
let u16_sub (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) =
UInt16.sub x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u8_logxor
val u8_logxor (r: range) (x y: UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> (UInt8.v x) `UInt.logxor` (UInt8.v y) == UInt8.v z))
val u8_logxor (r: range) (x y: UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> (UInt8.v x) `UInt.logxor` (UInt8.v y) == UInt8.v z))
let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 20, "end_line": 311, "start_col": 0, "start_line": 307 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt8.t -> y: FStar.UInt8.t -> Prims.Pure FStar.UInt8.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt8.t", "FStar.UInt8.logxor", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt8.n", "FStar.UInt.logxor", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let u8_logxor (r: range) (x y: UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> (UInt8.v x) `UInt.logxor` (UInt8.v y) == UInt8.v z)) =
UInt8.logxor x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u8_shift_left
val u8_shift_left (r: range) (a: UInt8.t) (s: UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
val u8_shift_left (r: range) (a: UInt8.t) (s: UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c))
let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 24, "end_line": 343, "start_col": 0, "start_line": 339 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> a: FStar.UInt8.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt8.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt8.t", "FStar.UInt32.t", "FStar.UInt8.shift_left", "FStar.Range.labeled", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "FStar.UInt8.n", "Prims.op_Equality", "FStar.UInt.uint_t", "FStar.UInt.shift_left", "FStar.UInt8.v" ]
[]
false
false
false
false
false
let u8_shift_left (r: range) (a: UInt8.t) (s: UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) =
UInt8.shift_left a s
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u16_add
val u16_add (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
val u16_add (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y)
let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 352, "start_col": 0, "start_line": 348 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt16.t", "FStar.UInt16.add", "FStar.Range.labeled", "FStar.UInt.size", "Prims.op_Addition", "FStar.UInt16.v", "FStar.UInt16.n", "Prims.eq2", "Prims.int" ]
[]
false
false
false
false
false
let u16_add (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) =
UInt16.add x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u16_logand
val u16_logand (r: range) (x y: UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> (UInt16.v x) `UInt.logand` (UInt16.v y) == UInt16.v z))
val u16_logand (r: range) (x y: UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> (UInt16.v x) `UInt.logand` (UInt16.v y) == UInt16.v z))
let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 21, "end_line": 389, "start_col": 0, "start_line": 385 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt16.t", "FStar.UInt16.logand", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt16.n", "FStar.UInt.logand", "FStar.UInt16.v" ]
[]
false
false
false
false
false
let u16_logand (r: range) (x y: UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> (UInt16.v x) `UInt.logand` (UInt16.v y) == UInt16.v z)) =
UInt16.logand x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u32_sub
val u32_sub (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
val u32_sub (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y)
let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 446, "start_col": 0, "start_line": 442 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt32.t", "FStar.UInt32.sub", "FStar.Range.labeled", "FStar.UInt.size", "Prims.op_Subtraction", "FStar.UInt32.v", "FStar.UInt32.n", "Prims.eq2", "Prims.int" ]
[]
false
false
false
false
false
let u32_sub (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) =
UInt32.sub x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u16_logxor
val u16_logxor (r: range) (x y: UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> (UInt16.v x) `UInt.logxor` (UInt16.v y) == UInt16.v z))
val u16_logxor (r: range) (x y: UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> (UInt16.v x) `UInt.logxor` (UInt16.v y) == UInt16.v z))
let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 21, "end_line": 397, "start_col": 0, "start_line": 393 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt16.t", "FStar.UInt16.logxor", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt16.n", "FStar.UInt.logxor", "FStar.UInt16.v" ]
[]
false
false
false
false
false
let u16_logxor (r: range) (x y: UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> (UInt16.v x) `UInt.logxor` (UInt16.v y) == UInt16.v z)) =
UInt16.logxor x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u32_mul
val u32_mul (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size ((UInt32.v x) `Prims.op_Multiply` (UInt32.v y)) UInt32.n)) (ensures fun z -> UInt32.v z == (UInt32.v x) `Prims.op_Multiply` (UInt32.v y))
val u32_mul (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size ((UInt32.v x) `Prims.op_Multiply` (UInt32.v y)) UInt32.n)) (ensures fun z -> UInt32.v z == (UInt32.v x) `Prims.op_Multiply` (UInt32.v y))
let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 453, "start_col": 0, "start_line": 449 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt32.t", "FStar.UInt32.mul", "FStar.Range.labeled", "FStar.UInt.size", "Prims.op_Multiply", "FStar.UInt32.v", "FStar.UInt32.n", "Prims.eq2", "Prims.int" ]
[]
false
false
false
false
false
let u32_mul (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size ((UInt32.v x) `Prims.op_Multiply` (UInt32.v y)) UInt32.n)) (ensures fun z -> UInt32.v z == (UInt32.v x) `Prims.op_Multiply` (UInt32.v y)) =
UInt32.mul x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u32_logxor
val u32_logxor (r: range) (x y: UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> (UInt32.v x) `UInt.logxor` (UInt32.v y) == UInt32.v z))
val u32_logxor (r: range) (x y: UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> (UInt32.v x) `UInt.logxor` (UInt32.v y) == UInt32.v z))
let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 21, "end_line": 484, "start_col": 0, "start_line": 480 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt32.t", "FStar.UInt32.logxor", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt32.n", "FStar.UInt.logxor", "FStar.UInt32.v" ]
[]
false
false
false
false
false
let u32_logxor (r: range) (x y: UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> (UInt32.v x) `UInt.logxor` (UInt32.v y) == UInt32.v z)) =
UInt32.logxor x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.id
val id (#t: Type) (x: t) : Tot t
val id (#t: Type) (x: t) : Tot t
let id (#t: Type) (x: t) : Tot t = x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 36, "end_line": 611, "start_col": 0, "start_line": 611 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y unfold noextract let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y unfold noextract let u64_mul (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 multiplication" (UInt.size (UInt64.v x `Prims.op_Multiply` UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x `Prims.op_Multiply` UInt64.v y) = UInt64.mul x y unfold noextract let u64_div (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 division" (UInt64.v y =!= 0)) (ensures fun z -> UInt64.v z == UInt64.v x / UInt64.v y) = UInt64.div x y (** Euclidean remainder *) unfold noextract let u64_rem (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 remainder" (UInt64.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt64.v x) (UInt64.v y) == UInt64.v z)) = UInt64.rem x y (** Bitwise logical conjunction *) unfold noextract let u64_logand (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logand` UInt64.v y == UInt64.v z)) = UInt64.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u64_logxor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logxor` UInt64.v y == UInt64.v z)) = UInt64.logxor x y (** Bitwise logical disjunction *) unfold noextract let u64_logor (r:range) (x:UInt64.t) (y:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt64.v x `UInt.logor` UInt64.v y == UInt64.v z)) = UInt64.logor x y (** Bitwise logical negation *) unfold noextract let u64_lognot (r:range) (x:UInt64.t) : Pure UInt64.t (requires True) (ensures (fun z -> UInt.lognot (UInt64.v x) == UInt64.v z)) = UInt64.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_right (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift right" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u64_shift_left (r:range) (a:UInt64.t) (s:UInt32.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 shift left" (UInt32.v s < UInt64.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt64.v a) (UInt32.v s) = UInt64.v c)) = UInt64.shift_left a s (*** Casts ***) (* Identity function for endianness-only casts *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: t -> t
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let id (#t: Type) (x: t) : Tot t =
x
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u32_logor
val u32_logor (r: range) (x y: UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> (UInt32.v x) `UInt.logor` (UInt32.v y) == UInt32.v z))
val u32_logor (r: range) (x y: UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> (UInt32.v x) `UInt.logor` (UInt32.v y) == UInt32.v z))
let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 20, "end_line": 492, "start_col": 0, "start_line": 488 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt32.t", "FStar.UInt32.logor", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt32.n", "FStar.UInt.logor", "FStar.UInt32.v" ]
[]
false
false
false
false
false
let u32_logor (r: range) (x y: UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> (UInt32.v x) `UInt.logor` (UInt32.v y) == UInt32.v z)) =
UInt32.logor x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u16_lognot
val u16_lognot (r: range) (x: UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
val u16_lognot (r: range) (x: UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z))
let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 19, "end_line": 413, "start_col": 0, "start_line": 409 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt16.t", "FStar.UInt16.lognot", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt16.n", "FStar.UInt.lognot", "FStar.UInt16.v" ]
[]
false
false
false
false
false
let u16_lognot (r: range) (x: UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) =
UInt16.lognot x
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u16_logor
val u16_logor (r: range) (x y: UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> (UInt16.v x) `UInt.logor` (UInt16.v y) == UInt16.v z))
val u16_logor (r: range) (x y: UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> (UInt16.v x) `UInt.logor` (UInt16.v y) == UInt16.v z))
let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 20, "end_line": 405, "start_col": 0, "start_line": 401 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt16.t", "FStar.UInt16.logor", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt16.n", "FStar.UInt.logor", "FStar.UInt16.v" ]
[]
false
false
false
false
false
let u16_logor (r: range) (x y: UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> (UInt16.v x) `UInt.logor` (UInt16.v y) == UInt16.v z)) =
UInt16.logor x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u16_rem
val u16_rem (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
val u16_rem (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z))
let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 381, "start_col": 0, "start_line": 377 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt16.t", "FStar.UInt16.rem", "FStar.Range.labeled", "Prims.l_not", "Prims.eq2", "Prims.int", "FStar.UInt16.v", "FStar.UInt.uint_t", "FStar.UInt16.n", "FStar.UInt.mod" ]
[]
false
false
false
false
false
let u16_rem (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) =
UInt16.rem x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u16_div
val u16_div (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
val u16_div (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y)
let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 373, "start_col": 0, "start_line": 369 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt16.t -> y: FStar.UInt16.t -> Prims.Pure FStar.UInt16.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt16.t", "FStar.UInt16.div", "FStar.Range.labeled", "Prims.l_not", "Prims.eq2", "Prims.int", "FStar.UInt16.v", "Prims.op_Division" ]
[]
false
false
false
false
false
let u16_div (r: range) (x y: UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) =
UInt16.div x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u32_add
val u32_add (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
val u32_add (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y)
let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 439, "start_col": 0, "start_line": 435 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt32.t", "FStar.UInt32.add", "FStar.Range.labeled", "FStar.UInt.size", "Prims.op_Addition", "FStar.UInt32.v", "FStar.UInt32.n", "Prims.eq2", "Prims.int" ]
[]
false
false
false
false
false
let u32_add (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) =
UInt32.add x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u32_rem
val u32_rem (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
val u32_rem (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z))
let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 468, "start_col": 0, "start_line": 464 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt32.t", "FStar.UInt32.rem", "FStar.Range.labeled", "Prims.l_not", "Prims.eq2", "Prims.int", "FStar.UInt32.v", "FStar.UInt.uint_t", "FStar.UInt32.n", "FStar.UInt.mod" ]
[]
false
false
false
false
false
let u32_rem (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) =
UInt32.rem x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u32_logand
val u32_logand (r: range) (x y: UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> (UInt32.v x) `UInt.logand` (UInt32.v y) == UInt32.v z))
val u32_logand (r: range) (x y: UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> (UInt32.v x) `UInt.logand` (UInt32.v y) == UInt32.v z))
let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 21, "end_line": 476, "start_col": 0, "start_line": 472 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt32.t", "FStar.UInt32.logand", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt32.n", "FStar.UInt.logand", "FStar.UInt32.v" ]
[]
false
false
false
false
false
let u32_logand (r: range) (x y: UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> (UInt32.v x) `UInt.logand` (UInt32.v y) == UInt32.v z)) =
UInt32.logand x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u64_sub
val u64_sub (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
val u64_sub (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y)
let u64_sub (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) = UInt64.sub x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 532, "start_col": 0, "start_line": 528 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s (*** UInt64 operators ***) unfold noextract let u64_add (r:range) (x y:UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 addition" (UInt.size (UInt64.v x + UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x + UInt64.v y) = UInt64.add x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt64.t", "FStar.UInt64.sub", "FStar.Range.labeled", "FStar.UInt.size", "Prims.op_Subtraction", "FStar.UInt64.v", "FStar.UInt64.n", "Prims.eq2", "Prims.int" ]
[]
false
false
false
false
false
let u64_sub (r: range) (x y: UInt64.t) : Pure UInt64.t (requires labeled r "Cannot verify u64 subtraction" (UInt.size (UInt64.v x - UInt64.v y) UInt64.n)) (ensures fun z -> UInt64.v z == UInt64.v x - UInt64.v y) =
UInt64.sub x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u32_lognot
val u32_lognot (r: range) (x: UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
val u32_lognot (r: range) (x: UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z))
let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 19, "end_line": 500, "start_col": 0, "start_line": 496 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt32.t", "FStar.UInt32.lognot", "Prims.l_True", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt32.n", "FStar.UInt.lognot", "FStar.UInt32.v" ]
[]
false
false
false
false
false
let u32_lognot (r: range) (x: UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) =
UInt32.lognot x
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u16_shift_left
val u16_shift_left (r: range) (a: UInt16.t) (s: UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
val u16_shift_left (r: range) (a: UInt16.t) (s: UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c))
let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 25, "end_line": 429, "start_col": 0, "start_line": 425 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> a: FStar.UInt16.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt16.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt16.t", "FStar.UInt32.t", "FStar.UInt16.shift_left", "FStar.Range.labeled", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "FStar.UInt16.n", "Prims.op_Equality", "FStar.UInt.uint_t", "FStar.UInt.shift_left", "FStar.UInt16.v" ]
[]
false
false
false
false
false
let u16_shift_left (r: range) (a: UInt16.t) (s: UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) =
UInt16.shift_left a s
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u16_shift_right
val u16_shift_right (r: range) (a: UInt16.t) (s: UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
val u16_shift_right (r: range) (a: UInt16.t) (s: UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c))
let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 26, "end_line": 421, "start_col": 0, "start_line": 417 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> a: FStar.UInt16.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt16.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt16.t", "FStar.UInt32.t", "FStar.UInt16.shift_right", "FStar.Range.labeled", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "FStar.UInt16.n", "Prims.op_Equality", "FStar.UInt.uint_t", "FStar.UInt.shift_right", "FStar.UInt16.v" ]
[]
false
false
false
false
false
let u16_shift_right (r: range) (a: UInt16.t) (s: UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) =
UInt16.shift_right a s
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u32_div
val u32_div (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
val u32_div (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y)
let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 460, "start_col": 0, "start_line": 456 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt32.t", "FStar.UInt32.div", "FStar.Range.labeled", "Prims.l_not", "Prims.eq2", "Prims.int", "FStar.UInt32.v", "Prims.op_Division" ]
[]
false
false
false
false
false
let u32_div (r: range) (x y: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) =
UInt32.div x y
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u32_shift_left
val u32_shift_left (r: range) (a s: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
val u32_shift_left (r: range) (a s: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c))
let u32_shift_left (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_left a s
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 25, "end_line": 516, "start_col": 0, "start_line": 512 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s (** Shift left with zero fill, shifting at most the integer width *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> a: FStar.UInt32.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt32.t", "FStar.UInt32.shift_left", "FStar.Range.labeled", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "FStar.UInt32.n", "Prims.op_Equality", "FStar.UInt.uint_t", "FStar.UInt.shift_left" ]
[]
false
false
false
false
false
let u32_shift_left (r: range) (a s: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift left" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt32.v a) (UInt32.v s) = UInt32.v c)) =
UInt32.shift_left a s
false
EverParse3d.Prelude.fsti
EverParse3d.Prelude.u32_shift_right
val u32_shift_right (r: range) (a s: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
val u32_shift_right (r: range) (a s: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c))
let u32_shift_right (r:range) (a:UInt32.t) (s:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) = UInt32.shift_right a s
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 26, "end_line": 508, "start_col": 0, "start_line": 504 }
(* Copyright 2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module EverParse3d.Prelude include EverParse3d.Prelude.StaticHeader include EverParse3d.Kinds open FStar.Range module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module C = FStar.Int.Cast let pow2_values (x:nat) : Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 2 -> p=4 | 3 -> p=8 | 4 -> p=16 | 5 -> p=32 | 6 -> p=64 | 7 -> p=128 | 8 -> p=256 | _ -> True) [SMTPat (pow2 x)] = norm_spec [delta;zeta;primops] (pow2 0); norm_spec [delta;zeta;primops] (pow2 1); norm_spec [delta;zeta;primops] (pow2 2); norm_spec [delta;zeta;primops] (pow2 3); norm_spec [delta;zeta;primops] (pow2 4); norm_spec [delta;zeta;primops] (pow2 5); norm_spec [delta;zeta;primops] (pow2 6); norm_spec [delta;zeta;primops] (pow2 7); norm_spec [delta;zeta;primops] (pow2 8) //////////////////////////////////////////////////////////////////////////////// // Parsers //////////////////////////////////////////////////////////////////////////////// [@@erasable] inline_for_extraction noextract val parser (#nz:bool) (#wk: weak_kind) (k:parser_kind nz wk) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_ret (#t:Type) (v:t) : Tot (parser ret_kind t) inline_for_extraction noextract val parse_dep_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: Type) (p1: parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2: (t1 -> Tot Type)) (p2: (x: t1) -> parser k2 (t2 x)) : Tot (parser (and_then_kind k1 k2) (dtuple2 t1 t2) ) /// Parser: sequencing inline_for_extraction noextract val parse_pair (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:_) (p1:parser k1 t1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:_) (p2:parser k2 t2) : Tot (parser (and_then_kind k1 k2) (t1 * t2)) /// Parser: filter let refine t (f:t -> bool) = x:t{f x} inline_for_extraction noextract val parse_filter (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (f:(t -> bool)) : Tot (parser (filter_kind k) (refine t f)) inline_for_extraction noextract val parse_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k' k) t) inline_for_extraction noextract val parse_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : Tot (parser (glb k k') t) /// Parser: unreachable, for default cases of exhaustive pattern matching inline_for_extraction noextract val parse_impos (_:unit) : parser impos_kind False let t_ite (e:bool) (a:squash e -> Type) (b:squash (not e) -> Type) : Type = if e then a() else b() val parse_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#a:squash e -> Type) (#b:squash (not e) -> Type) (p1:squash e -> parser k (a())) (p2:squash (not e) -> parser k (b())) : Tot (parser k (t_ite e a b)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized list whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val nlist (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#t:_) (p:parser k t) : Tot (parser kind_nlist (nlist n t)) ///// // Parse all of the remaining bytes of the input buffer ///// noextract val all_bytes: Type0 val parse_all_bytes: parser kind_all_bytes all_bytes //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is at most n //////////////////////////////////////////////////////////////////////////////// val t_at_most (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_at_most (t_at_most n t)) //////////////////////////////////////////////////////////////////////////////// // Variable-sized element whose size in bytes is exactly n //////////////////////////////////////////////////////////////////////////////// val t_exact (n:U32.t) (t:Type u#r) : Type u#r inline_for_extraction noextract val parse_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:_) (p:parser k t) : Tot (parser kind_t_exact (t_exact n t)) //////////////////////////////////////////////////////////////////////////////// // Readers //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract val reader (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:_) (p:parser k t) : Type u#1 inline_for_extraction noextract val read_filter (#nz:_) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: reader p) (f: (t -> bool)) : reader (parse_filter p f) inline_for_extraction noextract val read_impos : reader (parse_impos()) /// Parse a zero-terminated string noextract val cstring (t: eqtype) (terminator: t) : Tot Type0 val parse_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) : Tot (parser parse_string_kind (cstring t terminator)) noextract val all_zeros: Type0 val parse_all_zeros: parser kind_all_zeros all_zeros //////////////////////////////////////////////////////////////////////////////// // Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction let ___Bool = bool /// UINT8 let ___UINT8 : eqtype = FStar.UInt8.t val parse____UINT8 : parser kind____UINT8 ___UINT8 val read____UINT8 : reader parse____UINT8 // Big-endian (or "network order") /// UINT8BE let ___UINT8BE : eqtype = FStar.UInt8.t val parse____UINT8BE : parser kind____UINT8BE ___UINT8BE val read____UINT8BE : reader parse____UINT8BE /// UInt16BE let ___UINT16BE : eqtype = U16.t val parse____UINT16BE : parser kind____UINT16BE ___UINT16BE val read____UINT16BE : reader parse____UINT16BE /// UInt32BE let ___UINT32BE : eqtype = U32.t val parse____UINT32BE : parser kind____UINT32BE ___UINT32BE val read____UINT32BE : reader parse____UINT32BE /// UInt64BE let ___UINT64BE : eqtype = U64.t val parse____UINT64BE : parser kind____UINT64BE ___UINT64BE val read____UINT64BE : reader parse____UINT64BE // Little-endian /// UInt16 let ___UINT16 : eqtype = U16.t val parse____UINT16 : parser kind____UINT16 ___UINT16 val read____UINT16 : reader parse____UINT16 /// UInt32 let ___UINT32 : eqtype = U32.t val parse____UINT32 : parser kind____UINT32 ___UINT32 val read____UINT32 : reader parse____UINT32 /// UInt64 let ___UINT64 : eqtype = U64.t val parse____UINT64 : parser kind____UINT64 ___UINT64 val read____UINT64 : reader parse____UINT64 let parse_unit : parser kind_unit unit = parse_ret () inline_for_extraction noextract val read_unit : reader (parse_ret ()) //////////////////////////////////////////////////////////////////////////////// //Convenience lemmas for bounded arithmetic, especially on bitfields //////////////////////////////////////////////////////////////////////////////// let max_int_sizes : squash FStar.UInt.( max_int 10 == 1023 /\ max_int 8 == 255 ) = let open FStar.UInt in normalize_term_spec (max_int 10) (* * AR: scaffolding for getting arithmetic error locations in the 3d file *) (*** UInt8 operations ***) unfold noextract let u8_add (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 addition" (UInt.size (UInt8.v x + UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x + UInt8.v y) = UInt8.add x y unfold noextract let u8_sub (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 subtraction" (UInt.size (UInt8.v x - UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x - UInt8.v y) = UInt8.sub x y unfold noextract let u8_mul (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 multiplication" (UInt.size (UInt8.v x `Prims.op_Multiply` UInt8.v y) UInt8.n)) (ensures fun z -> UInt8.v z == UInt8.v x `Prims.op_Multiply` UInt8.v y) = UInt8.mul x y unfold noextract let u8_div (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 division" (UInt8.v y =!= 0)) (ensures fun z -> UInt8.v z == UInt8.v x / UInt8.v y) = UInt8.div x y (** Euclidean remainder *) unfold noextract let u8_rem (r:range) (x y:UInt8.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 remainder" (UInt8.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt8.v x) (UInt8.v y) == UInt8.v z)) = UInt8.rem x y (** Bitwise logical conjunction *) unfold noextract let u8_logand (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logand` UInt8.v y == UInt8.v z)) = UInt8.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u8_logxor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logxor` UInt8.v y == UInt8.v z)) = UInt8.logxor x y (** Bitwise logical disjunction *) unfold noextract let u8_logor (r:range) (x:UInt8.t) (y:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt8.v x `UInt.logor` UInt8.v y == UInt8.v z)) = UInt8.logor x y (** Bitwise logical negation *) unfold noextract let u8_lognot (r:range) (x:UInt8.t) : Pure UInt8.t (requires True) (ensures (fun z -> UInt.lognot (UInt8.v x) == UInt8.v z)) = UInt8.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_right (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift right" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u8_shift_left (r:range) (a:UInt8.t) (s:UInt32.t) : Pure UInt8.t (requires labeled r "Cannot verify u8 shift left" (UInt32.v s < UInt8.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt8.v a) (UInt32.v s) = UInt8.v c)) = UInt8.shift_left a s (*** UInt16 operations ***) unfold noextract let u16_add (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 addition" (UInt.size (UInt16.v x + UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x + UInt16.v y) = UInt16.add x y unfold noextract let u16_sub (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 subtraction" (UInt.size (UInt16.v x - UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x - UInt16.v y) = UInt16.sub x y unfold noextract let u16_mul (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 multiplication" (UInt.size (UInt16.v x `Prims.op_Multiply` UInt16.v y) UInt16.n)) (ensures fun z -> UInt16.v z == UInt16.v x `Prims.op_Multiply` UInt16.v y) = UInt16.mul x y unfold noextract let u16_div (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 division" (UInt16.v y =!= 0)) (ensures fun z -> UInt16.v z == UInt16.v x / UInt16.v y) = UInt16.div x y (** Euclidean remainder *) unfold noextract let u16_rem (r:range) (x y:UInt16.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 remainder" (UInt16.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt16.v x) (UInt16.v y) == UInt16.v z)) = UInt16.rem x y (** Bitwise logical conjunction *) unfold noextract let u16_logand (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logand` UInt16.v y == UInt16.v z)) = UInt16.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u16_logxor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logxor` UInt16.v y == UInt16.v z)) = UInt16.logxor x y (** Bitwise logical disjunction *) unfold noextract let u16_logor (r:range) (x:UInt16.t) (y:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt16.v x `UInt.logor` UInt16.v y == UInt16.v z)) = UInt16.logor x y (** Bitwise logical negation *) unfold noextract let u16_lognot (r:range) (x:UInt16.t) : Pure UInt16.t (requires True) (ensures (fun z -> UInt.lognot (UInt16.v x) == UInt16.v z)) = UInt16.lognot x (** Shift right with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_right (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift right" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_right a s (** Shift left with zero fill, shifting at most the integer width *) unfold noextract let u16_shift_left (r:range) (a:UInt16.t) (s:UInt32.t) : Pure UInt16.t (requires labeled r "Cannot verify u16 shift left" (UInt32.v s < UInt16.n)) (ensures (fun c -> FStar.UInt.shift_left (UInt16.v a) (UInt32.v s) = UInt16.v c)) = UInt16.shift_left a s (*** UInt32 operations ***) unfold noextract let u32_add (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 addition" (UInt.size (UInt32.v x + UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x + UInt32.v y) = UInt32.add x y unfold noextract let u32_sub (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 subtraction" (UInt.size (UInt32.v x - UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x - UInt32.v y) = UInt32.sub x y unfold noextract let u32_mul (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 multiplication" (UInt.size (UInt32.v x `Prims.op_Multiply` UInt32.v y) UInt32.n)) (ensures fun z -> UInt32.v z == UInt32.v x `Prims.op_Multiply` UInt32.v y) = UInt32.mul x y unfold noextract let u32_div (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 division" (UInt32.v y =!= 0)) (ensures fun z -> UInt32.v z == UInt32.v x / UInt32.v y) = UInt32.div x y (** Euclidean remainder *) unfold noextract let u32_rem (r:range) (x y:UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 remainder" (UInt32.v y =!= 0)) (ensures (fun z -> FStar.UInt.mod (UInt32.v x) (UInt32.v y) == UInt32.v z)) = UInt32.rem x y (** Bitwise logical conjunction *) unfold noextract let u32_logand (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logand` UInt32.v y == UInt32.v z)) = UInt32.logand x y (** Bitwise logical exclusive-or *) unfold noextract let u32_logxor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logxor` UInt32.v y == UInt32.v z)) = UInt32.logxor x y (** Bitwise logical disjunction *) unfold noextract let u32_logor (r:range) (x:UInt32.t) (y:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt32.v x `UInt.logor` UInt32.v y == UInt32.v z)) = UInt32.logor x y (** Bitwise logical negation *) unfold noextract let u32_lognot (r:range) (x:UInt32.t) : Pure UInt32.t (requires True) (ensures (fun z -> UInt.lognot (UInt32.v x) == UInt32.v z)) = UInt32.lognot x (** Shift right with zero fill, shifting at most the integer width *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Range.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Int.Cast.fst.checked", "EverParse3d.Prelude.StaticHeader.fst.checked", "EverParse3d.Kinds.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.fsti" }
[ { "abbrev": true, "full_module": "LowParse.Spec.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "LowParse.Low.Combinators", "short_module": "LPLC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "C" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Range", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Kinds", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude.StaticHeader", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Range.range -> a: FStar.UInt32.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.Range.range", "FStar.UInt32.t", "FStar.UInt32.shift_right", "FStar.Range.labeled", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "FStar.UInt32.n", "Prims.op_Equality", "FStar.UInt.uint_t", "FStar.UInt.shift_right" ]
[]
false
false
false
false
false
let u32_shift_right (r: range) (a s: UInt32.t) : Pure UInt32.t (requires labeled r "Cannot verify u32 shift right" (UInt32.v s < UInt32.n)) (ensures (fun c -> FStar.UInt.shift_right (UInt32.v a) (UInt32.v s) = UInt32.v c)) =
UInt32.shift_right a s
false