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
Vale.X64.InsAes.fsti
Vale.X64.InsAes.va_wp_VAESNI_enc_last
val va_wp_VAESNI_enc_last (dst src1 src2: va_operand_xmm) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
val va_wp_VAESNI_enc_last (dst src1 src2: va_operand_xmm) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
let va_wp_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (())))
{ "file_name": "obj/Vale.X64.InsAes.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 249, "start_col": 0, "start_line": 242 }
module Vale.X64.InsAes open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.Decls open Vale.X64.QuickCode open Vale.X64.CPU_Features_s //-- Pclmulqdq val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_code val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_pbool val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst))) (Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (()))) val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) : (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) = (va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi)) //-- //-- VPclmulqdq val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_code val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))) (Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2))))) ==> va_k va_sM (()))) val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)) = (va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi src2Hi)) //-- //-- AESNI_enc val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM (()))) val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src)) = (va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src) (va_wpProof_AESNI_enc dst src)) //-- //-- VAESNI_enc val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_code val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_pbool val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (()))) val va_wpProof_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VAESNI_enc dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) = (va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2)) //-- //-- AESNI_enc_last val va_code_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code val va_codegen_success_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool val va_lemma_AESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_enc_last dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) ==> va_k va_sM (()))) val va_wpProof_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AESNI_enc_last dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc_last dst src)) = (va_QProc (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc_last dst src) (va_wpProof_AESNI_enc_last dst src)) //-- //-- VAESNI_enc_last val va_code_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_code val va_codegen_success_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_pbool val va_lemma_VAESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VAESNI_enc_last dst src1 src2) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))) (va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.InsAes.fsti" }
[ { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "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": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> src1: Vale.X64.Decls.va_operand_xmm -> src2: Vale.X64.Decls.va_operand_xmm -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_state", "Prims.unit", "Prims.l_and", "Vale.X64.Decls.va_is_dst_xmm", "Vale.X64.Decls.va_is_src_xmm", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.CPU_Features_s.aesni_enabled", "Vale.X64.CPU_Features_s.avx_enabled", "Prims.l_Forall", "Vale.X64.Decls.va_value_xmm", "Vale.X64.Flags.t", "Prims.l_imp", "Prims.eq2", "Vale.Def.Types_s.quad32", "Vale.X64.Decls.va_eval_xmm", "Vale.Def.Types_s.quad32_xor", "Vale.AES.AES_common_s.sub_bytes", "Vale.AES.AES_s.shift_rows_LE", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_upd_flags", "Vale.X64.Decls.va_upd_operand_xmm" ]
[]
false
false
false
true
true
let va_wp_VAESNI_enc_last (dst src1 src2: va_operand_xmm) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst: va_value_xmm) (va_x_efl: Vale.X64.Flags.t). let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (())))
false
Hacl.Impl.Poly1305.Field32xN.fst
Hacl.Impl.Poly1305.Field32xN.load_precompute_r4
val load_precompute_r4: p:precomp_r 4 -> r0:uint64 -> r1:uint64 -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ load_precompute_r_post h1 p /\ (assert_norm (pow2 64 * pow2 64 = pow2 128); feval h1 (gsub p 0ul 5ul) == LSeq.create 4 (uint_v r1 * pow2 64 + uint_v r0)))
val load_precompute_r4: p:precomp_r 4 -> r0:uint64 -> r1:uint64 -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ load_precompute_r_post h1 p /\ (assert_norm (pow2 64 * pow2 64 = pow2 128); feval h1 (gsub p 0ul 5ul) == LSeq.create 4 (uint_v r1 * pow2 64 + uint_v r0)))
let load_precompute_r4 p r0 r1 = let r = sub p 0ul 5ul in let r5 = sub p 5ul 5ul in let rn = sub p 10ul 5ul in let rn_5 = sub p 15ul 5ul in let r_vec0 = vec_load r0 4 in let r_vec1 = vec_load r1 4 in let h0 = ST.get () in load_felem r r_vec0 r_vec1; let h1 = ST.get () in LSeq.eq_intro (LSeq.createi #Vec.pfelem 4 (fun i -> (uint64xN_v r_vec1).[i] * pow2 64 + (uint64xN_v r_vec0).[i])) (LSeq.create 4 (uint_v r1 * pow2 64 + uint_v r0)); assert (feval h1 r == LSeq.create 4 (uint_v r1 * pow2 64 + uint_v r0)); precompute_shift_reduce r5 r; fmul_r rn r r r5; precompute_shift_reduce rn_5 rn; fmul_r rn rn rn rn_5; let h3 = ST.get () in LSeq.eq_intro (feval h3 rn) (Vec.compute_rw (feval h1 r).[0]); precompute_shift_reduce rn_5 rn
{ "file_name": "code/poly1305/Hacl.Impl.Poly1305.Field32xN.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 550, "start_col": 0, "start_line": 527 }
module Hacl.Impl.Poly1305.Field32xN open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector include Hacl.Spec.Poly1305.Field32xN open Hacl.Spec.Poly1305.Field32xN.Lemmas open Hacl.Impl.Poly1305.Lemmas module Vec = Hacl.Spec.Poly1305.Vec module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BSeq = Lib.ByteSequence #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50 --using_facts_from '* -FStar.Seq'" inline_for_extraction noextract let felem (w:lanes) = lbuffer (uint64xN w) 5ul inline_for_extraction noextract let felem_wide (w:lanes) = felem w inline_for_extraction noextract let precomp_r (w:lanes) = lbuffer (uint64xN w) 20ul unfold noextract let op_String_Access #a #len = LSeq.index #a #len noextract val as_tup5: #w:lanes -> h:mem -> f:felem w -> GTot (felem5 w) let as_tup5 #w h f = let s = as_seq h f in let s0 = s.[0] in let s1 = s.[1] in let s2 = s.[2] in let s3 = s.[3] in let s4 = s.[4] in (s0,s1,s2,s3,s4) noextract val felem_fits: #w:lanes -> h:mem -> f:felem w -> m:scale32_5 -> Type0 let felem_fits #w h f m = felem_fits5 (as_tup5 h f) m noextract val felem_wide_fits: #w:lanes -> h:mem -> f:felem w -> m:scale32_5 -> Type0 let felem_wide_fits #w h f m = felem_wide_fits5 (as_tup5 h f) m noextract let feval (#w:lanes) (h:mem) (f:felem w) : GTot (LSeq.lseq Vec.pfelem w) = feval5 (as_tup5 h f) noextract let fas_nat (#w:lanes) (h:mem) (f:felem w) : GTot (LSeq.lseq nat w) = fas_nat5 (as_tup5 h f) noextract let felem_less (#w:lanes) (h:mem) (f:felem w) (max:nat) : Type0 = felem_less5 (as_tup5 h f) max val lemma_feval_is_fas_nat: #w:lanes -> h:mem -> f:felem w -> Lemma (requires felem_less h f (pow2 128)) (ensures (forall (i:nat). i < w ==> (feval h f).[i] == (fas_nat h f).[i])) let lemma_feval_is_fas_nat #w h f = lemma_feval_is_fas_nat (as_tup5 h f) inline_for_extraction noextract val fmul_precomp_r_pre: #w:lanes -> h:mem -> precomp:precomp_r w -> Type0 let fmul_precomp_r_pre #w h precomp = let r = gsub precomp 0ul 5ul in let r_5 = gsub precomp 5ul 5ul in felem_fits h r (1, 1, 1, 1, 1) /\ felem_fits h r_5 (5, 5, 5, 5, 5) /\ as_tup5 h r_5 == precomp_r5 (as_tup5 h r) noextract val load_precompute_r_post: #w:lanes -> h:mem -> p:precomp_r w -> Type0 let load_precompute_r_post #w h p = assert_norm (pow2 128 < Vec.prime); let r = gsub p 0ul 5ul in let rn = gsub p 10ul 5ul in let rn_5 = gsub p 15ul 5ul in fmul_precomp_r_pre h p /\ felem_fits h rn (2, 2, 2, 2, 2) /\ felem_fits h rn_5 (10, 10, 10, 10, 10) /\ as_tup5 h rn_5 == precomp_r5 (as_tup5 h rn) /\ feval h rn == Vec.compute_rw (feval h r).[0] inline_for_extraction noextract val create_felem: w:lanes -> StackInline (felem w) (requires fun h -> True) (ensures fun h0 b h1 -> stack_allocated b h0 h1 (LSeq.create 5 (zero w)) /\ feval h1 b == LSeq.create w 0) let create_felem w = let r = create 5ul (zero w) in let h1 = ST.get () in LSeq.eq_intro (feval h1 r) (LSeq.create w 0); r #push-options "--z3rlimit 100" inline_for_extraction noextract val set_bit: #w:lanes -> f:felem w -> i:size_t{size_v i <= 128} -> Stack unit (requires fun h -> live h f /\ felem_fits h f (1, 1, 1, 1, 1) /\ felem_less #w h f (pow2 (v i))) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (1, 1, 1, 1, 1) /\ (Math.Lemmas.pow2_le_compat 128 (v i); feval h1 f == LSeq.map (Vec.pfadd (pow2 (v i))) (feval h0 f))) let set_bit #w f i = let b = u64 1 <<. (i %. 26ul) in let mask = vec_load b w in let fi = f.(i /. 26ul) in let h0 = ST.get () in f.(i /. 26ul) <- vec_or fi mask; set_bit5_lemma (as_seq h0 f) (v i) #pop-options inline_for_extraction noextract val set_bit128: #w:lanes -> f:felem w -> Stack unit (requires fun h -> live h f /\ felem_fits h f (1, 1, 1, 1, 1) /\ felem_less #w h f (pow2 128)) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (1, 1, 1, 1, 1) /\ feval h1 f == LSeq.map (Vec.pfadd (pow2 128)) (feval h0 f)) let set_bit128 #w f = let b = u64 0x1000000 in assert_norm (0x1000000 = pow2 24); assert (v b == v (u64 1 <<. 24ul)); let mask = vec_load b w in let f4 = f.(4ul) in let h0 = ST.get () in f.(4ul) <- vec_or f4 mask; set_bit5_lemma (as_seq h0 f) 128 inline_for_extraction noextract val set_zero: #w:lanes -> f:felem w -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (0, 0, 0, 0, 0) /\ feval h1 f == LSeq.create w 0) let set_zero #w f = f.(0ul) <- zero w; f.(1ul) <- zero w; f.(2ul) <- zero w; f.(3ul) <- zero w; f.(4ul) <- zero w; let h1 = ST.get () in LSeq.eq_intro (feval h1 f) (LSeq.create w 0) inline_for_extraction noextract val copy_felem: #w:lanes -> #m:scale32_5 -> f1:felem w -> f2:felem w -> Stack unit (requires fun h -> live h f1 /\ live h f2 /\ disjoint f1 f2 /\ felem_fits h f2 m) (ensures fun h0 _ h1 -> modifies (loc f1) h0 h1 /\ felem_fits h1 f1 m /\ as_tup5 h1 f1 == as_tup5 h0 f2) let copy_felem #w #m f1 f2 = f1.(0ul) <- f2.(0ul); f1.(1ul) <- f2.(1ul); f1.(2ul) <- f2.(2ul); f1.(3ul) <- f2.(3ul); f1.(4ul) <- f2.(4ul) inline_for_extraction noextract val fadd: #w:lanes -> out:felem w -> f1:felem w -> f2:felem w -> Stack unit (requires fun h -> live h f1 /\ live h f2 /\ live h out /\ felem_fits h f1 (2,2,2,2,2) /\ felem_fits h f2 (1,1,1,1,1)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ //as_tup5 h1 out == fadd5 (as_tup5 h0 f1) (as_tup5 h0 f2) /\ felem_fits h1 out (3,3,3,3,3) /\ feval h1 out == LSeq.map2 Vec.pfadd (feval h0 f1) (feval h0 f2)) let fadd #w out f1 f2 = let f10 = f1.(0ul) in let f11 = f1.(1ul) in let f12 = f1.(2ul) in let f13 = f1.(3ul) in let f14 = f1.(4ul) in let f20 = f2.(0ul) in let f21 = f2.(1ul) in let f22 = f2.(2ul) in let f23 = f2.(3ul) in let f24 = f2.(4ul) in let (o0,o1,o2,o3,o4) = fadd5 #w (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in out.(0ul) <- o0; out.(1ul) <- o1; out.(2ul) <- o2; out.(3ul) <- o3; out.(4ul) <- o4 #push-options "--max_fuel 1" inline_for_extraction noextract val fmul_r: #w:lanes -> out:felem w -> f1:felem w -> r:felem w -> r5:felem w -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h r /\ live h r5 /\ felem_fits h f1 (3,3,3,3,3) /\ felem_fits h r (2,2,2,2,2) /\ felem_fits h r5 (10,10,10,10,10) /\ as_tup5 h r5 == precomp_r5 (as_tup5 h r)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ felem_fits h1 out (1,2,1,1,2) /\ feval h1 out == LSeq.map2 (Vec.pfmul) (feval h0 f1) (feval h0 r)) let fmul_r #w out f1 r r5 = let r0 = r.(0ul) in let r1 = r.(1ul) in let r2 = r.(2ul) in let r3 = r.(3ul) in let r4 = r.(4ul) in let r50 = r5.(0ul) in let r51 = r5.(1ul) in let r52 = r5.(2ul) in let r53 = r5.(3ul) in let r54 = r5.(4ul) in let f10 = f1.(0ul) in let f11 = f1.(1ul) in let f12 = f1.(2ul) in let f13 = f1.(3ul) in let f14 = f1.(4ul) in let (o0, o1, o2, o3, o4) = fmul_r5 #w (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r50, r51, r52, r53, r54) in out.(0ul) <- o0; out.(1ul) <- o1; out.(2ul) <- o2; out.(3ul) <- o3; out.(4ul) <- o4 #pop-options inline_for_extraction noextract val fadd_mul_r: #w:lanes -> acc:felem w -> f1:felem w -> p:precomp_r w -> Stack unit (requires fun h -> live h acc /\ live h f1 /\ live h p /\ felem_fits h acc (2,2,2,2,2) /\ felem_fits h f1 (1,1,1,1,1) /\ fmul_precomp_r_pre h p) (ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\ felem_fits h1 acc (1,2,1,1,2) /\ feval h1 acc == LSeq.map2 (Vec.pfmul) (LSeq.map2 (Vec.pfadd) (feval h0 acc) (feval h0 f1)) (feval h0 (gsub p 0ul 5ul))) let fadd_mul_r #w out f1 p = let r = sub p 0ul 5ul in let r5 = sub p 5ul 5ul in let r0 = r.(0ul) in let r1 = r.(1ul) in let r2 = r.(2ul) in let r3 = r.(3ul) in let r4 = r.(4ul) in let r50 = r5.(0ul) in let r51 = r5.(1ul) in let r52 = r5.(2ul) in let r53 = r5.(3ul) in let r54 = r5.(4ul) in let f10 = f1.(0ul) in let f11 = f1.(1ul) in let f12 = f1.(2ul) in let f13 = f1.(3ul) in let f14 = f1.(4ul) in let a0 = out.(0ul) in let a1 = out.(1ul) in let a2 = out.(2ul) in let a3 = out.(3ul) in let a4 = out.(4ul) in let (o0, o1, o2, o3, o4) = fadd_mul_r5 #w (a0, a1, a2, a3, a4) (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r50, r51, r52, r53, r54) in out.(0ul) <- o0; out.(1ul) <- o1; out.(2ul) <- o2; out.(3ul) <- o3; out.(4ul) <- o4 inline_for_extraction noextract val fmul_rn: #w:lanes -> out:felem w -> f1:felem w -> p:precomp_r w -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h p /\ (let rn = gsub p 10ul 5ul in let rn_5 = gsub p 15ul 5ul in felem_fits h f1 (3,3,3,3,3) /\ felem_fits h rn (2,2,2,2,2) /\ felem_fits h rn_5 (10,10,10,10,10) /\ as_tup5 h rn_5 == precomp_r5 (as_tup5 h rn))) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ felem_fits h1 out (1,2,1,1,2) /\ feval h1 out == LSeq.map2 Vec.pfmul (feval h0 f1) (feval h0 (gsub p 10ul 5ul))) let fmul_rn #w out f1 p = let rn = sub p 10ul 5ul in let rn5 = sub p 15ul 5ul in fmul_r #w out f1 rn rn5 inline_for_extraction noextract val reduce_felem: #w:lanes -> f:felem w -> Stack unit (requires fun h -> live h f /\ felem_fits h f (2,2,2,2,2)) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (1, 1, 1, 1, 1) /\ (fas_nat h1 f).[0] == (feval h0 f).[0]) let reduce_felem #w f = let f0 = f.(0ul) in let f1 = f.(1ul) in let f2 = f.(2ul) in let f3 = f.(3ul) in let f4 = f.(4ul) in let (f0, f1, f2, f3, f4) = reduce_felem5 (f0, f1, f2, f3, f4) in f.(0ul) <- f0; f.(1ul) <- f1; f.(2ul) <- f2; f.(3ul) <- f3; f.(4ul) <- f4 inline_for_extraction noextract val precompute_shift_reduce: #w:lanes -> f1:felem w -> f2:felem w -> Stack unit (requires fun h -> live h f1 /\ live h f2) (ensures fun h0 _ h1 -> modifies (loc f1) h0 h1 /\ as_tup5 h1 f1 == precomp_r5 (as_tup5 h0 f2)) let precompute_shift_reduce #w f1 f2 = let f20 = f2.(0ul) in let f21 = f2.(1ul) in let f22 = f2.(2ul) in let f23 = f2.(3ul) in let f24 = f2.(4ul) in f1.(0ul) <- vec_smul_mod f20 (u64 5); f1.(1ul) <- vec_smul_mod f21 (u64 5); f1.(2ul) <- vec_smul_mod f22 (u64 5); f1.(3ul) <- vec_smul_mod f23 (u64 5); f1.(4ul) <- vec_smul_mod f24 (u64 5) inline_for_extraction noextract val load_felem: #w:lanes -> f:felem w -> lo:uint64xN w -> hi:uint64xN w -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (1, 1, 1, 1, 1) /\ felem_less h1 f (pow2 128) /\ feval h1 f == LSeq.createi #Vec.pfelem w (fun i -> (uint64xN_v hi).[i] * pow2 64 + (uint64xN_v lo).[i])) let load_felem #w f lo hi = let (f0, f1, f2, f3, f4) = load_felem5 #w lo hi in load_felem5_lemma #w lo hi; f.(0ul) <- f0; f.(1ul) <- f1; f.(2ul) <- f2; f.(3ul) <- f3; f.(4ul) <- f4 #push-options "--max_fuel 2" inline_for_extraction noextract val load_precompute_r1: p:precomp_r 1 -> r0:uint64 -> r1:uint64 -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ load_precompute_r_post h1 p /\ (assert_norm (pow2 64 * pow2 64 = pow2 128); feval h1 (gsub p 0ul 5ul) == LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0))) let load_precompute_r1 p r0 r1 = let r = sub p 0ul 5ul in let r5 = sub p 5ul 5ul in let rn = sub p 10ul 5ul in let rn_5 = sub p 15ul 5ul in let r_vec0 = vec_load r0 1 in let r_vec1 = vec_load r1 1 in let h0 = ST.get () in load_felem r r_vec0 r_vec1; let h1 = ST.get () in LSeq.eq_intro (LSeq.createi #Vec.pfelem 1 (fun i -> (uint64xN_v r_vec1).[i] * pow2 64 + (uint64xN_v r_vec0).[i])) (LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0)); assert (feval h1 r == LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0)); precompute_shift_reduce r5 r; copy_felem #_ #(1,1,1,1,1) rn r; copy_felem #_ #(5,5,5,5,5) rn_5 r5 inline_for_extraction noextract val load_precompute_r2: p:precomp_r 2 -> r0:uint64 -> r1:uint64 -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ load_precompute_r_post h1 p /\ (assert_norm (pow2 64 * pow2 64 = pow2 128); feval h1 (gsub p 0ul 5ul) == LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0))) let load_precompute_r2 p r0 r1 = let r = sub p 0ul 5ul in let r5 = sub p 5ul 5ul in let rn = sub p 10ul 5ul in let rn_5 = sub p 15ul 5ul in let r_vec0 = vec_load r0 2 in let r_vec1 = vec_load r1 2 in let h0 = ST.get () in load_felem r r_vec0 r_vec1; let h1 = ST.get () in LSeq.eq_intro (LSeq.createi #Vec.pfelem 2 (fun i -> (uint64xN_v r_vec1).[i] * pow2 64 + (uint64xN_v r_vec0).[i])) (LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0)); assert (feval h1 r == LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0)); precompute_shift_reduce r5 r; let h2 = ST.get () in fmul_r rn r r r5; let h3 = ST.get () in LSeq.eq_intro (feval h3 rn) (Vec.compute_rw (feval h2 r).[0]); precompute_shift_reduce rn_5 rn inline_for_extraction noextract val load_precompute_r4: p:precomp_r 4 -> r0:uint64 -> r1:uint64 -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ load_precompute_r_post h1 p /\ (assert_norm (pow2 64 * pow2 64 = pow2 128); feval h1 (gsub p 0ul 5ul) ==
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Impl.Poly1305.Lemmas.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Poly1305.Field32xN.fst" }
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": "Vec" }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305", "short_module": null }, { "abbrev": 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": 2, "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
p: Hacl.Impl.Poly1305.Field32xN.precomp_r 4 -> r0: Lib.IntTypes.uint64 -> r1: Lib.IntTypes.uint64 -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Poly1305.Field32xN.precomp_r", "Lib.IntTypes.uint64", "Hacl.Impl.Poly1305.Field32xN.precompute_shift_reduce", "Prims.unit", "Lib.Sequence.eq_intro", "Hacl.Spec.Poly1305.Vec.pfelem", "Hacl.Impl.Poly1305.Field32xN.feval", "Hacl.Spec.Poly1305.Vec.compute_rw", "Hacl.Impl.Poly1305.Field32xN.op_String_Access", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.Poly1305.Field32xN.fmul_r", "Prims._assert", "Prims.eq2", "Lib.Sequence.lseq", "Lib.Sequence.create", "Prims.op_Addition", "FStar.Mul.op_Star", "Lib.IntTypes.uint_v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.pow2", "Lib.Sequence.createi", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Poly1305.Field32xN.uint64xN_v", "Hacl.Impl.Poly1305.Field32xN.load_felem", "Lib.IntVector.vec_t", "Lib.IntTypes.int_t", "Lib.IntVector.vec_v", "Lib.IntVector.vec_load", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t" ]
[]
false
true
false
false
false
let load_precompute_r4 p r0 r1 =
let r = sub p 0ul 5ul in let r5 = sub p 5ul 5ul in let rn = sub p 10ul 5ul in let rn_5 = sub p 15ul 5ul in let r_vec0 = vec_load r0 4 in let r_vec1 = vec_load r1 4 in let h0 = ST.get () in load_felem r r_vec0 r_vec1; let h1 = ST.get () in LSeq.eq_intro (LSeq.createi #Vec.pfelem 4 (fun i -> (uint64xN_v r_vec1).[ i ] * pow2 64 + (uint64xN_v r_vec0).[ i ])) (LSeq.create 4 (uint_v r1 * pow2 64 + uint_v r0)); assert (feval h1 r == LSeq.create 4 (uint_v r1 * pow2 64 + uint_v r0)); precompute_shift_reduce r5 r; fmul_r rn r r r5; precompute_shift_reduce rn_5 rn; fmul_r rn rn rn rn_5; let h3 = ST.get () in LSeq.eq_intro (feval h3 rn) (Vec.compute_rw (feval h1 r).[ 0 ]); precompute_shift_reduce rn_5 rn
false
Vale.X64.InsAes.fsti
Vale.X64.InsAes.va_quick_VPclmulqdq
val va_quick_VPclmulqdq (dst src1 src2: va_operand_xmm) (src1Hi src2Hi: bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi))
val va_quick_VPclmulqdq (dst src1 src2: va_operand_xmm) (src1Hi src2Hi: bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi))
let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)) = (va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi src2Hi))
{ "file_name": "obj/Vale.X64.InsAes.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 12, "end_line": 106, "start_col": 0, "start_line": 101 }
module Vale.X64.InsAes open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.Decls open Vale.X64.QuickCode open Vale.X64.CPU_Features_s //-- Pclmulqdq val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_code val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_pbool val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst))) (Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (()))) val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) : (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) = (va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi)) //-- //-- VPclmulqdq val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_code val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))) (Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2))))) ==> va_k va_sM (()))) val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.InsAes.fsti" }
[ { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "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": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> src1: Vale.X64.Decls.va_operand_xmm -> src2: Vale.X64.Decls.va_operand_xmm -> src1Hi: Prims.bool -> src2Hi: Prims.bool -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.X64.InsAes.va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Prims.bool", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.X64.InsAes.va_code_VPclmulqdq", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_mod_xmm", "Prims.Nil", "Vale.X64.InsAes.va_wp_VPclmulqdq", "Vale.X64.InsAes.va_wpProof_VPclmulqdq", "Vale.X64.QuickCode.va_quickCode" ]
[]
false
false
false
false
false
let va_quick_VPclmulqdq (dst src1 src2: va_operand_xmm) (src1Hi src2Hi: bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)) =
(va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi src2Hi))
false
Spec.SHA3.Incremental.fst
Spec.SHA3.Incremental.update_is_update_multi
val update_is_update_multi (a: keccak_alg) (inp: bytes{S.length inp == block_length a}) (s: words_state a) : Lemma (Spec.SHA3.absorb_inner (rate a / 8) inp s == update_multi a s () inp)
val update_is_update_multi (a: keccak_alg) (inp: bytes{S.length inp == block_length a}) (s: words_state a) : Lemma (Spec.SHA3.absorb_inner (rate a / 8) inp s == update_multi a s () inp)
let update_is_update_multi (a:keccak_alg) (inp:bytes{S.length inp == block_length a}) (s:words_state a) : Lemma (Spec.SHA3.absorb_inner (rate a/8) inp s == update_multi a s () inp) = let rateInBytes = rate a/8 in let f = Spec.SHA3.absorb_inner rateInBytes in let bs = block_length a in let f' = Lib.Sequence.repeat_blocks_f bs inp f 1 in assert (bs == rateInBytes); calc (==) { update_multi a s () inp; (==) { } Lib.Sequence.repeat_blocks_multi #_ #(words_state a) rateInBytes inp f s; (==) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) bs inp f s } (let len = S.length inp in let nb = len / bs in Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f bs inp f nb) s); (==) { Loops.unfold_repeati 1 f' s 0; Loops.eq_repeati0 1 f' s } f' 0 s; (==) { assert (Seq.slice inp (0 * bs) (0 * bs + bs) `S.equal` inp) } f inp s; }
{ "file_name": "specs/lemmas/Spec.SHA3.Incremental.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 41, "start_col": 0, "start_line": 20 }
module Spec.SHA3.Incremental module S = FStar.Seq open Spec.Agile.Hash open Spec.Hash.Definitions open Spec.Hash.Incremental.Definitions open Spec.Hash.Lemmas friend Spec.Agile.Hash open FStar.Mul module Loops = Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti open Lib.IntTypes #set-options "--fuel 0 --ifuel 0 --z3rlimit 200"
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.Definitions.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fst.checked", "Spec.Agile.Hash.fst.checked", "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Spec.SHA3.Incremental.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Incremental.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "Spec.Hash.Incremental.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": 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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.keccak_alg -> inp: Spec.Hash.Definitions.bytes{FStar.Seq.Base.length inp == Spec.Hash.Definitions.block_length a} -> s: Spec.Hash.Definitions.words_state a -> FStar.Pervasives.Lemma (ensures Spec.SHA3.absorb_inner (Spec.Hash.Definitions.rate a / 8) inp s == Spec.Agile.Hash.update_multi a s () inp)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.Hash.Definitions.keccak_alg", "Spec.Hash.Definitions.bytes", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_disEquality", "FStar.Seq.Base.length", "Lib.IntTypes.uint8", "Spec.Hash.Definitions.block_length", "Spec.Hash.Definitions.words_state", "FStar.Calc.calc_finish", "Spec.Agile.Hash.update_multi", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Lib.LoopCombinators.repeati", "Lib.Sequence.repeat_blocks_f", "Spec.SHA3.state", "Prims.op_Division", "Prims.nat", "Lib.Sequence.repeat_blocks_multi", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Lib.Sequence.lemma_repeat_blocks_multi", "Lib.LoopCombinators.eq_repeati0", "Lib.LoopCombinators.unfold_repeati", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "FStar.Mul.op_Star", "Prims.op_Addition", "Prims.op_LessThan", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.nonzero", "Lib.IntTypes.U8", "Spec.SHA3.absorb_inner", "Spec.Hash.Definitions.rate", "Prims.l_True", "Lib.Sequence.seq", "Lib.IntTypes.uint64", "Spec.Hash.Definitions.word", "Spec.Hash.Definitions.state_word_length", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let update_is_update_multi (a: keccak_alg) (inp: bytes{S.length inp == block_length a}) (s: words_state a) : Lemma (Spec.SHA3.absorb_inner (rate a / 8) inp s == update_multi a s () inp) =
let rateInBytes = rate a / 8 in let f = Spec.SHA3.absorb_inner rateInBytes in let bs = block_length a in let f' = Lib.Sequence.repeat_blocks_f bs inp f 1 in assert (bs == rateInBytes); calc ( == ) { update_multi a s () inp; ( == ) { () } Lib.Sequence.repeat_blocks_multi #_ #(words_state a) rateInBytes inp f s; ( == ) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) bs inp f s } (let len = S.length inp in let nb = len / bs in Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f bs inp f nb) s); ( == ) { (Loops.unfold_repeati 1 f' s 0; Loops.eq_repeati0 1 f' s) } f' 0 s; ( == ) { assert ((Seq.slice inp (0 * bs) (0 * bs + bs)) `S.equal` inp) } f inp s; }
false
Vale.X64.InsAes.fsti
Vale.X64.InsAes.va_quick_Pclmulqdq
val va_quick_Pclmulqdq (dst src: va_operand_xmm) (dstHi srcHi: bool) : (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi))
val va_quick_Pclmulqdq (dst src: va_operand_xmm) (dstHi srcHi: bool) : (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi))
let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) : (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) = (va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
{ "file_name": "obj/Vale.X64.InsAes.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 85, "end_line": 56, "start_col": 0, "start_line": 53 }
module Vale.X64.InsAes open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.Decls open Vale.X64.QuickCode open Vale.X64.CPU_Features_s //-- Pclmulqdq val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_code val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_pbool val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst))) (Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (()))) val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.InsAes.fsti" }
[ { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "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": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> src: Vale.X64.Decls.va_operand_xmm -> dstHi: Prims.bool -> srcHi: Prims.bool -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.X64.InsAes.va_code_Pclmulqdq dst src dstHi srcHi)
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Prims.bool", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.X64.InsAes.va_code_Pclmulqdq", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_mod_xmm", "Prims.Nil", "Vale.X64.InsAes.va_wp_Pclmulqdq", "Vale.X64.InsAes.va_wpProof_Pclmulqdq", "Vale.X64.QuickCode.va_quickCode" ]
[]
false
false
false
false
false
let va_quick_Pclmulqdq (dst src: va_operand_xmm) (dstHi srcHi: bool) : (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) =
(va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi))
false
Vale.X64.InsAes.fsti
Vale.X64.InsAes.va_quick_AESNI_enc_last
val va_quick_AESNI_enc_last (dst src: va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc_last dst src))
val va_quick_AESNI_enc_last (dst src: va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc_last dst src))
let va_quick_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc_last dst src)) = (va_QProc (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc_last dst src) (va_wpProof_AESNI_enc_last dst src))
{ "file_name": "obj/Vale.X64.InsAes.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 49, "end_line": 220, "start_col": 0, "start_line": 217 }
module Vale.X64.InsAes open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.Decls open Vale.X64.QuickCode open Vale.X64.CPU_Features_s //-- Pclmulqdq val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_code val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_pbool val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst))) (Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (()))) val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) : (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) = (va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi)) //-- //-- VPclmulqdq val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_code val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))) (Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2))))) ==> va_k va_sM (()))) val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)) = (va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi src2Hi)) //-- //-- AESNI_enc val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM (()))) val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src)) = (va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src) (va_wpProof_AESNI_enc dst src)) //-- //-- VAESNI_enc val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_code val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_pbool val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (()))) val va_wpProof_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VAESNI_enc dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) = (va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2)) //-- //-- AESNI_enc_last val va_code_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code val va_codegen_success_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool val va_lemma_AESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_enc_last dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) ==> va_k va_sM (()))) val va_wpProof_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AESNI_enc_last dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.InsAes.fsti" }
[ { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "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": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> src: Vale.X64.Decls.va_operand_xmm -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.X64.InsAes.va_code_AESNI_enc_last dst src)
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.X64.InsAes.va_code_AESNI_enc_last", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_mod_xmm", "Prims.Nil", "Vale.X64.InsAes.va_wp_AESNI_enc_last", "Vale.X64.InsAes.va_wpProof_AESNI_enc_last", "Vale.X64.QuickCode.va_quickCode" ]
[]
false
false
false
false
false
let va_quick_AESNI_enc_last (dst src: va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc_last dst src)) =
(va_QProc (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc_last dst src) (va_wpProof_AESNI_enc_last dst src))
false
Vale.X64.InsAes.fsti
Vale.X64.InsAes.va_quick_VAESNI_enc
val va_quick_VAESNI_enc (dst src1 src2: va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc dst src1 src2))
val va_quick_VAESNI_enc (dst src1 src2: va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc dst src1 src2))
let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) = (va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2))
{ "file_name": "obj/Vale.X64.InsAes.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 57, "end_line": 184, "start_col": 0, "start_line": 181 }
module Vale.X64.InsAes open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.Decls open Vale.X64.QuickCode open Vale.X64.CPU_Features_s //-- Pclmulqdq val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_code val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_pbool val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst))) (Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (()))) val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) : (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) = (va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi)) //-- //-- VPclmulqdq val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_code val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))) (Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2))))) ==> va_k va_sM (()))) val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)) = (va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi src2Hi)) //-- //-- AESNI_enc val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM (()))) val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src)) = (va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src) (va_wpProof_AESNI_enc dst src)) //-- //-- VAESNI_enc val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_code val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_pbool val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (()))) val va_wpProof_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VAESNI_enc dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.InsAes.fsti" }
[ { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "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": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> src1: Vale.X64.Decls.va_operand_xmm -> src2: Vale.X64.Decls.va_operand_xmm -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.X64.InsAes.va_code_VAESNI_enc dst src1 src2)
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.X64.InsAes.va_code_VAESNI_enc", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_mod_xmm", "Prims.Nil", "Vale.X64.InsAes.va_wp_VAESNI_enc", "Vale.X64.InsAes.va_wpProof_VAESNI_enc", "Vale.X64.QuickCode.va_quickCode" ]
[]
false
false
false
false
false
let va_quick_VAESNI_enc (dst src1 src2: va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) =
(va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2))
false
Vale.X64.InsAes.fsti
Vale.X64.InsAes.va_quick_AESNI_enc
val va_quick_AESNI_enc (dst src: va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src))
val va_quick_AESNI_enc (dst src: va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src))
let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src)) = (va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src) (va_wpProof_AESNI_enc dst src))
{ "file_name": "obj/Vale.X64.InsAes.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 143, "start_col": 0, "start_line": 140 }
module Vale.X64.InsAes open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.Decls open Vale.X64.QuickCode open Vale.X64.CPU_Features_s //-- Pclmulqdq val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_code val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_pbool val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst))) (Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (()))) val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) : (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) = (va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi)) //-- //-- VPclmulqdq val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_code val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))) (Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2))))) ==> va_k va_sM (()))) val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)) = (va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi src2Hi)) //-- //-- AESNI_enc val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM (()))) val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.InsAes.fsti" }
[ { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "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": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> src: Vale.X64.Decls.va_operand_xmm -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.X64.InsAes.va_code_AESNI_enc dst src)
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.X64.InsAes.va_code_AESNI_enc", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_mod_xmm", "Prims.Nil", "Vale.X64.InsAes.va_wp_AESNI_enc", "Vale.X64.InsAes.va_wpProof_AESNI_enc", "Vale.X64.QuickCode.va_quickCode" ]
[]
false
false
false
false
false
let va_quick_AESNI_enc (dst src: va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src)) =
(va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src) (va_wpProof_AESNI_enc dst src))
false
Hacl.Impl.Poly1305.Field32xN.fst
Hacl.Impl.Poly1305.Field32xN.load_precompute_r2
val load_precompute_r2: p:precomp_r 2 -> r0:uint64 -> r1:uint64 -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ load_precompute_r_post h1 p /\ (assert_norm (pow2 64 * pow2 64 = pow2 128); feval h1 (gsub p 0ul 5ul) == LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0)))
val load_precompute_r2: p:precomp_r 2 -> r0:uint64 -> r1:uint64 -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ load_precompute_r_post h1 p /\ (assert_norm (pow2 64 * pow2 64 = pow2 128); feval h1 (gsub p 0ul 5ul) == LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0)))
let load_precompute_r2 p r0 r1 = let r = sub p 0ul 5ul in let r5 = sub p 5ul 5ul in let rn = sub p 10ul 5ul in let rn_5 = sub p 15ul 5ul in let r_vec0 = vec_load r0 2 in let r_vec1 = vec_load r1 2 in let h0 = ST.get () in load_felem r r_vec0 r_vec1; let h1 = ST.get () in LSeq.eq_intro (LSeq.createi #Vec.pfelem 2 (fun i -> (uint64xN_v r_vec1).[i] * pow2 64 + (uint64xN_v r_vec0).[i])) (LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0)); assert (feval h1 r == LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0)); precompute_shift_reduce r5 r; let h2 = ST.get () in fmul_r rn r r r5; let h3 = ST.get () in LSeq.eq_intro (feval h3 rn) (Vec.compute_rw (feval h2 r).[0]); precompute_shift_reduce rn_5 rn
{ "file_name": "code/poly1305/Hacl.Impl.Poly1305.Field32xN.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 512, "start_col": 0, "start_line": 490 }
module Hacl.Impl.Poly1305.Field32xN open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector include Hacl.Spec.Poly1305.Field32xN open Hacl.Spec.Poly1305.Field32xN.Lemmas open Hacl.Impl.Poly1305.Lemmas module Vec = Hacl.Spec.Poly1305.Vec module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BSeq = Lib.ByteSequence #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50 --using_facts_from '* -FStar.Seq'" inline_for_extraction noextract let felem (w:lanes) = lbuffer (uint64xN w) 5ul inline_for_extraction noextract let felem_wide (w:lanes) = felem w inline_for_extraction noextract let precomp_r (w:lanes) = lbuffer (uint64xN w) 20ul unfold noextract let op_String_Access #a #len = LSeq.index #a #len noextract val as_tup5: #w:lanes -> h:mem -> f:felem w -> GTot (felem5 w) let as_tup5 #w h f = let s = as_seq h f in let s0 = s.[0] in let s1 = s.[1] in let s2 = s.[2] in let s3 = s.[3] in let s4 = s.[4] in (s0,s1,s2,s3,s4) noextract val felem_fits: #w:lanes -> h:mem -> f:felem w -> m:scale32_5 -> Type0 let felem_fits #w h f m = felem_fits5 (as_tup5 h f) m noextract val felem_wide_fits: #w:lanes -> h:mem -> f:felem w -> m:scale32_5 -> Type0 let felem_wide_fits #w h f m = felem_wide_fits5 (as_tup5 h f) m noextract let feval (#w:lanes) (h:mem) (f:felem w) : GTot (LSeq.lseq Vec.pfelem w) = feval5 (as_tup5 h f) noextract let fas_nat (#w:lanes) (h:mem) (f:felem w) : GTot (LSeq.lseq nat w) = fas_nat5 (as_tup5 h f) noextract let felem_less (#w:lanes) (h:mem) (f:felem w) (max:nat) : Type0 = felem_less5 (as_tup5 h f) max val lemma_feval_is_fas_nat: #w:lanes -> h:mem -> f:felem w -> Lemma (requires felem_less h f (pow2 128)) (ensures (forall (i:nat). i < w ==> (feval h f).[i] == (fas_nat h f).[i])) let lemma_feval_is_fas_nat #w h f = lemma_feval_is_fas_nat (as_tup5 h f) inline_for_extraction noextract val fmul_precomp_r_pre: #w:lanes -> h:mem -> precomp:precomp_r w -> Type0 let fmul_precomp_r_pre #w h precomp = let r = gsub precomp 0ul 5ul in let r_5 = gsub precomp 5ul 5ul in felem_fits h r (1, 1, 1, 1, 1) /\ felem_fits h r_5 (5, 5, 5, 5, 5) /\ as_tup5 h r_5 == precomp_r5 (as_tup5 h r) noextract val load_precompute_r_post: #w:lanes -> h:mem -> p:precomp_r w -> Type0 let load_precompute_r_post #w h p = assert_norm (pow2 128 < Vec.prime); let r = gsub p 0ul 5ul in let rn = gsub p 10ul 5ul in let rn_5 = gsub p 15ul 5ul in fmul_precomp_r_pre h p /\ felem_fits h rn (2, 2, 2, 2, 2) /\ felem_fits h rn_5 (10, 10, 10, 10, 10) /\ as_tup5 h rn_5 == precomp_r5 (as_tup5 h rn) /\ feval h rn == Vec.compute_rw (feval h r).[0] inline_for_extraction noextract val create_felem: w:lanes -> StackInline (felem w) (requires fun h -> True) (ensures fun h0 b h1 -> stack_allocated b h0 h1 (LSeq.create 5 (zero w)) /\ feval h1 b == LSeq.create w 0) let create_felem w = let r = create 5ul (zero w) in let h1 = ST.get () in LSeq.eq_intro (feval h1 r) (LSeq.create w 0); r #push-options "--z3rlimit 100" inline_for_extraction noextract val set_bit: #w:lanes -> f:felem w -> i:size_t{size_v i <= 128} -> Stack unit (requires fun h -> live h f /\ felem_fits h f (1, 1, 1, 1, 1) /\ felem_less #w h f (pow2 (v i))) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (1, 1, 1, 1, 1) /\ (Math.Lemmas.pow2_le_compat 128 (v i); feval h1 f == LSeq.map (Vec.pfadd (pow2 (v i))) (feval h0 f))) let set_bit #w f i = let b = u64 1 <<. (i %. 26ul) in let mask = vec_load b w in let fi = f.(i /. 26ul) in let h0 = ST.get () in f.(i /. 26ul) <- vec_or fi mask; set_bit5_lemma (as_seq h0 f) (v i) #pop-options inline_for_extraction noextract val set_bit128: #w:lanes -> f:felem w -> Stack unit (requires fun h -> live h f /\ felem_fits h f (1, 1, 1, 1, 1) /\ felem_less #w h f (pow2 128)) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (1, 1, 1, 1, 1) /\ feval h1 f == LSeq.map (Vec.pfadd (pow2 128)) (feval h0 f)) let set_bit128 #w f = let b = u64 0x1000000 in assert_norm (0x1000000 = pow2 24); assert (v b == v (u64 1 <<. 24ul)); let mask = vec_load b w in let f4 = f.(4ul) in let h0 = ST.get () in f.(4ul) <- vec_or f4 mask; set_bit5_lemma (as_seq h0 f) 128 inline_for_extraction noextract val set_zero: #w:lanes -> f:felem w -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (0, 0, 0, 0, 0) /\ feval h1 f == LSeq.create w 0) let set_zero #w f = f.(0ul) <- zero w; f.(1ul) <- zero w; f.(2ul) <- zero w; f.(3ul) <- zero w; f.(4ul) <- zero w; let h1 = ST.get () in LSeq.eq_intro (feval h1 f) (LSeq.create w 0) inline_for_extraction noextract val copy_felem: #w:lanes -> #m:scale32_5 -> f1:felem w -> f2:felem w -> Stack unit (requires fun h -> live h f1 /\ live h f2 /\ disjoint f1 f2 /\ felem_fits h f2 m) (ensures fun h0 _ h1 -> modifies (loc f1) h0 h1 /\ felem_fits h1 f1 m /\ as_tup5 h1 f1 == as_tup5 h0 f2) let copy_felem #w #m f1 f2 = f1.(0ul) <- f2.(0ul); f1.(1ul) <- f2.(1ul); f1.(2ul) <- f2.(2ul); f1.(3ul) <- f2.(3ul); f1.(4ul) <- f2.(4ul) inline_for_extraction noextract val fadd: #w:lanes -> out:felem w -> f1:felem w -> f2:felem w -> Stack unit (requires fun h -> live h f1 /\ live h f2 /\ live h out /\ felem_fits h f1 (2,2,2,2,2) /\ felem_fits h f2 (1,1,1,1,1)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ //as_tup5 h1 out == fadd5 (as_tup5 h0 f1) (as_tup5 h0 f2) /\ felem_fits h1 out (3,3,3,3,3) /\ feval h1 out == LSeq.map2 Vec.pfadd (feval h0 f1) (feval h0 f2)) let fadd #w out f1 f2 = let f10 = f1.(0ul) in let f11 = f1.(1ul) in let f12 = f1.(2ul) in let f13 = f1.(3ul) in let f14 = f1.(4ul) in let f20 = f2.(0ul) in let f21 = f2.(1ul) in let f22 = f2.(2ul) in let f23 = f2.(3ul) in let f24 = f2.(4ul) in let (o0,o1,o2,o3,o4) = fadd5 #w (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in out.(0ul) <- o0; out.(1ul) <- o1; out.(2ul) <- o2; out.(3ul) <- o3; out.(4ul) <- o4 #push-options "--max_fuel 1" inline_for_extraction noextract val fmul_r: #w:lanes -> out:felem w -> f1:felem w -> r:felem w -> r5:felem w -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h r /\ live h r5 /\ felem_fits h f1 (3,3,3,3,3) /\ felem_fits h r (2,2,2,2,2) /\ felem_fits h r5 (10,10,10,10,10) /\ as_tup5 h r5 == precomp_r5 (as_tup5 h r)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ felem_fits h1 out (1,2,1,1,2) /\ feval h1 out == LSeq.map2 (Vec.pfmul) (feval h0 f1) (feval h0 r)) let fmul_r #w out f1 r r5 = let r0 = r.(0ul) in let r1 = r.(1ul) in let r2 = r.(2ul) in let r3 = r.(3ul) in let r4 = r.(4ul) in let r50 = r5.(0ul) in let r51 = r5.(1ul) in let r52 = r5.(2ul) in let r53 = r5.(3ul) in let r54 = r5.(4ul) in let f10 = f1.(0ul) in let f11 = f1.(1ul) in let f12 = f1.(2ul) in let f13 = f1.(3ul) in let f14 = f1.(4ul) in let (o0, o1, o2, o3, o4) = fmul_r5 #w (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r50, r51, r52, r53, r54) in out.(0ul) <- o0; out.(1ul) <- o1; out.(2ul) <- o2; out.(3ul) <- o3; out.(4ul) <- o4 #pop-options inline_for_extraction noextract val fadd_mul_r: #w:lanes -> acc:felem w -> f1:felem w -> p:precomp_r w -> Stack unit (requires fun h -> live h acc /\ live h f1 /\ live h p /\ felem_fits h acc (2,2,2,2,2) /\ felem_fits h f1 (1,1,1,1,1) /\ fmul_precomp_r_pre h p) (ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\ felem_fits h1 acc (1,2,1,1,2) /\ feval h1 acc == LSeq.map2 (Vec.pfmul) (LSeq.map2 (Vec.pfadd) (feval h0 acc) (feval h0 f1)) (feval h0 (gsub p 0ul 5ul))) let fadd_mul_r #w out f1 p = let r = sub p 0ul 5ul in let r5 = sub p 5ul 5ul in let r0 = r.(0ul) in let r1 = r.(1ul) in let r2 = r.(2ul) in let r3 = r.(3ul) in let r4 = r.(4ul) in let r50 = r5.(0ul) in let r51 = r5.(1ul) in let r52 = r5.(2ul) in let r53 = r5.(3ul) in let r54 = r5.(4ul) in let f10 = f1.(0ul) in let f11 = f1.(1ul) in let f12 = f1.(2ul) in let f13 = f1.(3ul) in let f14 = f1.(4ul) in let a0 = out.(0ul) in let a1 = out.(1ul) in let a2 = out.(2ul) in let a3 = out.(3ul) in let a4 = out.(4ul) in let (o0, o1, o2, o3, o4) = fadd_mul_r5 #w (a0, a1, a2, a3, a4) (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r50, r51, r52, r53, r54) in out.(0ul) <- o0; out.(1ul) <- o1; out.(2ul) <- o2; out.(3ul) <- o3; out.(4ul) <- o4 inline_for_extraction noextract val fmul_rn: #w:lanes -> out:felem w -> f1:felem w -> p:precomp_r w -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h p /\ (let rn = gsub p 10ul 5ul in let rn_5 = gsub p 15ul 5ul in felem_fits h f1 (3,3,3,3,3) /\ felem_fits h rn (2,2,2,2,2) /\ felem_fits h rn_5 (10,10,10,10,10) /\ as_tup5 h rn_5 == precomp_r5 (as_tup5 h rn))) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ felem_fits h1 out (1,2,1,1,2) /\ feval h1 out == LSeq.map2 Vec.pfmul (feval h0 f1) (feval h0 (gsub p 10ul 5ul))) let fmul_rn #w out f1 p = let rn = sub p 10ul 5ul in let rn5 = sub p 15ul 5ul in fmul_r #w out f1 rn rn5 inline_for_extraction noextract val reduce_felem: #w:lanes -> f:felem w -> Stack unit (requires fun h -> live h f /\ felem_fits h f (2,2,2,2,2)) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (1, 1, 1, 1, 1) /\ (fas_nat h1 f).[0] == (feval h0 f).[0]) let reduce_felem #w f = let f0 = f.(0ul) in let f1 = f.(1ul) in let f2 = f.(2ul) in let f3 = f.(3ul) in let f4 = f.(4ul) in let (f0, f1, f2, f3, f4) = reduce_felem5 (f0, f1, f2, f3, f4) in f.(0ul) <- f0; f.(1ul) <- f1; f.(2ul) <- f2; f.(3ul) <- f3; f.(4ul) <- f4 inline_for_extraction noextract val precompute_shift_reduce: #w:lanes -> f1:felem w -> f2:felem w -> Stack unit (requires fun h -> live h f1 /\ live h f2) (ensures fun h0 _ h1 -> modifies (loc f1) h0 h1 /\ as_tup5 h1 f1 == precomp_r5 (as_tup5 h0 f2)) let precompute_shift_reduce #w f1 f2 = let f20 = f2.(0ul) in let f21 = f2.(1ul) in let f22 = f2.(2ul) in let f23 = f2.(3ul) in let f24 = f2.(4ul) in f1.(0ul) <- vec_smul_mod f20 (u64 5); f1.(1ul) <- vec_smul_mod f21 (u64 5); f1.(2ul) <- vec_smul_mod f22 (u64 5); f1.(3ul) <- vec_smul_mod f23 (u64 5); f1.(4ul) <- vec_smul_mod f24 (u64 5) inline_for_extraction noextract val load_felem: #w:lanes -> f:felem w -> lo:uint64xN w -> hi:uint64xN w -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (1, 1, 1, 1, 1) /\ felem_less h1 f (pow2 128) /\ feval h1 f == LSeq.createi #Vec.pfelem w (fun i -> (uint64xN_v hi).[i] * pow2 64 + (uint64xN_v lo).[i])) let load_felem #w f lo hi = let (f0, f1, f2, f3, f4) = load_felem5 #w lo hi in load_felem5_lemma #w lo hi; f.(0ul) <- f0; f.(1ul) <- f1; f.(2ul) <- f2; f.(3ul) <- f3; f.(4ul) <- f4 #push-options "--max_fuel 2" inline_for_extraction noextract val load_precompute_r1: p:precomp_r 1 -> r0:uint64 -> r1:uint64 -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ load_precompute_r_post h1 p /\ (assert_norm (pow2 64 * pow2 64 = pow2 128); feval h1 (gsub p 0ul 5ul) == LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0))) let load_precompute_r1 p r0 r1 = let r = sub p 0ul 5ul in let r5 = sub p 5ul 5ul in let rn = sub p 10ul 5ul in let rn_5 = sub p 15ul 5ul in let r_vec0 = vec_load r0 1 in let r_vec1 = vec_load r1 1 in let h0 = ST.get () in load_felem r r_vec0 r_vec1; let h1 = ST.get () in LSeq.eq_intro (LSeq.createi #Vec.pfelem 1 (fun i -> (uint64xN_v r_vec1).[i] * pow2 64 + (uint64xN_v r_vec0).[i])) (LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0)); assert (feval h1 r == LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0)); precompute_shift_reduce r5 r; copy_felem #_ #(1,1,1,1,1) rn r; copy_felem #_ #(5,5,5,5,5) rn_5 r5 inline_for_extraction noextract val load_precompute_r2: p:precomp_r 2 -> r0:uint64 -> r1:uint64 -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ load_precompute_r_post h1 p /\ (assert_norm (pow2 64 * pow2 64 = pow2 128); feval h1 (gsub p 0ul 5ul) ==
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Impl.Poly1305.Lemmas.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Poly1305.Field32xN.fst" }
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": "Vec" }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305", "short_module": null }, { "abbrev": 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": 2, "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
p: Hacl.Impl.Poly1305.Field32xN.precomp_r 2 -> r0: Lib.IntTypes.uint64 -> r1: Lib.IntTypes.uint64 -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Poly1305.Field32xN.precomp_r", "Lib.IntTypes.uint64", "Hacl.Impl.Poly1305.Field32xN.precompute_shift_reduce", "Prims.unit", "Lib.Sequence.eq_intro", "Hacl.Spec.Poly1305.Vec.pfelem", "Hacl.Impl.Poly1305.Field32xN.feval", "Hacl.Spec.Poly1305.Vec.compute_rw", "Hacl.Impl.Poly1305.Field32xN.op_String_Access", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.Poly1305.Field32xN.fmul_r", "Prims._assert", "Prims.eq2", "Lib.Sequence.lseq", "Lib.Sequence.create", "Prims.op_Addition", "FStar.Mul.op_Star", "Lib.IntTypes.uint_v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.pow2", "Lib.Sequence.createi", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Poly1305.Field32xN.uint64xN_v", "Hacl.Impl.Poly1305.Field32xN.load_felem", "Lib.IntVector.vec_t", "Lib.IntTypes.int_t", "Lib.IntVector.vec_v", "Lib.IntVector.vec_load", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t" ]
[]
false
true
false
false
false
let load_precompute_r2 p r0 r1 =
let r = sub p 0ul 5ul in let r5 = sub p 5ul 5ul in let rn = sub p 10ul 5ul in let rn_5 = sub p 15ul 5ul in let r_vec0 = vec_load r0 2 in let r_vec1 = vec_load r1 2 in let h0 = ST.get () in load_felem r r_vec0 r_vec1; let h1 = ST.get () in LSeq.eq_intro (LSeq.createi #Vec.pfelem 2 (fun i -> (uint64xN_v r_vec1).[ i ] * pow2 64 + (uint64xN_v r_vec0).[ i ])) (LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0)); assert (feval h1 r == LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0)); precompute_shift_reduce r5 r; let h2 = ST.get () in fmul_r rn r r r5; let h3 = ST.get () in LSeq.eq_intro (feval h3 rn) (Vec.compute_rw (feval h2 r).[ 0 ]); precompute_shift_reduce rn_5 rn
false
Vale.X64.InsAes.fsti
Vale.X64.InsAes.va_quick_VAESNI_enc_last
val va_quick_VAESNI_enc_last (dst src1 src2: va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc_last dst src1 src2))
val va_quick_VAESNI_enc_last (dst src1 src2: va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc_last dst src1 src2))
let va_quick_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc_last dst src1 src2)) = (va_QProc (va_code_VAESNI_enc_last dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc_last dst src1 src2) (va_wpProof_VAESNI_enc_last dst src1 src2))
{ "file_name": "obj/Vale.X64.InsAes.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 85, "end_line": 261, "start_col": 0, "start_line": 258 }
module Vale.X64.InsAes open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.Decls open Vale.X64.QuickCode open Vale.X64.CPU_Features_s //-- Pclmulqdq val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_code val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_pbool val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst))) (Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (()))) val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) : (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) = (va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi)) //-- //-- VPclmulqdq val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_code val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))) (Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2))))) ==> va_k va_sM (()))) val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)) = (va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi src2Hi)) //-- //-- AESNI_enc val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM (()))) val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src)) = (va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src) (va_wpProof_AESNI_enc dst src)) //-- //-- VAESNI_enc val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_code val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_pbool val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (()))) val va_wpProof_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VAESNI_enc dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) = (va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2)) //-- //-- AESNI_enc_last val va_code_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code val va_codegen_success_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool val va_lemma_AESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_enc_last dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) ==> va_k va_sM (()))) val va_wpProof_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AESNI_enc_last dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc_last dst src)) = (va_QProc (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc_last dst src) (va_wpProof_AESNI_enc_last dst src)) //-- //-- VAESNI_enc_last val va_code_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_code val va_codegen_success_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_pbool val va_lemma_VAESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VAESNI_enc_last dst src1 src2) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))) (va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (()))) val va_wpProof_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VAESNI_enc_last dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc_last dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.InsAes.fsti" }
[ { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "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": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> src1: Vale.X64.Decls.va_operand_xmm -> src2: Vale.X64.Decls.va_operand_xmm -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.X64.InsAes.va_code_VAESNI_enc_last dst src1 src2)
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.X64.InsAes.va_code_VAESNI_enc_last", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_mod_xmm", "Prims.Nil", "Vale.X64.InsAes.va_wp_VAESNI_enc_last", "Vale.X64.InsAes.va_wpProof_VAESNI_enc_last", "Vale.X64.QuickCode.va_quickCode" ]
[]
false
false
false
false
false
let va_quick_VAESNI_enc_last (dst src1 src2: va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc_last dst src1 src2)) =
(va_QProc (va_code_VAESNI_enc_last dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc_last dst src1 src2) (va_wpProof_VAESNI_enc_last dst src1 src2))
false
Vale.X64.InsAes.fsti
Vale.X64.InsAes.va_quick_AESNI_keygen_assist
val va_quick_AESNI_keygen_assist (dst src: va_operand_xmm) (imm: nat8) : (va_quickCode unit (va_code_AESNI_keygen_assist dst src imm))
val va_quick_AESNI_keygen_assist (dst src: va_operand_xmm) (imm: nat8) : (va_quickCode unit (va_code_AESNI_keygen_assist dst src imm))
let va_quick_AESNI_keygen_assist (dst:va_operand_xmm) (src:va_operand_xmm) (imm:nat8) : (va_quickCode unit (va_code_AESNI_keygen_assist dst src imm)) = (va_QProc (va_code_AESNI_keygen_assist dst src imm) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_keygen_assist dst src imm) (va_wpProof_AESNI_keygen_assist dst src imm))
{ "file_name": "obj/Vale.X64.InsAes.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 89, "end_line": 310, "start_col": 0, "start_line": 307 }
module Vale.X64.InsAes open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.Decls open Vale.X64.QuickCode open Vale.X64.CPU_Features_s //-- Pclmulqdq val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_code val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_pbool val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst))) (Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (()))) val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) : (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) = (va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi)) //-- //-- VPclmulqdq val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_code val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))) (Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2))))) ==> va_k va_sM (()))) val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)) = (va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi src2Hi)) //-- //-- AESNI_enc val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM (()))) val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src)) = (va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src) (va_wpProof_AESNI_enc dst src)) //-- //-- VAESNI_enc val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_code val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_pbool val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (()))) val va_wpProof_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VAESNI_enc dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) = (va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2)) //-- //-- AESNI_enc_last val va_code_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code val va_codegen_success_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool val va_lemma_AESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_enc_last dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) ==> va_k va_sM (()))) val va_wpProof_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AESNI_enc_last dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc_last dst src)) = (va_QProc (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc_last dst src) (va_wpProof_AESNI_enc_last dst src)) //-- //-- VAESNI_enc_last val va_code_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_code val va_codegen_success_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_pbool val va_lemma_VAESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VAESNI_enc_last dst src1 src2) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))) (va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (()))) val va_wpProof_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VAESNI_enc_last dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc_last dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc_last dst src1 src2)) = (va_QProc (va_code_VAESNI_enc_last dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc_last dst src1 src2) (va_wpProof_VAESNI_enc_last dst src1 src2)) //-- //-- AESNI_keygen_assist val va_code_AESNI_keygen_assist : dst:va_operand_xmm -> src:va_operand_xmm -> imm:nat8 -> Tot va_code val va_codegen_success_AESNI_keygen_assist : dst:va_operand_xmm -> src:va_operand_xmm -> imm:nat8 -> Tot va_pbool val va_lemma_AESNI_keygen_assist : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> imm:nat8 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_keygen_assist dst src imm) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src)))) imm) (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src)))) imm) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_AESNI_keygen_assist (dst:va_operand_xmm) (src:va_operand_xmm) (imm:nat8) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src)))) imm) (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src)))) imm) ==> va_k va_sM (()))) val va_wpProof_AESNI_keygen_assist : dst:va_operand_xmm -> src:va_operand_xmm -> imm:nat8 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AESNI_keygen_assist dst src imm va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_keygen_assist dst src imm) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.InsAes.fsti" }
[ { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "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": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> src: Vale.X64.Decls.va_operand_xmm -> imm: Vale.Def.Types_s.nat8 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.X64.InsAes.va_code_AESNI_keygen_assist dst src imm)
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.Def.Types_s.nat8", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.X64.InsAes.va_code_AESNI_keygen_assist", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_mod_xmm", "Prims.Nil", "Vale.X64.InsAes.va_wp_AESNI_keygen_assist", "Vale.X64.InsAes.va_wpProof_AESNI_keygen_assist", "Vale.X64.QuickCode.va_quickCode" ]
[]
false
false
false
false
false
let va_quick_AESNI_keygen_assist (dst src: va_operand_xmm) (imm: nat8) : (va_quickCode unit (va_code_AESNI_keygen_assist dst src imm)) =
(va_QProc (va_code_AESNI_keygen_assist dst src imm) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_keygen_assist dst src imm) (va_wpProof_AESNI_keygen_assist dst src imm))
false
Vale.X64.InsAes.fsti
Vale.X64.InsAes.va_wp_AESNI_keygen_assist
val va_wp_AESNI_keygen_assist (dst src: va_operand_xmm) (imm: nat8) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
val va_wp_AESNI_keygen_assist (dst src: va_operand_xmm) (imm: nat8) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
let va_wp_AESNI_keygen_assist (dst:va_operand_xmm) (src:va_operand_xmm) (imm:nat8) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src)))) imm) (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src)))) imm) ==> va_k va_sM (())))
{ "file_name": "obj/Vale.X64.InsAes.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 10, "end_line": 298, "start_col": 0, "start_line": 286 }
module Vale.X64.InsAes open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.AES.AES_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.Decls open Vale.X64.QuickCode open Vale.X64.CPU_Features_s //-- Pclmulqdq val va_code_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_code val va_codegen_success_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Tot va_pbool val va_lemma_Pclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pclmulqdq dst src dstHi srcHi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if dstHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst))) (Vale.Math.Poly2.Bits_s.of_double32 (if srcHi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ pclmulqdq_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if dstHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 dst)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 dst)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if srcHi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src))))) ==> va_k va_sM (()))) val va_wpProof_Pclmulqdq : dst:va_operand_xmm -> src:va_operand_xmm -> dstHi:bool -> srcHi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pclmulqdq dst src dstHi srcHi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Pclmulqdq (dst:va_operand_xmm) (src:va_operand_xmm) (dstHi:bool) (srcHi:bool) : (va_quickCode unit (va_code_Pclmulqdq dst src dstHi srcHi)) = (va_QProc (va_code_Pclmulqdq dst src dstHi srcHi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_Pclmulqdq dst src dstHi srcHi) (va_wpProof_Pclmulqdq dst src dstHi srcHi)) //-- //-- VPclmulqdq val va_code_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_code val va_codegen_success_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Tot va_pbool val va_lemma_VPclmulqdq : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (if src1Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1))) (Vale.Math.Poly2.Bits_s.of_double32 (if src2Hi then Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2) else Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (pclmulqdq_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.Bits_s.of_double32 (va_if src1Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src1)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src1)))) (Vale.Math.Poly2.Bits_s.of_double32 (va_if src2Hi (fun _ -> Vale.Arch.Types.quad32_double_hi (va_eval_xmm va_s0 src2)) (fun _ -> Vale.Arch.Types.quad32_double_lo (va_eval_xmm va_s0 src2))))) ==> va_k va_sM (()))) val va_wpProof_VPclmulqdq : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> src1Hi:bool -> src2Hi:bool -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPclmulqdq (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (src1Hi:bool) (src2Hi:bool) : (va_quickCode unit (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi)) = (va_QProc (va_code_VPclmulqdq dst src1 src2 src1Hi src2Hi) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VPclmulqdq dst src1 src2 src1Hi src2Hi) (va_wpProof_VPclmulqdq dst src1 src2 src1Hi src2Hi)) //-- //-- AESNI_enc val va_code_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code val va_codegen_success_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool val va_lemma_AESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_enc dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst)))) (va_eval_xmm va_s0 src) ==> va_k va_sM (()))) val va_wpProof_AESNI_enc : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AESNI_enc dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AESNI_enc (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc dst src)) = (va_QProc (va_code_AESNI_enc dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc dst src) (va_wpProof_AESNI_enc dst src)) //-- //-- VAESNI_enc val va_code_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_code val va_codegen_success_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_pbool val va_lemma_VAESNI_enc : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VAESNI_enc dst src1 src2) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1)))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (()))) val va_wpProof_VAESNI_enc : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VAESNI_enc dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VAESNI_enc (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc dst src1 src2)) = (va_QProc (va_code_VAESNI_enc dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc dst src1 src2) (va_wpProof_VAESNI_enc dst src1 src2)) //-- //-- AESNI_enc_last val va_code_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code val va_codegen_success_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool val va_lemma_AESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_enc_last dst src) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 dst))) (va_eval_xmm va_s0 src) ==> va_k va_sM (()))) val va_wpProof_AESNI_enc_last : dst:va_operand_xmm -> src:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AESNI_enc_last dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AESNI_enc_last (dst:va_operand_xmm) (src:va_operand_xmm) : (va_quickCode unit (va_code_AESNI_enc_last dst src)) = (va_QProc (va_code_AESNI_enc_last dst src) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_AESNI_enc_last dst src) (va_wpProof_AESNI_enc_last dst src)) //-- //-- VAESNI_enc_last val va_code_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_code val va_codegen_success_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Tot va_pbool val va_lemma_VAESNI_enc_last : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VAESNI_enc_last dst src1 src2) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))) (va_eval_xmm va_s0 src2) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0))))) [@ va_qattr] let va_wp_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src1 va_s0 /\ va_is_src_xmm src2 va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ avx_enabled) /\ (forall (va_x_dst:va_value_xmm) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE (va_eval_xmm va_s0 src1))) (va_eval_xmm va_s0 src2) ==> va_k va_sM (()))) val va_wpProof_VAESNI_enc_last : dst:va_operand_xmm -> src1:va_operand_xmm -> src2:va_operand_xmm -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VAESNI_enc_last dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VAESNI_enc_last dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VAESNI_enc_last (dst:va_operand_xmm) (src1:va_operand_xmm) (src2:va_operand_xmm) : (va_quickCode unit (va_code_VAESNI_enc_last dst src1 src2)) = (va_QProc (va_code_VAESNI_enc_last dst src1 src2) ([va_Mod_flags; va_mod_xmm dst]) (va_wp_VAESNI_enc_last dst src1 src2) (va_wpProof_VAESNI_enc_last dst src1 src2)) //-- //-- AESNI_keygen_assist val va_code_AESNI_keygen_assist : dst:va_operand_xmm -> src:va_operand_xmm -> imm:nat8 -> Tot va_code val va_codegen_success_AESNI_keygen_assist : dst:va_operand_xmm -> src:va_operand_xmm -> imm:nat8 -> Tot va_pbool val va_lemma_AESNI_keygen_assist : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm -> src:va_operand_xmm -> imm:nat8 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AESNI_keygen_assist dst src imm) va_s0 /\ va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src)))) imm) (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src)))) imm) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_xmm dst va_sM va_s0)))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.InsAes.fsti" }
[ { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "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": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> src: Vale.X64.Decls.va_operand_xmm -> imm: Vale.Def.Types_s.nat8 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.Def.Types_s.nat8", "Vale.X64.Decls.va_state", "Prims.unit", "Prims.l_and", "Vale.X64.Decls.va_is_dst_xmm", "Vale.X64.Decls.va_is_src_xmm", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.CPU_Features_s.aesni_enabled", "Prims.l_Forall", "Vale.X64.Decls.va_value_xmm", "Vale.X64.Flags.t", "Prims.l_imp", "Prims.eq2", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat32", "Vale.X64.Decls.va_eval_xmm", "Vale.Def.Words_s.Mkfour", "Vale.AES.AES_common_s.sub_word", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Arch.Types.ixor32", "Vale.AES.AES_s.rot_word_LE", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_upd_flags", "Vale.X64.Decls.va_upd_operand_xmm" ]
[]
false
false
false
true
true
let va_wp_AESNI_keygen_assist (dst src: va_operand_xmm) (imm: nat8) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ aesni_enabled /\ (forall (va_x_dst: va_value_xmm) (va_x_efl: Vale.X64.Flags.t). let va_sM = va_upd_flags va_x_efl (va_upd_operand_xmm dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_xmm va_sM dst == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__lo1 (va_eval_xmm va_s0 src)))) imm) (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src))) (Vale.Arch.Types.ixor32 (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_common_s.sub_word (Vale.Def.Words_s.__proj__Mkfour__item__hi3 (va_eval_xmm va_s0 src)))) imm) ==> va_k va_sM (())))
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.validate_bounded_integer
val validate_bounded_integer (i: integer_size) : Tot (validator (parse_bounded_integer i))
val validate_bounded_integer (i: integer_size) : Tot (validator (parse_bounded_integer i))
let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 77, "end_line": 71, "start_col": 0, "start_line": 68 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
i: LowParse.Spec.BoundedInt.integer_size -> LowParse.Low.Base.validator (LowParse.Spec.BoundedInt.parse_bounded_integer i)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Low.Base.validate_total_constant_size", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "FStar.UInt64.uint_to_t", "LowParse.Low.Base.validator" ]
[]
false
false
false
false
false
let validate_bounded_integer (i: integer_size) : Tot (validator (parse_bounded_integer i)) =
validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.read_bounded_integer
val read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i))
val read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i))
let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 34, "end_line": 35, "start_col": 0, "start_line": 26 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
i: LowParse.Spec.BoundedInt.integer_size -> LowParse.Low.Base.leaf_reader (LowParse.Spec.BoundedInt.parse_bounded_integer i)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Low.BoundedInt.read_bounded_integer_1", "LowParse.Low.BoundedInt.read_bounded_integer_2", "LowParse.Low.BoundedInt.read_bounded_integer_3", "LowParse.Low.BoundedInt.read_bounded_integer_4", "LowParse.Low.Base.leaf_reader", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "Prims.unit", "LowParse.Spec.BoundedInt.integer_size_values" ]
[]
false
false
false
false
false
let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) =
[@@ inline_let ]let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 ()
false
Spec.SHA3.Incremental.fst
Spec.SHA3.Incremental.sha3_is_incremental
val sha3_is_incremental (a: keccak_alg) (input: bytes) (l: output_length a): Lemma (hash_incremental a input l `S.equal` hash' a input l)
val sha3_is_incremental (a: keccak_alg) (input: bytes) (l: output_length a): Lemma (hash_incremental a input l `S.equal` hash' a input l)
let sha3_is_incremental (a: keccak_alg) (input: bytes) (out_length: output_length a): Lemma (hash_incremental a input out_length `S.equal` hash' a input out_length) = calc (S.equal) { hash_incremental a input out_length; (S.equal) { sha3_is_incremental1 a input out_length } ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last rateInBytes input in let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length); (S.equal) { sha3_is_incremental2 a input out_length } hash' a input out_length; }
{ "file_name": "specs/lemmas/Spec.SHA3.Incremental.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 232, "start_col": 0, "start_line": 215 }
module Spec.SHA3.Incremental module S = FStar.Seq open Spec.Agile.Hash open Spec.Hash.Definitions open Spec.Hash.Incremental.Definitions open Spec.Hash.Lemmas friend Spec.Agile.Hash open FStar.Mul module Loops = Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti open Lib.IntTypes #set-options "--fuel 0 --ifuel 0 --z3rlimit 200" let update_is_update_multi (a:keccak_alg) (inp:bytes{S.length inp == block_length a}) (s:words_state a) : Lemma (Spec.SHA3.absorb_inner (rate a/8) inp s == update_multi a s () inp) = let rateInBytes = rate a/8 in let f = Spec.SHA3.absorb_inner rateInBytes in let bs = block_length a in let f' = Lib.Sequence.repeat_blocks_f bs inp f 1 in assert (bs == rateInBytes); calc (==) { update_multi a s () inp; (==) { } Lib.Sequence.repeat_blocks_multi #_ #(words_state a) rateInBytes inp f s; (==) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) bs inp f s } (let len = S.length inp in let nb = len / bs in Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f bs inp f nb) s); (==) { Loops.unfold_repeati 1 f' s 0; Loops.eq_repeati0 1 f' s } f' 0 s; (==) { assert (Seq.slice inp (0 * bs) (0 * bs + bs) `S.equal` inp) } f inp s; } let suffix (a: keccak_alg) = if is_shake a then byte 0x1f else byte 0x06 val sha3_is_incremental1 (a: keccak_alg) (input: bytes) (out_length: output_length a): Lemma (hash_incremental a input out_length `S.equal` ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last rateInBytes input in let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length)) let sha3_is_incremental1 a input out_length = calc (==) { hash_incremental a input out_length; (==) { } (let s = init a in let bs, l = split_blocks a input in let s = update_multi a s () bs in let s = update_last a s () l in finish a s out_length); (==) { } (let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a/8 in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in let s = update_multi a s () bs in let s = update_last a s () l in finish a s out_length); (==) { } ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in if S.length l = rateInBytes then let s = update_multi a s () bs in let s = Spec.SHA3.absorb_inner rateInBytes l s in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in finish a s out_length else let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length ); (==) { ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in if S.length l = rateInBytes then let s = update_multi a s () bs in update_is_update_multi a l s else () ) } ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in if S.length l = rateInBytes then let s = update_multi a s () bs in let s = update_multi a s () l in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in finish a s out_length else let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length ); (==) { ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in if S.length l = rateInBytes then Lib.Sequence.Lemmas.repeat_blocks_multi_split (block_length a) (S.length bs) (bs `S.append` l) (Spec.SHA3.absorb_inner rateInBytes) s else () ) } ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in if S.length l = rateInBytes then let s = update_multi a s () (bs `S.append` l) in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in finish a s out_length else let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length ); }; calc (S.equal) { ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in if S.length l = rateInBytes then let s = update_multi a s () (bs `S.append` l) in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in finish a s out_length else let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length ); (S.equal) { let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in let s = update_multi a s () bs in if S.length l = rateInBytes then begin let bs', l' = UpdateMulti.split_at_last rateInBytes input in // TODO: strengthen this... NL arith! assert (bs' `S.equal` (bs `S.append` l)); assert (l' `S.equal` S.empty) end else () } ( let s = Lib.Sequence.create 25 (u64 0) in // Also the block size let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last rateInBytes input in let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length ); } let sha3_is_incremental2 (a: keccak_alg) (input: bytes) (out_length: output_length a): Lemma (hash' a input out_length `S.equal` ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last rateInBytes input in let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length)) = let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let nb = S.length input / block_length a in let s = Lib.Sequence.create 25 (u64 0) in let bs, l = UpdateMulti.split_at_last rateInBytes input in assert (S.length bs / block_length a == nb); let f = Spec.SHA3.absorb_inner rateInBytes in calc (==) { hash' a input out_length; (==) { } ( let s = Spec.SHA3.absorb s rateInBytes (S.length input) input delimitedSuffix in Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length) ); (==) { Lib.Sequence.lemma_repeat_blocks (block_length a) input f (Spec.SHA3.absorb_last delimitedSuffix rateInBytes) s } ( let s = Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) input f nb) s in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length)); (==) { Lib.Sequence.Lemmas.repeati_extensionality #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) input f nb) (Lib.Sequence.repeat_blocks_f (block_length a) bs f nb) s } ( let s = Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) bs f nb) s in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length)); (==) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) (block_length a) bs f s } ( let s = Lib.Sequence.repeat_blocks_multi #_ #(words_state a) (block_length a) bs f s in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length)); }
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.Definitions.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fst.checked", "Spec.Agile.Hash.fst.checked", "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Spec.SHA3.Incremental.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Incremental.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": 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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.keccak_alg -> input: Spec.Hash.Definitions.bytes -> l: Spec.Hash.Definitions.output_length a -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.equal (Spec.Hash.Incremental.Definitions.hash_incremental a input l) (Spec.Agile.Hash.hash' a input l))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.Hash.Definitions.keccak_alg", "Spec.Hash.Definitions.bytes", "Spec.Hash.Definitions.output_length", "FStar.Calc.calc_finish", "FStar.Seq.Base.seq", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.Seq.Base.equal", "Spec.Hash.Incremental.Definitions.hash_incremental", "Spec.Agile.Hash.hash'", "Prims.Cons", "FStar.Preorder.relation", "Lib.IntTypes.uint8", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Lib.UpdateMulti.uint8", "Spec.Agile.Hash.finish", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Spec.SHA3.absorb_last", "FStar.Seq.Base.length", "Spec.Hash.Definitions.words_state", "Spec.Agile.Hash.update_multi", "FStar.Pervasives.Native.tuple2", "Lib.UpdateMulti.split_at_last", "Lib.IntTypes.PUB", "Prims.l_or", "Prims.eq2", "Prims.int", "Lib.IntTypes.range", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Lib.IntTypes.v", "Spec.SHA3.Incremental.suffix", "Prims.op_Division", "Spec.Hash.Definitions.rate", "Spec.Hash.Definitions.word", "Lib.Sequence.to_seq", "FStar.Seq.Base.create", "Lib.IntTypes.mk_int", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Lib.Sequence.index", "Lib.Sequence.create", "Lib.IntTypes.u64", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Spec.SHA3.Incremental.sha3_is_incremental1", "Prims.squash", "Spec.SHA3.Incremental.sha3_is_incremental2", "Prims.l_True", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let sha3_is_incremental (a: keccak_alg) (input: bytes) (out_length: output_length a) : Lemma ((hash_incremental a input out_length) `S.equal` (hash' a input out_length)) =
calc (S.equal) { hash_incremental a input out_length; (S.equal) { sha3_is_incremental1 a input out_length } (let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last rateInBytes input in let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length); (S.equal) { sha3_is_incremental2 a input out_length } hash' a input out_length; }
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.validate_bounded_integer'
val validate_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) : Tot (validator (parse_bounded_integer (U32.v i)))
val validate_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) : Tot (validator (parse_bounded_integer (U32.v i)))
let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 103, "end_line": 77, "start_col": 0, "start_line": 74 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
i: FStar.UInt32.t{1 <= FStar.UInt32.v i /\ FStar.UInt32.v i <= 4} -> LowParse.Low.Base.validator (LowParse.Spec.BoundedInt.parse_bounded_integer (FStar.UInt32.v i))
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "LowParse.Low.Base.validate_total_constant_size", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "FStar.Int.Cast.uint32_to_uint64", "LowParse.Low.Base.validator" ]
[]
false
false
false
false
false
let validate_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) : Tot (validator (parse_bounded_integer (U32.v i))) =
validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.read_bounded_integer'
val read_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) : Tot (leaf_reader (parse_bounded_integer (U32.v i)))
val read_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) : Tot (leaf_reader (parse_bounded_integer (U32.v i)))
let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 39, "end_line": 47, "start_col": 0, "start_line": 37 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
i: FStar.UInt32.t{1 <= FStar.UInt32.v i /\ FStar.UInt32.v i <= 4} -> LowParse.Low.Base.leaf_reader (LowParse.Spec.BoundedInt.parse_bounded_integer (FStar.UInt32.v i ))
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "Prims.op_Equality", "FStar.UInt32.__uint_to_t", "LowParse.Low.BoundedInt.read_bounded_integer_1", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.bool", "LowParse.Low.BoundedInt.read_bounded_integer_2", "LowParse.Low.BoundedInt.read_bounded_integer_3", "LowParse.Low.BoundedInt.read_bounded_integer_4", "LowParse.Low.Base.leaf_reader", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer" ]
[]
false
false
false
false
false
let read_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) =
fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos
false
Hacl.Impl.Poly1305.Field32xN.fst
Hacl.Impl.Poly1305.Field32xN.load_precompute_r1
val load_precompute_r1: p:precomp_r 1 -> r0:uint64 -> r1:uint64 -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ load_precompute_r_post h1 p /\ (assert_norm (pow2 64 * pow2 64 = pow2 128); feval h1 (gsub p 0ul 5ul) == LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0)))
val load_precompute_r1: p:precomp_r 1 -> r0:uint64 -> r1:uint64 -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ load_precompute_r_post h1 p /\ (assert_norm (pow2 64 * pow2 64 = pow2 128); feval h1 (gsub p 0ul 5ul) == LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0)))
let load_precompute_r1 p r0 r1 = let r = sub p 0ul 5ul in let r5 = sub p 5ul 5ul in let rn = sub p 10ul 5ul in let rn_5 = sub p 15ul 5ul in let r_vec0 = vec_load r0 1 in let r_vec1 = vec_load r1 1 in let h0 = ST.get () in load_felem r r_vec0 r_vec1; let h1 = ST.get () in LSeq.eq_intro (LSeq.createi #Vec.pfelem 1 (fun i -> (uint64xN_v r_vec1).[i] * pow2 64 + (uint64xN_v r_vec0).[i])) (LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0)); assert (feval h1 r == LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0)); precompute_shift_reduce r5 r; copy_felem #_ #(1,1,1,1,1) rn r; copy_felem #_ #(5,5,5,5,5) rn_5 r5
{ "file_name": "code/poly1305/Hacl.Impl.Poly1305.Field32xN.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 475, "start_col": 0, "start_line": 456 }
module Hacl.Impl.Poly1305.Field32xN open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Lib.IntVector include Hacl.Spec.Poly1305.Field32xN open Hacl.Spec.Poly1305.Field32xN.Lemmas open Hacl.Impl.Poly1305.Lemmas module Vec = Hacl.Spec.Poly1305.Vec module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module BSeq = Lib.ByteSequence #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50 --using_facts_from '* -FStar.Seq'" inline_for_extraction noextract let felem (w:lanes) = lbuffer (uint64xN w) 5ul inline_for_extraction noextract let felem_wide (w:lanes) = felem w inline_for_extraction noextract let precomp_r (w:lanes) = lbuffer (uint64xN w) 20ul unfold noextract let op_String_Access #a #len = LSeq.index #a #len noextract val as_tup5: #w:lanes -> h:mem -> f:felem w -> GTot (felem5 w) let as_tup5 #w h f = let s = as_seq h f in let s0 = s.[0] in let s1 = s.[1] in let s2 = s.[2] in let s3 = s.[3] in let s4 = s.[4] in (s0,s1,s2,s3,s4) noextract val felem_fits: #w:lanes -> h:mem -> f:felem w -> m:scale32_5 -> Type0 let felem_fits #w h f m = felem_fits5 (as_tup5 h f) m noextract val felem_wide_fits: #w:lanes -> h:mem -> f:felem w -> m:scale32_5 -> Type0 let felem_wide_fits #w h f m = felem_wide_fits5 (as_tup5 h f) m noextract let feval (#w:lanes) (h:mem) (f:felem w) : GTot (LSeq.lseq Vec.pfelem w) = feval5 (as_tup5 h f) noextract let fas_nat (#w:lanes) (h:mem) (f:felem w) : GTot (LSeq.lseq nat w) = fas_nat5 (as_tup5 h f) noextract let felem_less (#w:lanes) (h:mem) (f:felem w) (max:nat) : Type0 = felem_less5 (as_tup5 h f) max val lemma_feval_is_fas_nat: #w:lanes -> h:mem -> f:felem w -> Lemma (requires felem_less h f (pow2 128)) (ensures (forall (i:nat). i < w ==> (feval h f).[i] == (fas_nat h f).[i])) let lemma_feval_is_fas_nat #w h f = lemma_feval_is_fas_nat (as_tup5 h f) inline_for_extraction noextract val fmul_precomp_r_pre: #w:lanes -> h:mem -> precomp:precomp_r w -> Type0 let fmul_precomp_r_pre #w h precomp = let r = gsub precomp 0ul 5ul in let r_5 = gsub precomp 5ul 5ul in felem_fits h r (1, 1, 1, 1, 1) /\ felem_fits h r_5 (5, 5, 5, 5, 5) /\ as_tup5 h r_5 == precomp_r5 (as_tup5 h r) noextract val load_precompute_r_post: #w:lanes -> h:mem -> p:precomp_r w -> Type0 let load_precompute_r_post #w h p = assert_norm (pow2 128 < Vec.prime); let r = gsub p 0ul 5ul in let rn = gsub p 10ul 5ul in let rn_5 = gsub p 15ul 5ul in fmul_precomp_r_pre h p /\ felem_fits h rn (2, 2, 2, 2, 2) /\ felem_fits h rn_5 (10, 10, 10, 10, 10) /\ as_tup5 h rn_5 == precomp_r5 (as_tup5 h rn) /\ feval h rn == Vec.compute_rw (feval h r).[0] inline_for_extraction noextract val create_felem: w:lanes -> StackInline (felem w) (requires fun h -> True) (ensures fun h0 b h1 -> stack_allocated b h0 h1 (LSeq.create 5 (zero w)) /\ feval h1 b == LSeq.create w 0) let create_felem w = let r = create 5ul (zero w) in let h1 = ST.get () in LSeq.eq_intro (feval h1 r) (LSeq.create w 0); r #push-options "--z3rlimit 100" inline_for_extraction noextract val set_bit: #w:lanes -> f:felem w -> i:size_t{size_v i <= 128} -> Stack unit (requires fun h -> live h f /\ felem_fits h f (1, 1, 1, 1, 1) /\ felem_less #w h f (pow2 (v i))) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (1, 1, 1, 1, 1) /\ (Math.Lemmas.pow2_le_compat 128 (v i); feval h1 f == LSeq.map (Vec.pfadd (pow2 (v i))) (feval h0 f))) let set_bit #w f i = let b = u64 1 <<. (i %. 26ul) in let mask = vec_load b w in let fi = f.(i /. 26ul) in let h0 = ST.get () in f.(i /. 26ul) <- vec_or fi mask; set_bit5_lemma (as_seq h0 f) (v i) #pop-options inline_for_extraction noextract val set_bit128: #w:lanes -> f:felem w -> Stack unit (requires fun h -> live h f /\ felem_fits h f (1, 1, 1, 1, 1) /\ felem_less #w h f (pow2 128)) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (1, 1, 1, 1, 1) /\ feval h1 f == LSeq.map (Vec.pfadd (pow2 128)) (feval h0 f)) let set_bit128 #w f = let b = u64 0x1000000 in assert_norm (0x1000000 = pow2 24); assert (v b == v (u64 1 <<. 24ul)); let mask = vec_load b w in let f4 = f.(4ul) in let h0 = ST.get () in f.(4ul) <- vec_or f4 mask; set_bit5_lemma (as_seq h0 f) 128 inline_for_extraction noextract val set_zero: #w:lanes -> f:felem w -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (0, 0, 0, 0, 0) /\ feval h1 f == LSeq.create w 0) let set_zero #w f = f.(0ul) <- zero w; f.(1ul) <- zero w; f.(2ul) <- zero w; f.(3ul) <- zero w; f.(4ul) <- zero w; let h1 = ST.get () in LSeq.eq_intro (feval h1 f) (LSeq.create w 0) inline_for_extraction noextract val copy_felem: #w:lanes -> #m:scale32_5 -> f1:felem w -> f2:felem w -> Stack unit (requires fun h -> live h f1 /\ live h f2 /\ disjoint f1 f2 /\ felem_fits h f2 m) (ensures fun h0 _ h1 -> modifies (loc f1) h0 h1 /\ felem_fits h1 f1 m /\ as_tup5 h1 f1 == as_tup5 h0 f2) let copy_felem #w #m f1 f2 = f1.(0ul) <- f2.(0ul); f1.(1ul) <- f2.(1ul); f1.(2ul) <- f2.(2ul); f1.(3ul) <- f2.(3ul); f1.(4ul) <- f2.(4ul) inline_for_extraction noextract val fadd: #w:lanes -> out:felem w -> f1:felem w -> f2:felem w -> Stack unit (requires fun h -> live h f1 /\ live h f2 /\ live h out /\ felem_fits h f1 (2,2,2,2,2) /\ felem_fits h f2 (1,1,1,1,1)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ //as_tup5 h1 out == fadd5 (as_tup5 h0 f1) (as_tup5 h0 f2) /\ felem_fits h1 out (3,3,3,3,3) /\ feval h1 out == LSeq.map2 Vec.pfadd (feval h0 f1) (feval h0 f2)) let fadd #w out f1 f2 = let f10 = f1.(0ul) in let f11 = f1.(1ul) in let f12 = f1.(2ul) in let f13 = f1.(3ul) in let f14 = f1.(4ul) in let f20 = f2.(0ul) in let f21 = f2.(1ul) in let f22 = f2.(2ul) in let f23 = f2.(3ul) in let f24 = f2.(4ul) in let (o0,o1,o2,o3,o4) = fadd5 #w (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in out.(0ul) <- o0; out.(1ul) <- o1; out.(2ul) <- o2; out.(3ul) <- o3; out.(4ul) <- o4 #push-options "--max_fuel 1" inline_for_extraction noextract val fmul_r: #w:lanes -> out:felem w -> f1:felem w -> r:felem w -> r5:felem w -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h r /\ live h r5 /\ felem_fits h f1 (3,3,3,3,3) /\ felem_fits h r (2,2,2,2,2) /\ felem_fits h r5 (10,10,10,10,10) /\ as_tup5 h r5 == precomp_r5 (as_tup5 h r)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ felem_fits h1 out (1,2,1,1,2) /\ feval h1 out == LSeq.map2 (Vec.pfmul) (feval h0 f1) (feval h0 r)) let fmul_r #w out f1 r r5 = let r0 = r.(0ul) in let r1 = r.(1ul) in let r2 = r.(2ul) in let r3 = r.(3ul) in let r4 = r.(4ul) in let r50 = r5.(0ul) in let r51 = r5.(1ul) in let r52 = r5.(2ul) in let r53 = r5.(3ul) in let r54 = r5.(4ul) in let f10 = f1.(0ul) in let f11 = f1.(1ul) in let f12 = f1.(2ul) in let f13 = f1.(3ul) in let f14 = f1.(4ul) in let (o0, o1, o2, o3, o4) = fmul_r5 #w (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r50, r51, r52, r53, r54) in out.(0ul) <- o0; out.(1ul) <- o1; out.(2ul) <- o2; out.(3ul) <- o3; out.(4ul) <- o4 #pop-options inline_for_extraction noextract val fadd_mul_r: #w:lanes -> acc:felem w -> f1:felem w -> p:precomp_r w -> Stack unit (requires fun h -> live h acc /\ live h f1 /\ live h p /\ felem_fits h acc (2,2,2,2,2) /\ felem_fits h f1 (1,1,1,1,1) /\ fmul_precomp_r_pre h p) (ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\ felem_fits h1 acc (1,2,1,1,2) /\ feval h1 acc == LSeq.map2 (Vec.pfmul) (LSeq.map2 (Vec.pfadd) (feval h0 acc) (feval h0 f1)) (feval h0 (gsub p 0ul 5ul))) let fadd_mul_r #w out f1 p = let r = sub p 0ul 5ul in let r5 = sub p 5ul 5ul in let r0 = r.(0ul) in let r1 = r.(1ul) in let r2 = r.(2ul) in let r3 = r.(3ul) in let r4 = r.(4ul) in let r50 = r5.(0ul) in let r51 = r5.(1ul) in let r52 = r5.(2ul) in let r53 = r5.(3ul) in let r54 = r5.(4ul) in let f10 = f1.(0ul) in let f11 = f1.(1ul) in let f12 = f1.(2ul) in let f13 = f1.(3ul) in let f14 = f1.(4ul) in let a0 = out.(0ul) in let a1 = out.(1ul) in let a2 = out.(2ul) in let a3 = out.(3ul) in let a4 = out.(4ul) in let (o0, o1, o2, o3, o4) = fadd_mul_r5 #w (a0, a1, a2, a3, a4) (f10, f11, f12, f13, f14) (r0, r1, r2, r3, r4) (r50, r51, r52, r53, r54) in out.(0ul) <- o0; out.(1ul) <- o1; out.(2ul) <- o2; out.(3ul) <- o3; out.(4ul) <- o4 inline_for_extraction noextract val fmul_rn: #w:lanes -> out:felem w -> f1:felem w -> p:precomp_r w -> Stack unit (requires fun h -> live h out /\ live h f1 /\ live h p /\ (let rn = gsub p 10ul 5ul in let rn_5 = gsub p 15ul 5ul in felem_fits h f1 (3,3,3,3,3) /\ felem_fits h rn (2,2,2,2,2) /\ felem_fits h rn_5 (10,10,10,10,10) /\ as_tup5 h rn_5 == precomp_r5 (as_tup5 h rn))) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ felem_fits h1 out (1,2,1,1,2) /\ feval h1 out == LSeq.map2 Vec.pfmul (feval h0 f1) (feval h0 (gsub p 10ul 5ul))) let fmul_rn #w out f1 p = let rn = sub p 10ul 5ul in let rn5 = sub p 15ul 5ul in fmul_r #w out f1 rn rn5 inline_for_extraction noextract val reduce_felem: #w:lanes -> f:felem w -> Stack unit (requires fun h -> live h f /\ felem_fits h f (2,2,2,2,2)) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (1, 1, 1, 1, 1) /\ (fas_nat h1 f).[0] == (feval h0 f).[0]) let reduce_felem #w f = let f0 = f.(0ul) in let f1 = f.(1ul) in let f2 = f.(2ul) in let f3 = f.(3ul) in let f4 = f.(4ul) in let (f0, f1, f2, f3, f4) = reduce_felem5 (f0, f1, f2, f3, f4) in f.(0ul) <- f0; f.(1ul) <- f1; f.(2ul) <- f2; f.(3ul) <- f3; f.(4ul) <- f4 inline_for_extraction noextract val precompute_shift_reduce: #w:lanes -> f1:felem w -> f2:felem w -> Stack unit (requires fun h -> live h f1 /\ live h f2) (ensures fun h0 _ h1 -> modifies (loc f1) h0 h1 /\ as_tup5 h1 f1 == precomp_r5 (as_tup5 h0 f2)) let precompute_shift_reduce #w f1 f2 = let f20 = f2.(0ul) in let f21 = f2.(1ul) in let f22 = f2.(2ul) in let f23 = f2.(3ul) in let f24 = f2.(4ul) in f1.(0ul) <- vec_smul_mod f20 (u64 5); f1.(1ul) <- vec_smul_mod f21 (u64 5); f1.(2ul) <- vec_smul_mod f22 (u64 5); f1.(3ul) <- vec_smul_mod f23 (u64 5); f1.(4ul) <- vec_smul_mod f24 (u64 5) inline_for_extraction noextract val load_felem: #w:lanes -> f:felem w -> lo:uint64xN w -> hi:uint64xN w -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ felem_fits h1 f (1, 1, 1, 1, 1) /\ felem_less h1 f (pow2 128) /\ feval h1 f == LSeq.createi #Vec.pfelem w (fun i -> (uint64xN_v hi).[i] * pow2 64 + (uint64xN_v lo).[i])) let load_felem #w f lo hi = let (f0, f1, f2, f3, f4) = load_felem5 #w lo hi in load_felem5_lemma #w lo hi; f.(0ul) <- f0; f.(1ul) <- f1; f.(2ul) <- f2; f.(3ul) <- f3; f.(4ul) <- f4 #push-options "--max_fuel 2" inline_for_extraction noextract val load_precompute_r1: p:precomp_r 1 -> r0:uint64 -> r1:uint64 -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ load_precompute_r_post h1 p /\ (assert_norm (pow2 64 * pow2 64 = pow2 128); feval h1 (gsub p 0ul 5ul) ==
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Impl.Poly1305.Lemmas.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Poly1305.Field32xN.fst" }
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": "Vec" }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305", "short_module": null }, { "abbrev": 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": 2, "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
p: Hacl.Impl.Poly1305.Field32xN.precomp_r 1 -> r0: Lib.IntTypes.uint64 -> r1: Lib.IntTypes.uint64 -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Poly1305.Field32xN.precomp_r", "Lib.IntTypes.uint64", "Hacl.Impl.Poly1305.Field32xN.copy_felem", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Prims.unit", "Hacl.Impl.Poly1305.Field32xN.precompute_shift_reduce", "Prims._assert", "Prims.eq2", "Lib.Sequence.lseq", "Hacl.Spec.Poly1305.Vec.pfelem", "Hacl.Impl.Poly1305.Field32xN.feval", "Lib.Sequence.create", "Prims.op_Addition", "FStar.Mul.op_Star", "Lib.IntTypes.uint_v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.pow2", "Lib.Sequence.eq_intro", "Lib.Sequence.createi", "Prims.b2t", "Prims.op_LessThan", "Hacl.Impl.Poly1305.Field32xN.op_String_Access", "Hacl.Spec.Poly1305.Field32xN.uint64xN_v", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.Poly1305.Field32xN.load_felem", "Lib.IntVector.vec_t", "Lib.IntTypes.int_t", "Lib.IntVector.vec_v", "Lib.IntVector.vec_load", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t" ]
[]
false
true
false
false
false
let load_precompute_r1 p r0 r1 =
let r = sub p 0ul 5ul in let r5 = sub p 5ul 5ul in let rn = sub p 10ul 5ul in let rn_5 = sub p 15ul 5ul in let r_vec0 = vec_load r0 1 in let r_vec1 = vec_load r1 1 in let h0 = ST.get () in load_felem r r_vec0 r_vec1; let h1 = ST.get () in LSeq.eq_intro (LSeq.createi #Vec.pfelem 1 (fun i -> (uint64xN_v r_vec1).[ i ] * pow2 64 + (uint64xN_v r_vec0).[ i ])) (LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0)); assert (feval h1 r == LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0)); precompute_shift_reduce r5 r; copy_felem #_ #(1, 1, 1, 1, 1) rn r; copy_felem #_ #(5, 5, 5, 5, 5) rn_5 r5
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.validate_bounded_integer_le
val validate_bounded_integer_le (i: integer_size) : Tot (validator (parse_bounded_integer_le i))
val validate_bounded_integer_le (i: integer_size) : Tot (validator (parse_bounded_integer_le i))
let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 80, "end_line": 84, "start_col": 0, "start_line": 81 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
i: LowParse.Spec.BoundedInt.integer_size -> LowParse.Low.Base.validator (LowParse.Spec.BoundedInt.parse_bounded_integer_le i)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Low.Base.validate_total_constant_size", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "FStar.UInt64.uint_to_t", "LowParse.Low.Base.validator" ]
[]
false
false
false
false
false
let validate_bounded_integer_le (i: integer_size) : Tot (validator (parse_bounded_integer_le i)) =
validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.jump_bounded_integer'
val jump_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) : Tot (jumper (parse_bounded_integer (U32.v i)))
val jump_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) : Tot (jumper (parse_bounded_integer (U32.v i)))
let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 61, "end_line": 97, "start_col": 0, "start_line": 94 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
i: FStar.UInt32.t{1 <= FStar.UInt32.v i /\ FStar.UInt32.v i <= 4} -> LowParse.Low.Base.jumper (LowParse.Spec.BoundedInt.parse_bounded_integer (FStar.UInt32.v i))
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "LowParse.Low.Base.jump_constant_size", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Low.Base.jumper" ]
[]
false
false
false
false
false
let jump_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) : Tot (jumper (parse_bounded_integer (U32.v i))) =
jump_constant_size (parse_bounded_integer (U32.v i)) (i) ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_integer_2
val write_bounded_integer_2 : _: Prims.unit -> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 2)
let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 105, "end_line": 122, "start_col": 0, "start_line": 122 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
_: Prims.unit -> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 2)
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowParse.Low.Base.leaf_writer_strong_of_serializer32", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.Low.BoundedInt.serialize32_bounded_integer_2", "LowParse.Low.Base.leaf_writer_strong" ]
[]
false
false
false
false
false
let write_bounded_integer_2 () =
leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.jump_bounded_integer_le
val jump_bounded_integer_le (i: integer_size) : Tot (jumper (parse_bounded_integer_le i))
val jump_bounded_integer_le (i: integer_size) : Tot (jumper (parse_bounded_integer_le i))
let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 70, "end_line": 104, "start_col": 0, "start_line": 101 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
i: LowParse.Spec.BoundedInt.integer_size -> LowParse.Low.Base.jumper (LowParse.Spec.BoundedInt.parse_bounded_integer_le i)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Low.Base.jump_constant_size", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "FStar.UInt32.uint_to_t", "LowParse.Low.Base.jumper" ]
[]
false
false
false
false
false
let jump_bounded_integer_le (i: integer_size) : Tot (jumper (parse_bounded_integer_le i)) =
jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.jump_bounded_integer
val jump_bounded_integer (i: integer_size) : Tot (jumper (parse_bounded_integer i))
val jump_bounded_integer (i: integer_size) : Tot (jumper (parse_bounded_integer i))
let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 67, "end_line": 91, "start_col": 0, "start_line": 88 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
i: LowParse.Spec.BoundedInt.integer_size -> LowParse.Low.Base.jumper (LowParse.Spec.BoundedInt.parse_bounded_integer i)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Low.Base.jump_constant_size", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "FStar.UInt32.uint_to_t", "LowParse.Low.Base.jumper" ]
[]
false
false
false
false
false
let jump_bounded_integer (i: integer_size) : Tot (jumper (parse_bounded_integer i)) =
jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_integer_4
val write_bounded_integer_4 : _: Prims.unit -> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 4)
let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 105, "end_line": 128, "start_col": 0, "start_line": 128 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
_: Prims.unit -> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 4)
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowParse.Low.Base.leaf_writer_strong_of_serializer32", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.Low.BoundedInt.serialize32_bounded_integer_4", "LowParse.Low.Base.leaf_writer_strong" ]
[]
false
false
false
false
false
let write_bounded_integer_4 () =
leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_integer_1
val write_bounded_integer_1 : _: Prims.unit -> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 1)
let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 105, "end_line": 119, "start_col": 0, "start_line": 119 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
_: Prims.unit -> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 1)
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowParse.Low.Base.leaf_writer_strong_of_serializer32", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.Low.BoundedInt.serialize32_bounded_integer_1", "LowParse.Low.Base.leaf_writer_strong" ]
[]
false
false
false
false
false
let write_bounded_integer_1 () =
leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_integer
val write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i))
val write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i))
let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 35, "end_line": 141, "start_col": 0, "start_line": 132 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
i: LowParse.Spec.BoundedInt.integer_size -> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer i)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Low.BoundedInt.write_bounded_integer_1", "LowParse.Low.BoundedInt.write_bounded_integer_2", "LowParse.Low.BoundedInt.write_bounded_integer_3", "LowParse.Low.BoundedInt.write_bounded_integer_4", "LowParse.Low.Base.leaf_writer_strong", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "Prims.unit", "LowParse.Spec.BoundedInt.integer_size_values" ]
[]
false
false
false
false
false
let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) =
[@@ inline_let ]let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_integer_3
val write_bounded_integer_3 : _: Prims.unit -> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 3)
let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 105, "end_line": 125, "start_col": 0, "start_line": 125 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
_: Prims.unit -> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer 3)
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowParse.Low.Base.leaf_writer_strong_of_serializer32", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.Low.BoundedInt.serialize32_bounded_integer_3", "LowParse.Low.Base.leaf_writer_strong" ]
[]
false
false
false
false
false
let write_bounded_integer_3 () =
leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_integer'
val write_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
val write_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i)))
let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 42, "end_line": 154, "start_col": 0, "start_line": 144 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
i: FStar.UInt32.t{1 <= FStar.UInt32.v i /\ FStar.UInt32.v i <= 4} -> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer (FStar.UInt32.v i))
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "Prims.op_Equality", "FStar.UInt32.__uint_to_t", "LowParse.Low.BoundedInt.write_bounded_integer_1", "Prims.bool", "LowParse.Low.BoundedInt.write_bounded_integer_2", "LowParse.Low.BoundedInt.write_bounded_integer_3", "LowParse.Low.BoundedInt.write_bounded_integer_4", "LowParse.Low.Base.leaf_writer_strong", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer" ]
[]
false
false
false
false
false
let write_bounded_integer' (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) =
fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_integer_2_weak
val write_bounded_integer_2_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 2))
val write_bounded_integer_2_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 2))
let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 78, "end_line": 162, "start_col": 0, "start_line": 161 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
_: Prims.unit -> LowParse.Low.Base.leaf_writer_weak (LowParse.Spec.BoundedInt.serialize_bounded_integer 2)
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowParse.Low.Base.leaf_writer_weak_of_strong_constant_size", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.Low.BoundedInt.write_bounded_integer_2", "FStar.UInt32.__uint_to_t", "LowParse.Low.Base.leaf_writer_weak" ]
[]
false
false
false
false
false
let write_bounded_integer_2_weak (_: unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_integer_1_weak
val write_bounded_integer_1_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 1))
val write_bounded_integer_1_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 1))
let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 78, "end_line": 158, "start_col": 0, "start_line": 157 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
_: Prims.unit -> LowParse.Low.Base.leaf_writer_weak (LowParse.Spec.BoundedInt.serialize_bounded_integer 1)
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowParse.Low.Base.leaf_writer_weak_of_strong_constant_size", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.Low.BoundedInt.write_bounded_integer_1", "FStar.UInt32.__uint_to_t", "LowParse.Low.Base.leaf_writer_weak" ]
[]
false
false
false
false
false
let write_bounded_integer_1_weak (_: unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_integer_4_weak
val write_bounded_integer_4_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 4))
val write_bounded_integer_4_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 4))
let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 78, "end_line": 170, "start_col": 0, "start_line": 169 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
_: Prims.unit -> LowParse.Low.Base.leaf_writer_weak (LowParse.Spec.BoundedInt.serialize_bounded_integer 4)
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowParse.Low.Base.leaf_writer_weak_of_strong_constant_size", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.Low.BoundedInt.write_bounded_integer_4", "FStar.UInt32.__uint_to_t", "LowParse.Low.Base.leaf_writer_weak" ]
[]
false
false
false
false
false
let write_bounded_integer_4_weak (_: unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_integer_3_weak
val write_bounded_integer_3_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 3))
val write_bounded_integer_3_weak: unit -> Tot (leaf_writer_weak (serialize_bounded_integer 3))
let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 78, "end_line": 166, "start_col": 0, "start_line": 165 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
_: Prims.unit -> LowParse.Low.Base.leaf_writer_weak (LowParse.Spec.BoundedInt.serialize_bounded_integer 3)
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowParse.Low.Base.leaf_writer_weak_of_strong_constant_size", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.Low.BoundedInt.write_bounded_integer_3", "FStar.UInt32.__uint_to_t", "LowParse.Low.Base.leaf_writer_weak" ]
[]
false
false
false
false
false
let write_bounded_integer_3_weak (_: unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) =
leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_integer_weak
val write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i))
val write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i))
let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 40, "end_line": 183, "start_col": 0, "start_line": 174 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
i: LowParse.Spec.BoundedInt.integer_size -> LowParse.Low.Base.leaf_writer_weak (LowParse.Spec.BoundedInt.serialize_bounded_integer i)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Low.BoundedInt.write_bounded_integer_1_weak", "LowParse.Low.BoundedInt.write_bounded_integer_2_weak", "LowParse.Low.BoundedInt.write_bounded_integer_3_weak", "LowParse.Low.BoundedInt.write_bounded_integer_4_weak", "LowParse.Low.Base.leaf_writer_weak", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "Prims.unit", "LowParse.Spec.BoundedInt.integer_size_values" ]
[]
false
false
false
false
false
let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) =
[@@ inline_let ]let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_int32
val write_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
val write_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos )
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 218, "start_col": 0, "start_line": 206 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_int32 (FStar.UInt32.v min32) (FStar.UInt32.v max32))
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "LowParse.Low.BoundedInt.write_bounded_int32_1", "Prims.bool", "LowParse.Low.BoundedInt.write_bounded_int32_2", "LowParse.Low.BoundedInt.write_bounded_int32_3", "LowParse.Low.BoundedInt.write_bounded_int32_4", "LowParse.Low.Base.leaf_writer_strong", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32", "LowParse.Spec.BoundedInt.serialize_bounded_int32" ]
[]
false
false
false
false
false
let write_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) =
fun input #rrel #rel out pos -> (if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos)
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.read_bounded_int32
val read_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val read_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos )
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 253, "start_col": 0, "start_line": 241 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.Low.Base.leaf_reader (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "LowParse.Low.BoundedInt.read_bounded_int32_1", "LowParse.Spec.BoundedInt.bounded_int32", "Prims.bool", "LowParse.Low.BoundedInt.read_bounded_int32_2", "LowParse.Low.BoundedInt.read_bounded_int32_3", "LowParse.Low.BoundedInt.read_bounded_int32_4", "LowParse.Low.Base.leaf_reader", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32" ]
[]
false
false
false
false
false
let read_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) =
fun #rrel #rel sl pos -> (if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos)
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.validate_u32_le
val validate_u32_le: Prims.unit -> validator parse_u32_le
val validate_u32_le: Prims.unit -> validator parse_u32_le
let validate_u32_le () : validator parse_u32_le = validate_total_constant_size parse_u32_le 4uL ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 50, "end_line": 335, "start_col": 0, "start_line": 334 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos ) inline_for_extraction let validate_u16_le () : validator parse_u16_le = validate_total_constant_size parse_u16_le 2uL () inline_for_extraction let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le = validate_total_constant_size_with_error_code parse_u16_le 2uL c
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
_: Prims.unit -> LowParse.Low.Base.validator LowParse.Spec.BoundedInt.parse_u32_le
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowParse.Low.Base.validate_total_constant_size", "LowParse.Spec.Int.parse_u32_kind", "FStar.UInt32.t", "LowParse.Spec.BoundedInt.parse_u32_le", "FStar.UInt64.__uint_to_t", "LowParse.Low.Base.validator" ]
[]
false
false
false
true
false
let validate_u32_le () : validator parse_u32_le =
validate_total_constant_size parse_u32_le 4uL ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.jump_u32_le
val jump_u32_le:jumper parse_u32_le
val jump_u32_le:jumper parse_u32_le
let jump_u32_le : jumper parse_u32_le = jump_constant_size parse_u32_le 4ul ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 40, "end_line": 347, "start_col": 0, "start_line": 346 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos ) inline_for_extraction let validate_u16_le () : validator parse_u16_le = validate_total_constant_size parse_u16_le 2uL () inline_for_extraction let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le = validate_total_constant_size_with_error_code parse_u16_le 2uL c inline_for_extraction let validate_u32_le () : validator parse_u32_le = validate_total_constant_size parse_u32_le 4uL () inline_for_extraction let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le = validate_total_constant_size_with_error_code parse_u32_le 4uL c inline_for_extraction let jump_u16_le : jumper parse_u16_le = jump_constant_size parse_u16_le 2ul ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
LowParse.Low.Base.jumper LowParse.Spec.BoundedInt.parse_u32_le
Prims.Tot
[ "total" ]
[]
[ "LowParse.Low.Base.jump_constant_size", "LowParse.Spec.Int.parse_u32_kind", "FStar.UInt32.t", "LowParse.Spec.BoundedInt.parse_u32_le", "FStar.UInt32.__uint_to_t" ]
[]
false
false
false
true
false
let jump_u32_le:jumper parse_u32_le =
jump_constant_size parse_u32_le 4ul ()
false
CQueue.fst
CQueue.create_queue
val create_queue (a: Type) : Steel (t a & Ghost.erased (v a)) emp (fun x -> queue (fst x) (snd x)) (requires (fun _ -> True)) (ensures (fun _ res _ -> datas (snd res) == []))
val create_queue (a: Type) : Steel (t a & Ghost.erased (v a)) emp (fun x -> queue (fst x) (snd x)) (requires (fun _ -> True)) (ensures (fun _ res _ -> datas (snd res) == []))
let create_queue a = let head = ccell_ptrvalue_null a in let tail : ref (ccell_ptrvalue a) = null in let l0 = alloc_llist head tail in let l = elim_cllist l0 in write (cllist_tail l) (cllist_head l); intro_llist_fragment_head_nil [] (cllist_head l) (Ghost.reveal (Ghost.hide head)); intro_queue_head l [] head; let res : (t a & Ghost.erased (v a)) = (l0, Ghost.hide []) in change_equal_slprop (queue_head l []) (queue (fst res) (snd res)); return res
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 12, "end_line": 1304, "start_col": 0, "start_line": 1292 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *) let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f let elim_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) = elim_vrewrite v f let vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) = fun _ -> x [@@ __steel_reduce__] let vconst' (#a: Type) (x: a) : GTot vprop' = { hp = hp_of emp; t = a; sel = vconst_sel x; } [@@ __steel_reduce__] let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x) let intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x) = change_slprop_rel emp (vconst x) (fun _ y -> y == x) (fun _ -> ()) let elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x) = change_slprop_rel (vconst x) emp (fun y _ -> y == x) (fun _ -> ()) let vpure_sel' (p: prop) : Tot (selector' (squash p) (Steel.Memory.pure p)) = fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m let vpure_sel (p: prop) : Tot (selector (squash p) (Steel.Memory.pure p)) = vpure_sel' p [@@ __steel_reduce__] let vpure' (p: prop) : GTot vprop' = { hp = Steel.Memory.pure p; t = squash p; sel = vpure_sel p; } [@@ __steel_reduce__] let vpure (p: prop) : Tot vprop = VUnit (vpure' p) let intro_vpure (#opened: _) (p: prop) : SteelGhost unit opened emp (fun _ -> vpure p) (fun _ -> p) (fun _ _ h' -> p) = change_slprop_rel emp (vpure p) (fun _ _ -> p) (fun m -> pure_interp p m) let elim_vpure (#opened: _) (p: prop) : SteelGhost unit opened (vpure p) (fun _ -> emp) (fun _ -> True) (fun _ _ _ -> p) = change_slprop_rel (vpure p) emp (fun _ _ -> p) (fun m -> pure_interp p m; reveal_emp (); intro_emp m) val intro_vdep2 (#opened:inames) (v: vprop) (q: vprop) (x: t_of v) (p: (t_of v -> Tot vprop)) : SteelGhost unit opened (v `star` q) (fun _ -> vdep v p) (requires (fun h -> q == p x /\ x == h v )) (ensures (fun h _ h' -> let x2 = h' (vdep v p) in q == p (h v) /\ dfst x2 == (h v) /\ dsnd x2 == (h q) )) let intro_vdep2 v q x p = intro_vdep v q p let vbind0_payload (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: t_of a) : Tot vprop = vpure (t == t_of (b x)) `star` b x let vbind0_rewrite (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: normal (t_of (vdep a (vbind0_payload a t b)))) : Tot t = snd (dsnd x) [@@__steel_reduce__; __reduce__] let vbind0 (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b let vbind_hp // necessary to hide the attribute on hp_of (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot (slprop u#1) = hp_of (vbind0 a t b) let vbind_sel // same for hp_sel (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot (selector t (vbind_hp a t b)) = sel_of (vbind0 a t b) [@@__steel_reduce__] let vbind' (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot vprop' = { hp = vbind_hp a t b; t = t; sel = vbind_sel a t b; } [@@__steel_reduce__] let vbind (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = VUnit (vbind' a t b) let intro_vbind (#opened: _) (a: vprop) (b' : vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost unit opened (a `star` b') (fun _ -> vbind a t b) (fun h -> t_of b' == t /\ b' == b (h a)) (fun h _ h' -> t_of b' == t /\ b' == b (h a) /\ h' (vbind a t b) == h b' ) = intro_vpure (t == t_of b'); intro_vdep a (vpure (t == t_of b') `star` b') (vbind0_payload a t b); intro_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); change_slprop_rel (vbind0 a t b) (vbind a t b) (fun x y -> x == y) (fun _ -> ()) let elim_vbind (#opened: _) (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost (Ghost.erased (t_of a)) opened (vbind a t b) (fun res -> a `star` b (Ghost.reveal res)) (fun h -> True) (fun h res h' -> h' a == Ghost.reveal res /\ t == t_of (b (Ghost.reveal res)) /\ h' (b (Ghost.reveal res)) == h (vbind a t b) ) = change_slprop_rel (vbind a t b) (vbind0 a t b) (fun x y -> x == y) (fun _ -> ()); elim_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); let res = elim_vdep a (vbind0_payload a t b) in change_equal_slprop (vbind0_payload a t b (Ghost.reveal res)) (vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res)); elim_vpure (t == t_of (b (Ghost.reveal res))); res let (==) (#a:_) (x y: a) : prop = x == y let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma (requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2])) (ensures (hd1 == hd2 /\ tl1 == tl2)) [SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])] = L.lemma_snoc_unsnoc (hd1, tl1); L.lemma_snoc_unsnoc (hd2, tl2) [@"opaque_to_smt"] let unsnoc (#a: Type) (l: list a) : Pure (list a & a) (requires (Cons? l)) (ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l)) = L.lemma_unsnoc_snoc l; L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)]; L.unsnoc l let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' < L.length l)) = fst (unsnoc l) let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l) [@@"opaque_to_smt"] let snoc (#a: Type) (l: list a) (x: a) : Pure (list a) (requires True) (ensures (fun l' -> Cons? l' /\ unsnoc_hd l' == l /\ unsnoc_tl l' == x )) = let l' = L.snoc (l, x) in L.append_length l [x]; snoc_inj l (unsnoc_hd l') x (unsnoc_tl l'); l' let snoc_unsnoc (#a: Type) (l: list a) : Lemma (requires (Cons? l)) (ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l)) = () unfold let coerce (#a: Type) (x: a) (b: Type) : Pure b (requires (a == b)) (ensures (fun y -> a == b /\ x == y)) = x (* END library *) let t a = cllist_lvalue a let v (a: Type0) = list a let datas (#a: Type0) (l: v a) : Tot (list a) = l (* view from the tail *) let llist_fragment_tail_cons_data_refine (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (d: a) : Tot prop = d == unsnoc_tl (Ghost.reveal l) [@@ __steel_reduce__] let llist_fragment_tail_cons_lvalue_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (c: ccell_lvalue a) : Tot vprop = vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l let ccell_is_lvalue_refine (a: Type) (c: ccell_ptrvalue a) : Tot prop = ccell_ptrvalue_is_null c == false [@@ __steel_reduce__ ] let llist_fragment_tail_cons_next_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (ptail: ref (ccell_ptrvalue a)) : Tot vprop = vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l [@@ __steel_reduce__ ] let llist_fragment_tail_cons_rewrite (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) }) (x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l)))) : Tot (ref (ccell_ptrvalue a)) = let (| _, (| c, _ |) |) = x in ccell_next c let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop (requires True) (ensures (fun v -> t_of v == ref (ccell_ptrvalue a))) (decreases (Ghost.reveal (L.length l))) = if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) let llist_fragment_tail_eq (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) = assert_norm (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) let llist_fragment_tail_eq_cons (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (requires (Cons? l)) (ensures (Cons? l /\ llist_fragment_tail l phead == ( llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) ))) = llist_fragment_tail_eq l phead unfold let sel_llist_fragment_tail (#a:Type) (#p:vprop) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) }) : GTot (ref (ccell_ptrvalue a)) = coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a)) val intro_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened emp (fun _ -> llist_fragment_tail l phead) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead) let intro_llist_fragment_tail_nil l phead = intro_vconst phead; change_equal_slprop (vconst phead) (llist_fragment_tail l phead) val elim_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l phead) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_tail l phead h == phead) let elim_llist_fragment_tail_nil l phead = change_equal_slprop (llist_fragment_tail l phead) (vconst phead); elim_vconst phead val intro_llist_fragment_tail_snoc (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (ptail: Ghost.erased (ref (ccell_ptrvalue a))) (tail: Ghost.erased (ccell_lvalue a)) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail)) (fun res -> llist_fragment_tail res phead) (fun h -> sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\ sel ptail h == Ghost.reveal tail ) (fun h res h' -> Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\ sel_llist_fragment_tail res phead h' == ccell_next tail ) #push-options "--z3rlimit 16" let intro_llist_fragment_tail_snoc #_ #a l phead ptail tail = let d = gget (vptr (ccell_data tail)) in let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l'); intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a); intro_vdep (vptr ptail `vrefine` ccell_is_lvalue_refine a) (vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l') (llist_fragment_tail_cons_lvalue_payload l'); change_equal_slprop (llist_fragment_tail l phead) (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead); intro_vdep (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead) (vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l') (llist_fragment_tail_cons_next_payload l'); intro_vrewrite_no_norm (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l') (llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)); llist_fragment_tail_eq_cons l' phead; change_equal_slprop (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)) (llist_fragment_tail l' phead); let g' = gget (llist_fragment_tail l' phead) in assert (Ghost.reveal g' == ccell_next tail); noop (); l' #pop-options [@@erasable] noeq type ll_unsnoc_t (a: Type) = { ll_unsnoc_l: list a; ll_unsnoc_ptail: ref (ccell_ptrvalue a); ll_unsnoc_tail: ccell_lvalue a; } val elim_llist_fragment_tail_snoc (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost (ll_unsnoc_t a) opened (llist_fragment_tail l phead) (fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail)) (fun _ -> Cons? l) (fun h res h' -> Cons? l /\ Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\ sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\ sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\ sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\ sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail) ) #push-options "--z3rlimit 32" #restart-solver let elim_llist_fragment_tail_snoc #_ #a l phead = let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in llist_fragment_tail_eq_cons l0 phead; change_equal_slprop (llist_fragment_tail l phead) (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)); elim_vrewrite_no_norm (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0) (llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)); let ptail = elim_vdep (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead) (llist_fragment_tail_cons_next_payload l0) in let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in change_equal_slprop (llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail)) (vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0); let tail = elim_vdep (vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a) (llist_fragment_tail_cons_lvalue_payload l0) in elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a); let res = { ll_unsnoc_l = unsnoc_hd l0; ll_unsnoc_ptail = Ghost.reveal ptail0; ll_unsnoc_tail = Ghost.reveal tail; } in change_equal_slprop (vptr (Ghost.reveal ptail0)) (vptr res.ll_unsnoc_ptail); change_equal_slprop (llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail)) (vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0); elim_vrefine (vptr (ccell_data res.ll_unsnoc_tail)) (llist_fragment_tail_cons_data_refine l0); change_equal_slprop (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead) (llist_fragment_tail res.ll_unsnoc_l phead); res #pop-options let rec llist_fragment_tail_append (#opened: _) (#a: Type) (phead0: ref (ccell_ptrvalue a)) (l1: Ghost.erased (list a)) (phead1: Ghost.erased (ref (ccell_ptrvalue a))) (l2: Ghost.erased (list a)) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1) (fun res -> llist_fragment_tail res phead0) (fun h -> Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h ) (fun h res h' -> Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\ (sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h ) (decreases (L.length (Ghost.reveal l2))) = let g1 = gget (llist_fragment_tail l1 phead0) in assert (Ghost.reveal phead1 == Ghost.reveal g1); if Nil? l2 then begin L.append_l_nil (Ghost.reveal l1); elim_llist_fragment_tail_nil l2 phead1; l1 end else begin let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d]; let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail end let queue_tail_refine (#a: Type) (tail1: ref (ccell_ptrvalue a)) (tail2: ref (ccell_ptrvalue a)) (tl: normal (t_of (vptr tail2))) : Tot prop = ccell_ptrvalue_is_null tl == true /\ tail1 == tail2 [@@__steel_reduce__] let queue_tail_dep2 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail1: t_of (llist_fragment_tail l (cllist_head x))) (tail2: ref (ccell_ptrvalue a)) : Tot vprop = vptr tail2 `vrefine` queue_tail_refine tail1 tail2 [@@__steel_reduce__] let queue_tail_dep1 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail1: t_of (llist_fragment_tail l (cllist_head x))) : Tot vprop = vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1 [@@__steel_reduce__; __reduce__] let queue_tail (#a: Type) (x: t a) (l: Ghost.erased (list a)) : Tot vprop = llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l val intro_queue_tail (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail) (fun _ -> queue_tail x l) (fun h -> sel_llist_fragment_tail l (cllist_head x) h == tail /\ sel (cllist_tail x) h == tail /\ ccell_ptrvalue_is_null (sel tail h) ) (fun _ _ _ -> True) let intro_queue_tail x l tail = intro_vrefine (vptr tail) (queue_tail_refine tail tail); intro_vdep2 (vptr (cllist_tail x)) (vptr tail `vrefine` queue_tail_refine tail tail) tail (queue_tail_dep2 x l tail); intro_vdep2 (llist_fragment_tail l (cllist_head x)) (vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail) tail (queue_tail_dep1 x l) val elim_queue_tail (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) : SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened (queue_tail x l) (fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail) (fun h -> True) (fun _ tail h -> sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\ sel (cllist_tail x) h == Ghost.reveal tail /\ ccell_ptrvalue_is_null (h (vptr tail)) ) let elim_queue_tail #_ #a x l = let tail0 = elim_vdep (llist_fragment_tail l (cllist_head x)) (queue_tail_dep1 x l) in let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in change_equal_slprop (queue_tail_dep1 x l (Ghost.reveal tail0)) (vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0); let tail2 = elim_vdep (vptr (cllist_tail x)) (queue_tail_dep2 x l tail0) in let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in change_equal_slprop (queue_tail_dep2 x l tail0 (Ghost.reveal tail2)) (vptr tail3 `vrefine` queue_tail_refine tail0 tail3); elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3); change_equal_slprop (vptr tail3) (vptr tail); tail (* view from the head *) let llist_fragment_head_data_refine (#a: Type) (d: a) (c: vcell a) : Tot prop = c.vcell_data == d let llist_fragment_head_payload (#a: Type) (head: ccell_ptrvalue a) (d: a) (llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop)) (x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d))) : Tot vprop = llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop (decreases (Ghost.reveal l)) = if Nil? l then vconst (phead, head) else vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l)))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l)))) let t_of_llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Lemma (t_of (llist_fragment_head l phead head) == ref (ccell_ptrvalue a) & ccell_ptrvalue a) = () unfold let sel_llist_fragment_head (#a:Type) (#p:vprop) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) (h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_head l phead head) /\ True) }) : GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) val intro_llist_fragment_head_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost unit opened emp (fun _ -> llist_fragment_head l phead head) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head)) let intro_llist_fragment_head_nil l phead head = intro_vconst (phead, head); change_equal_slprop (vconst (phead, head)) (llist_fragment_head l phead head) val elim_llist_fragment_head_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost unit opened (llist_fragment_head l phead head) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_head l phead head h == (phead, head)) let elim_llist_fragment_head_nil l phead head = change_equal_slprop (llist_fragment_head l phead head) (vconst (phead, head)); elim_vconst (phead, head) let llist_fragment_head_eq_cons (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Lemma (requires (Cons? (Ghost.reveal l))) (ensures ( llist_fragment_head l phead head == vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l)))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l)))) )) = assert_norm (llist_fragment_head l phead head == ( if Nil? l then vconst (phead, head) else vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l)))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l)))) )) val intro_llist_fragment_head_cons (#opened: _) (#a: Type) (phead: ref (ccell_ptrvalue a)) (head: ccell_lvalue a) (next: (ccell_ptrvalue a)) (tl: Ghost.erased (list a)) : SteelGhost (Ghost.erased (list a)) opened (ccell head `star` llist_fragment_head tl (ccell_next head) next) (fun res -> llist_fragment_head res phead head) (fun h -> (h (ccell head)).vcell_next == next) (fun h res h' -> Ghost.reveal res == (h (ccell head)).vcell_data :: Ghost.reveal tl /\ h' (llist_fragment_head res phead head) == h (llist_fragment_head tl (ccell_next head) next) ) let intro_llist_fragment_head_cons #_ #a phead head next tl = let vc = gget (ccell head) in let l' : (l' : Ghost.erased (list a) { Cons? l' }) = Ghost.hide (vc.vcell_data :: tl) in intro_ccell_is_lvalue head; intro_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l')); intro_vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l'))) (llist_fragment_head tl (ccell_next head) next) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l'))); llist_fragment_head_eq_cons l' phead head; change_equal_slprop (vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l'))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l')))) (llist_fragment_head l' phead head); l' [@@erasable] noeq type ll_uncons_t (a: Type) = { ll_uncons_pnext: Ghost.erased (ref (ccell_ptrvalue a)); ll_uncons_next: Ghost.erased (ccell_ptrvalue a); ll_uncons_tl: Ghost.erased (list a); } val elim_llist_fragment_head_cons (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost (ll_uncons_t a) opened (llist_fragment_head l phead head) (fun res -> ccell head `star` llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next) (fun _ -> Cons? (Ghost.reveal l)) (fun h res h' -> ccell_ptrvalue_is_null head == false /\ Ghost.reveal l == (h' (ccell head)).vcell_data :: Ghost.reveal res.ll_uncons_tl /\ Ghost.reveal res.ll_uncons_pnext == ccell_next head /\ Ghost.reveal res.ll_uncons_next == (h' (ccell head)).vcell_next /\ h' (llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next) == h (llist_fragment_head l phead head) ) let elim_llist_fragment_head_cons #_ #a l0 phead head = let l : (l : Ghost.erased (list a) { Cons? l }) = l0 in change_equal_slprop (llist_fragment_head l0 phead head) (llist_fragment_head l phead head); llist_fragment_head_eq_cons l phead head; change_equal_slprop (llist_fragment_head l phead head) (vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)))); let x = elim_vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l))) in let head2 = gget (ccell_is_lvalue head) in elim_ccell_is_lvalue head; elim_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l)); let vhead2 = gget (ccell head) in let res = { ll_uncons_pnext = ccell_next head2; ll_uncons_next = vhead2.vcell_next; ll_uncons_tl = L.tl l; } in change_equal_slprop (llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)) (Ghost.reveal x)) (llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next); res let rec llist_fragment_head_append (#opened: _) (#a: Type) (l1: Ghost.erased (list a)) (phead1: ref (ccell_ptrvalue a)) (head1: ccell_ptrvalue a) (l2: Ghost.erased (list a)) (phead2: ref (ccell_ptrvalue a)) (head2: ccell_ptrvalue a) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_head l1 phead1 head1 `star` llist_fragment_head l2 phead2 head2) (fun l -> llist_fragment_head l phead1 head1) (fun h -> sel_llist_fragment_head l1 phead1 head1 h == (Ghost.reveal phead2, Ghost.reveal head2)) (fun h l h' -> Ghost.reveal l == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\ h' (llist_fragment_head l phead1 head1) == h (llist_fragment_head l2 phead2 head2) ) (decreases (Ghost.reveal l1)) = if Nil? l1 then begin elim_llist_fragment_head_nil l1 phead1 head1; change_equal_slprop (llist_fragment_head l2 phead2 head2) (llist_fragment_head l2 phead1 head1); l2 end else begin let u = elim_llist_fragment_head_cons l1 phead1 head1 in let head1' : Ghost.erased (ccell_lvalue a) = head1 in let l3 = llist_fragment_head_append u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next l2 phead2 head2 in change_equal_slprop (llist_fragment_head l3 u.ll_uncons_pnext u.ll_uncons_next) (llist_fragment_head l3 (ccell_next head1') u.ll_uncons_next); change_equal_slprop (ccell head1) (ccell head1'); let l4 = intro_llist_fragment_head_cons phead1 head1' u.ll_uncons_next l3 in change_equal_slprop (llist_fragment_head l4 phead1 head1') (llist_fragment_head l4 phead1 head1); l4 end let rec llist_fragment_head_to_tail (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened (vptr phead `star` llist_fragment_head l phead head) (fun res -> llist_fragment_tail l phead `star` vptr res) (fun h -> h (vptr phead) == head) (fun h res h' -> let v = sel_llist_fragment_head l phead head h in fst v == Ghost.reveal res /\ fst v == sel_llist_fragment_tail l phead h' /\ snd v == h' (vptr res) ) (decreases (L.length (Ghost.reveal l))) = if Nil? l then begin let ptail = Ghost.hide phead in let gh = gget (vptr phead) in assert (Ghost.reveal gh == head); elim_llist_fragment_head_nil l phead head; intro_llist_fragment_tail_nil l phead; change_equal_slprop (vptr phead) (vptr ptail); ptail end else begin intro_llist_fragment_tail_nil [] phead; change_equal_slprop (vptr phead) (vptr (Ghost.reveal (Ghost.hide phead))); let uc = elim_llist_fragment_head_cons l phead head in let head' = elim_ccell_ghost head in change_equal_slprop (vptr (ccell_next head')) (vptr uc.ll_uncons_pnext); let lc = intro_llist_fragment_tail_snoc [] phead phead head' in let ptail = llist_fragment_head_to_tail uc.ll_uncons_tl uc.ll_uncons_pnext uc.ll_uncons_next in let l' = llist_fragment_tail_append phead lc uc.ll_uncons_pnext uc.ll_uncons_tl in change_equal_slprop (llist_fragment_tail l' phead) (llist_fragment_tail l phead); ptail end #push-options "--z3rlimit 16" #restart-solver let rec llist_fragment_tail_to_head (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (ptail: ref (ccell_ptrvalue a)) : SteelGhost (Ghost.erased (ccell_ptrvalue a)) opened (llist_fragment_tail l phead `star` vptr ptail) (fun head -> vptr phead `star` llist_fragment_head l phead (Ghost.reveal head)) (fun h -> Ghost.reveal ptail == sel_llist_fragment_tail l phead h) (fun h head h' -> let v = sel_llist_fragment_head l phead head h' in fst v == ptail /\ snd v == h (vptr ptail) /\ h' (vptr phead) == Ghost.reveal head ) (decreases (L.length (Ghost.reveal l))) = if Nil? l then begin let g = gget (llist_fragment_tail l phead) in assert (Ghost.reveal g == ptail); elim_llist_fragment_tail_nil l phead; change_equal_slprop (vptr ptail) (vptr phead); let head = gget (vptr phead) in intro_llist_fragment_head_nil l phead head; head end else begin let us = elim_llist_fragment_tail_snoc l phead in let tail = gget (vptr ptail) in assert (ccell_next us.ll_unsnoc_tail == ptail); intro_llist_fragment_head_nil [] (ccell_next us.ll_unsnoc_tail) tail; change_equal_slprop (vptr ptail) (vptr (ccell_next us.ll_unsnoc_tail)); intro_ccell us.ll_unsnoc_tail; let lc = intro_llist_fragment_head_cons us.ll_unsnoc_ptail us.ll_unsnoc_tail tail [] in let head = llist_fragment_tail_to_head us.ll_unsnoc_l phead us.ll_unsnoc_ptail in let g = gget (llist_fragment_head us.ll_unsnoc_l phead head) in let g : Ghost.erased (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = Ghost.hide (Ghost.reveal g) in assert (Ghost.reveal g == (Ghost.reveal us.ll_unsnoc_ptail, Ghost.reveal us.ll_unsnoc_tail)); let l' = llist_fragment_head_append us.ll_unsnoc_l phead head lc us.ll_unsnoc_ptail us.ll_unsnoc_tail in change_equal_slprop (llist_fragment_head l' phead head) (llist_fragment_head l phead head); head end #pop-options val llist_fragment_head_is_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost unit opened (llist_fragment_head l phead head) (fun _ -> llist_fragment_head l phead head) (fun h -> ccell_ptrvalue_is_null (snd (sel_llist_fragment_head l phead head h)) == true) (fun h _ h' -> Nil? l == ccell_ptrvalue_is_null head /\ h' (llist_fragment_head l phead head) == h (llist_fragment_head l phead head) ) let llist_fragment_head_is_nil l phead head = if Nil? l then begin elim_llist_fragment_head_nil l phead head; assert (ccell_ptrvalue_is_null head == true); intro_llist_fragment_head_nil l phead head end else begin let r = elim_llist_fragment_head_cons l phead head in let head2 : ccell_lvalue _ = head in change_equal_slprop (llist_fragment_head r.ll_uncons_tl r.ll_uncons_pnext r.ll_uncons_next) (llist_fragment_head r.ll_uncons_tl (ccell_next head2) r.ll_uncons_next); change_equal_slprop (ccell head) (ccell head2); let l' = intro_llist_fragment_head_cons phead head2 r.ll_uncons_next r.ll_uncons_tl in change_equal_slprop (llist_fragment_head l' phead head2) (llist_fragment_head l phead head) end val llist_fragment_head_cons_change_phead (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) (phead' : ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_head l phead head) (fun _ -> llist_fragment_head l phead' head) (fun _ -> Cons? l) (fun h _ h' -> h' (llist_fragment_head l phead' head) == h (llist_fragment_head l phead head)) let llist_fragment_head_cons_change_phead l phead head phead' = let u = elim_llist_fragment_head_cons l phead head in let head2 : ccell_lvalue _ = head in change_equal_slprop (ccell head) (ccell head2); change_equal_slprop (llist_fragment_head u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next) (llist_fragment_head u.ll_uncons_tl (ccell_next head2) u.ll_uncons_next); let l' = intro_llist_fragment_head_cons phead' head2 u.ll_uncons_next u.ll_uncons_tl in change_equal_slprop (llist_fragment_head l' phead' head2) (llist_fragment_head l phead' head) let queue_head_refine (#a: Type) (x: t a) (l: Ghost.erased (list a)) (hd: ccell_ptrvalue a) (ptl: t_of (llist_fragment_head l (cllist_head x) hd)) (tl: ref (ccell_ptrvalue a)) : Tot prop = let ptl : (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = ptl in tl == fst ptl /\ ccell_ptrvalue_is_null (snd ptl) == true let queue_head_dep1 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (hd: ccell_ptrvalue a) (ptl: t_of (llist_fragment_head l (cllist_head x) hd)) : Tot vprop = vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl let queue_head_dep2 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (hd: ccell_ptrvalue a) : Tot vprop = llist_fragment_head l (cllist_head x) hd `vdep` queue_head_dep1 x l hd [@@__reduce__] let queue_head (#a: Type) (x: t a) (l: Ghost.erased (list a)) : Tot vprop = vptr (cllist_head x) `vdep` queue_head_dep2 x l val intro_queue_head (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) (hd: Ghost.erased (ccell_ptrvalue a)) : SteelGhost unit opened (vptr (cllist_head x) `star` llist_fragment_head l (cllist_head x) hd `star` vptr (cllist_tail x)) (fun _ -> queue_head x l) (fun h -> ( let frag = (sel_llist_fragment_head l (cllist_head x) hd) h in sel (cllist_head x) h == Ghost.reveal hd /\ sel (cllist_tail x) h == fst frag /\ ccell_ptrvalue_is_null (snd frag) == true )) (fun _ _ _ -> True) let intro_queue_head #_ #a x l hd = let ptl = gget (llist_fragment_head l (cllist_head x) hd) in intro_vrefine (vptr (cllist_tail x)) (queue_head_refine x l hd ptl); assert_norm (vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl == queue_head_dep1 x l hd ptl); intro_vdep (llist_fragment_head l (cllist_head x) hd) (vptr (cllist_tail x) `vrefine` queue_head_refine x l hd ptl) (queue_head_dep1 x l hd); intro_vdep (vptr (cllist_head x)) (llist_fragment_head l (cllist_head x) hd `vdep` queue_head_dep1 x l hd) (queue_head_dep2 x l) val elim_queue_head (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) : SteelGhost (Ghost.erased (ccell_ptrvalue a)) opened (queue_head x l) (fun hd -> vptr (cllist_head x) `star` llist_fragment_head l (cllist_head x) hd `star` vptr (cllist_tail x)) (fun _ -> True) (fun _ hd h -> ( let frag = (sel_llist_fragment_head l (cllist_head x) hd) h in sel (cllist_head x) h == Ghost.reveal hd /\ sel (cllist_tail x) h == fst frag /\ ccell_ptrvalue_is_null (snd frag) == true )) let elim_queue_head #_ #a x l = let hd = elim_vdep (vptr (cllist_head x)) (queue_head_dep2 x l) in let ptl = elim_vdep (llist_fragment_head l (cllist_head x) hd) (queue_head_dep1 x l hd) in elim_vrefine (vptr (cllist_tail x)) (queue_head_refine x l hd ptl); hd let queue_head_to_tail (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) : SteelGhostT unit opened (queue_head x l) (fun _ -> queue_tail x l) = let hd = elim_queue_head x l in let tl = llist_fragment_head_to_tail l (cllist_head x) hd in intro_queue_tail x l tl let queue_tail_to_head (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) : SteelGhostT unit opened (queue_tail x l) (fun _ -> queue_head x l) = let tl = elim_queue_tail x l in let hd = llist_fragment_tail_to_head l (cllist_head x) tl in intro_queue_head x l hd (* We choose the head representation, since queue_is_empty and dequeue need the head representation, but only enqueue needs the tail representation. *) [@@__reduce__] let queue x l = queue_head x l
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.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
a: Type0 -> Steel.Effect.Steel (CQueue.t a * FStar.Ghost.erased (CQueue.v a))
Steel.Effect.Steel
[]
[]
[ "Steel.Effect.Atomic.return", "FStar.Pervasives.Native.tuple2", "CQueue.t", "FStar.Ghost.erased", "CQueue.v", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Effect.Common.vdep", "Steel.Reference.vptrp", "CQueue.Cell.ccell_ptrvalue", "CQueue.LList.cllist_head", "Steel.FractionalPermission.full_perm", "CQueue.queue_head_dep2", "Steel.Effect.Common.vprop", "Prims.unit", "Steel.Effect.Atomic.change_equal_slprop", "CQueue.queue_head", "Prims.list", "Prims.Nil", "CQueue.queue", "FStar.Pervasives.Native.fst", "FStar.Pervasives.Native.snd", "FStar.Pervasives.Native.Mktuple2", "CQueue.intro_queue_head", "CQueue.intro_llist_fragment_head_nil", "FStar.Ghost.reveal", "Steel.Reference.write", "Steel.Reference.ref", "CQueue.LList.cllist_tail", "CQueue.LList.cllist_lvalue", "CQueue.LList.elim_cllist", "CQueue.LList.alloc_llist", "Steel.Reference.null", "CQueue.Cell.ccell_ptrvalue_null" ]
[]
false
true
false
false
false
let create_queue a =
let head = ccell_ptrvalue_null a in let tail:ref (ccell_ptrvalue a) = null in let l0 = alloc_llist head tail in let l = elim_cllist l0 in write (cllist_tail l) (cllist_head l); intro_llist_fragment_head_nil [] (cllist_head l) (Ghost.reveal (Ghost.hide head)); intro_queue_head l [] head; let res:(t a & Ghost.erased (v a)) = (l0, Ghost.hide []) in change_equal_slprop (queue_head l []) (queue (fst res) (snd res)); return res
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.read_bounded_integer_le
val read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i))
val read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i))
let read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_le_1 | 2 -> read_bounded_integer_le_2 | 3 -> read_bounded_integer_le_3 | 4 -> read_bounded_integer_le_4
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 34, "end_line": 372, "start_col": 0, "start_line": 363 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos ) inline_for_extraction let validate_u16_le () : validator parse_u16_le = validate_total_constant_size parse_u16_le 2uL () inline_for_extraction let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le = validate_total_constant_size_with_error_code parse_u16_le 2uL c inline_for_extraction let validate_u32_le () : validator parse_u32_le = validate_total_constant_size parse_u32_le 4uL () inline_for_extraction let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le = validate_total_constant_size_with_error_code parse_u32_le 4uL c inline_for_extraction let jump_u16_le : jumper parse_u16_le = jump_constant_size parse_u16_le 2ul () inline_for_extraction let jump_u32_le : jumper parse_u32_le = jump_constant_size parse_u32_le 4ul () inline_for_extraction val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1) inline_for_extraction val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2) inline_for_extraction val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3) inline_for_extraction val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4) inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
i: LowParse.Spec.BoundedInt.integer_size -> LowParse.Low.Base.leaf_reader (LowParse.Spec.BoundedInt.parse_bounded_integer_le i)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Low.BoundedInt.read_bounded_integer_le_1", "LowParse.Low.BoundedInt.read_bounded_integer_le_2", "LowParse.Low.BoundedInt.read_bounded_integer_le_3", "LowParse.Low.BoundedInt.read_bounded_integer_le_4", "LowParse.Low.Base.leaf_reader", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "Prims.unit", "LowParse.Spec.BoundedInt.integer_size_values" ]
[]
false
false
false
false
false
let read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i)) =
[@@ inline_let ]let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_le_1 | 2 -> read_bounded_integer_le_2 | 3 -> read_bounded_integer_le_3 | 4 -> read_bounded_integer_le_4
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.jump_bounded_int32
val jump_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val jump_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos )
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 323, "start_col": 0, "start_line": 311 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.Low.Base.jumper (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32) (FStar.UInt32.v max32))
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "LowParse.Low.BoundedInt.jump_bounded_int32_1", "Prims.bool", "LowParse.Low.BoundedInt.jump_bounded_int32_2", "LowParse.Low.BoundedInt.jump_bounded_int32_3", "LowParse.Low.BoundedInt.jump_bounded_int32_4", "LowParse.Low.Base.jumper", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32" ]
[]
false
false
false
false
false
let jump_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) =
fun #rrel #rel sl pos -> (if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos)
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_integer_le
val write_bounded_integer_le (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer_le i))
val write_bounded_integer_le (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer_le i))
let write_bounded_integer_le (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer_le i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_le_1 | 2 -> write_bounded_integer_le_2 | 3 -> write_bounded_integer_le_3 | 4 -> write_bounded_integer_le_4
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 35, "end_line": 415, "start_col": 0, "start_line": 406 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos ) inline_for_extraction let validate_u16_le () : validator parse_u16_le = validate_total_constant_size parse_u16_le 2uL () inline_for_extraction let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le = validate_total_constant_size_with_error_code parse_u16_le 2uL c inline_for_extraction let validate_u32_le () : validator parse_u32_le = validate_total_constant_size parse_u32_le 4uL () inline_for_extraction let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le = validate_total_constant_size_with_error_code parse_u32_le 4uL c inline_for_extraction let jump_u16_le : jumper parse_u16_le = jump_constant_size parse_u16_le 2ul () inline_for_extraction let jump_u32_le : jumper parse_u32_le = jump_constant_size parse_u32_le 4ul () inline_for_extraction val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1) inline_for_extraction val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2) inline_for_extraction val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3) inline_for_extraction val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4) inline_for_extraction noextract let read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_le_1 | 2 -> read_bounded_integer_le_2 | 3 -> read_bounded_integer_le_3 | 4 -> read_bounded_integer_le_4 inline_for_extraction val read_u16_le : leaf_reader parse_u16_le inline_for_extraction val read_u32_le : leaf_reader parse_u32_le inline_for_extraction val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) inline_for_extraction val write_bounded_integer_le_1 : leaf_writer_strong (serialize_bounded_integer_le 1) inline_for_extraction val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) inline_for_extraction val write_bounded_integer_le_2 : leaf_writer_strong (serialize_bounded_integer_le 2) inline_for_extraction val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) inline_for_extraction val write_bounded_integer_le_3 : leaf_writer_strong (serialize_bounded_integer_le 3) inline_for_extraction val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) inline_for_extraction val write_bounded_integer_le_4 : leaf_writer_strong (serialize_bounded_integer_le 4) inline_for_extraction
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
i: LowParse.Spec.BoundedInt.integer_size -> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_integer_le i)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.Low.BoundedInt.write_bounded_integer_le_1", "LowParse.Low.BoundedInt.write_bounded_integer_le_2", "LowParse.Low.BoundedInt.write_bounded_integer_le_3", "LowParse.Low.BoundedInt.write_bounded_integer_le_4", "LowParse.Low.Base.leaf_writer_strong", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.BoundedInt.serialize_bounded_integer_le", "Prims.unit", "LowParse.Spec.BoundedInt.integer_size_values" ]
[]
false
false
false
false
false
let write_bounded_integer_le (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer_le i)) =
[@@ inline_let ]let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_le_1 | 2 -> write_bounded_integer_le_2 | 3 -> write_bounded_integer_le_3 | 4 -> write_bounded_integer_le_4
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.validate_u16_le_with_error_code
val validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le
val validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le = validate_total_constant_size_with_error_code parse_u16_le 2uL c
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 65, "end_line": 331, "start_col": 0, "start_line": 330 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos ) inline_for_extraction let validate_u16_le () : validator parse_u16_le = validate_total_constant_size parse_u16_le 2uL ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
c: LowParse.Low.ErrorCode.error_code -> LowParse.Low.Base.validator LowParse.Spec.BoundedInt.parse_u16_le
Prims.Tot
[ "total" ]
[]
[ "LowParse.Low.ErrorCode.error_code", "LowParse.Low.Base.validate_total_constant_size_with_error_code", "LowParse.Spec.Int.parse_u16_kind", "FStar.UInt16.t", "LowParse.Spec.BoundedInt.parse_u16_le", "FStar.UInt64.__uint_to_t", "LowParse.Low.Base.validator" ]
[]
false
false
false
true
false
let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le =
validate_total_constant_size_with_error_code parse_u16_le 2uL c
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.validate_u16_le
val validate_u16_le: Prims.unit -> validator parse_u16_le
val validate_u16_le: Prims.unit -> validator parse_u16_le
let validate_u16_le () : validator parse_u16_le = validate_total_constant_size parse_u16_le 2uL ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 50, "end_line": 327, "start_col": 0, "start_line": 326 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
_: Prims.unit -> LowParse.Low.Base.validator LowParse.Spec.BoundedInt.parse_u16_le
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "LowParse.Low.Base.validate_total_constant_size", "LowParse.Spec.Int.parse_u16_kind", "FStar.UInt16.t", "LowParse.Spec.BoundedInt.parse_u16_le", "FStar.UInt64.__uint_to_t", "LowParse.Low.Base.validator" ]
[]
false
false
false
true
false
let validate_u16_le () : validator parse_u16_le =
validate_total_constant_size parse_u16_le 2uL ()
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.validate_u32_le_with_error_code
val validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le
val validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le
let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le = validate_total_constant_size_with_error_code parse_u32_le 4uL c
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 65, "end_line": 339, "start_col": 0, "start_line": 338 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos ) inline_for_extraction let validate_u16_le () : validator parse_u16_le = validate_total_constant_size parse_u16_le 2uL () inline_for_extraction let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le = validate_total_constant_size_with_error_code parse_u16_le 2uL c inline_for_extraction let validate_u32_le () : validator parse_u32_le = validate_total_constant_size parse_u32_le 4uL ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
c: LowParse.Low.ErrorCode.error_code -> LowParse.Low.Base.validator LowParse.Spec.BoundedInt.parse_u32_le
Prims.Tot
[ "total" ]
[]
[ "LowParse.Low.ErrorCode.error_code", "LowParse.Low.Base.validate_total_constant_size_with_error_code", "LowParse.Spec.Int.parse_u32_kind", "FStar.UInt32.t", "LowParse.Spec.BoundedInt.parse_u32_le", "FStar.UInt64.__uint_to_t", "LowParse.Low.Base.validator" ]
[]
false
false
false
true
false
let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le =
validate_total_constant_size_with_error_code parse_u32_le 4uL c
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.jump_u16_le
val jump_u16_le:jumper parse_u16_le
val jump_u16_le:jumper parse_u16_le
let jump_u16_le : jumper parse_u16_le = jump_constant_size parse_u16_le 2ul ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 40, "end_line": 343, "start_col": 0, "start_line": 342 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos ) inline_for_extraction let validate_u16_le () : validator parse_u16_le = validate_total_constant_size parse_u16_le 2uL () inline_for_extraction let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le = validate_total_constant_size_with_error_code parse_u16_le 2uL c inline_for_extraction let validate_u32_le () : validator parse_u32_le = validate_total_constant_size parse_u32_le 4uL () inline_for_extraction let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le = validate_total_constant_size_with_error_code parse_u32_le 4uL c
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
LowParse.Low.Base.jumper LowParse.Spec.BoundedInt.parse_u16_le
Prims.Tot
[ "total" ]
[]
[ "LowParse.Low.Base.jump_constant_size", "LowParse.Spec.Int.parse_u16_kind", "FStar.UInt16.t", "LowParse.Spec.BoundedInt.parse_u16_le", "FStar.UInt32.__uint_to_t" ]
[]
false
false
false
true
false
let jump_u16_le:jumper parse_u16_le =
jump_constant_size parse_u16_le 2ul ()
false
LowParse.SLow.Tac.Enum.fst
LowParse.SLow.Tac.Enum.parse32_maybe_enum_key_tac
val parse32_maybe_enum_key_tac: #k: parser_kind -> #key: eqtype -> #repr: eqtype -> #p: parser k repr -> p32: parser32 p -> e: enum key repr {Cons? e} -> Prims.unit -> T.Tac unit
val parse32_maybe_enum_key_tac: #k: parser_kind -> #key: eqtype -> #repr: eqtype -> #p: parser k repr -> p32: parser32 p -> e: enum key repr {Cons? e} -> Prims.unit -> T.Tac unit
let parse32_maybe_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (parse32_maybe_enum_key_gen #k #key #repr #p p32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> maybe_enum_key_of_repr_tac #key #repr e); ]
{ "file_name": "src/lowparse/LowParse.SLow.Tac.Enum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 37, "start_col": 0, "start_line": 22 }
module LowParse.SLow.Tac.Enum include LowParse.Spec.Tac.Enum include LowParse.SLow.Enum module T = LowParse.TacLib // // The enum tactic solves goals of type ?u:eqtype with enum types that are // in the environment at type Type0 // So typechecking such uvars fails since F* 2635 bug fix // (since uvar solutions are checked with smt off) // // To circumvent that, we use t_apply with tc_resolve_uvars flag on, // so that ?u will be typechecked as soon as it is resolved, // resulting in an smt guard that will be added to the proofstate // let apply (t:T.term) : T.Tac unit = T.t_apply true false true t
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.TacLib.fst.checked", "LowParse.Spec.Tac.Enum.fst.checked", "LowParse.SLow.Enum.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Tac.Enum.fst" }
[ { "abbrev": true, "full_module": "LowParse.TacLib", "short_module": "T" }, { "abbrev": false, "full_module": "LowParse.SLow.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Tac.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": 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
p32: LowParse.SLow.Base.parser32 p -> e: LowParse.Spec.Enum.enum key repr {Cons? e} -> _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.Spec.Enum.enum", "Prims.b2t", "Prims.uu___is_Cons", "FStar.Pervasives.Native.tuple2", "Prims.unit", "FStar.Tactics.V1.Derived.iseq", "Prims.Cons", "LowParse.TacLib.solve_vc", "LowParse.Spec.Tac.Enum.maybe_enum_key_of_repr_tac", "Prims.Nil", "LowParse.SLow.Tac.Enum.apply", "FStar.Stubs.Reflection.Types.term", "LowParse.SLow.Enum.parse32_maybe_enum_key_gen" ]
[]
false
true
false
false
false
let parse32_maybe_enum_key_tac (#k: parser_kind) (#key: eqtype) (#repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr {Cons? e}) () : T.Tac unit =
let fu = quote (parse32_maybe_enum_key_gen #k #key #repr #p p32 e) in apply fu; T.iseq [T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> maybe_enum_key_of_repr_tac #key #repr e)]
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.validate_bounded_int32
val validate_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
val validate_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos )
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 288, "start_col": 0, "start_line": 276 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.Low.Base.validator (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt64.t", "LowParse.Low.BoundedInt.validate_bounded_int32_1", "Prims.bool", "LowParse.Low.BoundedInt.validate_bounded_int32_2", "LowParse.Low.BoundedInt.validate_bounded_int32_3", "LowParse.Low.BoundedInt.validate_bounded_int32_4", "LowParse.Low.Base.validator", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32" ]
[]
false
false
false
false
false
let validate_bounded_int32 (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) =
fun #rrel #rel sl pos -> (if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos)
false
LowParse.SLow.Tac.Enum.fst
LowParse.SLow.Tac.Enum.apply
val apply (t: T.term) : T.Tac unit
val apply (t: T.term) : T.Tac unit
let apply (t:T.term) : T.Tac unit = T.t_apply true false true t
{ "file_name": "src/lowparse/LowParse.SLow.Tac.Enum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 29, "end_line": 19, "start_col": 0, "start_line": 18 }
module LowParse.SLow.Tac.Enum include LowParse.Spec.Tac.Enum include LowParse.SLow.Enum module T = LowParse.TacLib // // The enum tactic solves goals of type ?u:eqtype with enum types that are // in the environment at type Type0 // So typechecking such uvars fails since F* 2635 bug fix // (since uvar solutions are checked with smt off) // // To circumvent that, we use t_apply with tc_resolve_uvars flag on, // so that ?u will be typechecked as soon as it is resolved, // resulting in an smt guard that will be added to the proofstate //
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.TacLib.fst.checked", "LowParse.Spec.Tac.Enum.fst.checked", "LowParse.SLow.Enum.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Tac.Enum.fst" }
[ { "abbrev": true, "full_module": "LowParse.TacLib", "short_module": "T" }, { "abbrev": false, "full_module": "LowParse.SLow.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Tac.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": 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
t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Tactics.V1.Builtins.t_apply", "Prims.unit" ]
[]
false
true
false
false
false
let apply (t: T.term) : T.Tac unit =
T.t_apply true false true t
false
LowParse.SLow.Tac.Enum.fst
LowParse.SLow.Tac.Enum.serialize32_enum_key_gen_tac
val serialize32_enum_key_gen_tac: #k: parser_kind -> #key: eqtype -> #repr: eqtype -> #p: parser k repr -> #s: serializer p -> s32: serializer32 s -> e: enum key repr {Cons? e} -> Prims.unit -> T.Tac unit
val serialize32_enum_key_gen_tac: #k: parser_kind -> #key: eqtype -> #repr: eqtype -> #p: parser k repr -> #s: serializer p -> s32: serializer32 s -> e: enum key repr {Cons? e} -> Prims.unit -> T.Tac unit
let serialize32_enum_key_gen_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (serialize32_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e); ]
{ "file_name": "src/lowparse/LowParse.SLow.Tac.Enum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 76, "start_col": 0, "start_line": 59 }
module LowParse.SLow.Tac.Enum include LowParse.Spec.Tac.Enum include LowParse.SLow.Enum module T = LowParse.TacLib // // The enum tactic solves goals of type ?u:eqtype with enum types that are // in the environment at type Type0 // So typechecking such uvars fails since F* 2635 bug fix // (since uvar solutions are checked with smt off) // // To circumvent that, we use t_apply with tc_resolve_uvars flag on, // so that ?u will be typechecked as soon as it is resolved, // resulting in an smt guard that will be added to the proofstate // let apply (t:T.term) : T.Tac unit = T.t_apply true false true t noextract let parse32_maybe_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (parse32_maybe_enum_key_gen #k #key #repr #p p32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> maybe_enum_key_of_repr_tac #key #repr e); ] noextract let parse32_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) () : T.Tac unit = T.tassert (Cons? e); let fu = quote (parse32_enum_key_gen #k #key #repr p e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> parse32_maybe_enum_key_tac p32 e ()) ]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.TacLib.fst.checked", "LowParse.Spec.Tac.Enum.fst.checked", "LowParse.SLow.Enum.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Tac.Enum.fst" }
[ { "abbrev": true, "full_module": "LowParse.TacLib", "short_module": "T" }, { "abbrev": false, "full_module": "LowParse.SLow.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Tac.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": 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
s32: LowParse.SLow.Base.serializer32 s -> e: LowParse.Spec.Enum.enum key repr {Cons? e} -> _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "LowParse.Spec.Enum.enum", "Prims.b2t", "Prims.uu___is_Cons", "FStar.Pervasives.Native.tuple2", "Prims.unit", "FStar.Tactics.V1.Derived.iseq", "Prims.Cons", "LowParse.TacLib.solve_vc", "LowParse.Spec.Tac.Enum.enum_repr_of_key_tac", "Prims.Nil", "LowParse.SLow.Tac.Enum.apply", "FStar.Stubs.Reflection.Types.term", "LowParse.SLow.Enum.serialize32_enum_key_gen" ]
[]
false
true
false
false
false
let serialize32_enum_key_gen_tac (#k: parser_kind) (#key: eqtype) (#repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr {Cons? e}) () : T.Tac unit =
let fu = quote (serialize32_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e)]
false
LowParse.SLow.Tac.Enum.fst
LowParse.SLow.Tac.Enum.serialize32_maybe_enum_key_tac
val serialize32_maybe_enum_key_tac: #k: parser_kind -> #key: eqtype -> #repr: eqtype -> #p: parser k repr -> #s: serializer p -> s32: serializer32 s -> e: enum key repr {Cons? e} -> Prims.unit -> T.Tac unit
val serialize32_maybe_enum_key_tac: #k: parser_kind -> #key: eqtype -> #repr: eqtype -> #p: parser k repr -> #s: serializer p -> s32: serializer32 s -> e: enum key repr {Cons? e} -> Prims.unit -> T.Tac unit
let serialize32_maybe_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (serialize32_maybe_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e); ]
{ "file_name": "src/lowparse/LowParse.SLow.Tac.Enum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 96, "start_col": 0, "start_line": 79 }
module LowParse.SLow.Tac.Enum include LowParse.Spec.Tac.Enum include LowParse.SLow.Enum module T = LowParse.TacLib // // The enum tactic solves goals of type ?u:eqtype with enum types that are // in the environment at type Type0 // So typechecking such uvars fails since F* 2635 bug fix // (since uvar solutions are checked with smt off) // // To circumvent that, we use t_apply with tc_resolve_uvars flag on, // so that ?u will be typechecked as soon as it is resolved, // resulting in an smt guard that will be added to the proofstate // let apply (t:T.term) : T.Tac unit = T.t_apply true false true t noextract let parse32_maybe_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (parse32_maybe_enum_key_gen #k #key #repr #p p32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> maybe_enum_key_of_repr_tac #key #repr e); ] noextract let parse32_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) () : T.Tac unit = T.tassert (Cons? e); let fu = quote (parse32_enum_key_gen #k #key #repr p e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> parse32_maybe_enum_key_tac p32 e ()) ] noextract let serialize32_enum_key_gen_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (serialize32_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e); ]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.TacLib.fst.checked", "LowParse.Spec.Tac.Enum.fst.checked", "LowParse.SLow.Enum.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Tac.Enum.fst" }
[ { "abbrev": true, "full_module": "LowParse.TacLib", "short_module": "T" }, { "abbrev": false, "full_module": "LowParse.SLow.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Tac.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": 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
s32: LowParse.SLow.Base.serializer32 s -> e: LowParse.Spec.Enum.enum key repr {Cons? e} -> _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "LowParse.Spec.Enum.enum", "Prims.b2t", "Prims.uu___is_Cons", "FStar.Pervasives.Native.tuple2", "Prims.unit", "FStar.Tactics.V1.Derived.iseq", "Prims.Cons", "LowParse.TacLib.solve_vc", "LowParse.Spec.Tac.Enum.enum_repr_of_key_tac", "Prims.Nil", "LowParse.SLow.Tac.Enum.apply", "FStar.Stubs.Reflection.Types.term", "LowParse.SLow.Enum.serialize32_maybe_enum_key_gen" ]
[]
false
true
false
false
false
let serialize32_maybe_enum_key_tac (#k: parser_kind) (#key: eqtype) (#repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr {Cons? e}) () : T.Tac unit =
let fu = quote (serialize32_maybe_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e)]
false
LowParse.SLow.Tac.Enum.fst
LowParse.SLow.Tac.Enum.size32_enum_key_gen_tac
val size32_enum_key_gen_tac: #k: parser_kind -> #key: eqtype -> #repr: eqtype -> #p: parser k repr -> #s: serializer p -> s32: size32 s -> e: enum key repr {Cons? e} -> Prims.unit -> T.Tac unit
val size32_enum_key_gen_tac: #k: parser_kind -> #key: eqtype -> #repr: eqtype -> #p: parser k repr -> #s: serializer p -> s32: size32 s -> e: enum key repr {Cons? e} -> Prims.unit -> T.Tac unit
let size32_enum_key_gen_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (size32_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e); ]
{ "file_name": "src/lowparse/LowParse.SLow.Tac.Enum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 116, "start_col": 0, "start_line": 99 }
module LowParse.SLow.Tac.Enum include LowParse.Spec.Tac.Enum include LowParse.SLow.Enum module T = LowParse.TacLib // // The enum tactic solves goals of type ?u:eqtype with enum types that are // in the environment at type Type0 // So typechecking such uvars fails since F* 2635 bug fix // (since uvar solutions are checked with smt off) // // To circumvent that, we use t_apply with tc_resolve_uvars flag on, // so that ?u will be typechecked as soon as it is resolved, // resulting in an smt guard that will be added to the proofstate // let apply (t:T.term) : T.Tac unit = T.t_apply true false true t noextract let parse32_maybe_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (parse32_maybe_enum_key_gen #k #key #repr #p p32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> maybe_enum_key_of_repr_tac #key #repr e); ] noextract let parse32_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) () : T.Tac unit = T.tassert (Cons? e); let fu = quote (parse32_enum_key_gen #k #key #repr p e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> parse32_maybe_enum_key_tac p32 e ()) ] noextract let serialize32_enum_key_gen_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (serialize32_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e); ] noextract let serialize32_maybe_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (serialize32_maybe_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e); ]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.TacLib.fst.checked", "LowParse.Spec.Tac.Enum.fst.checked", "LowParse.SLow.Enum.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Tac.Enum.fst" }
[ { "abbrev": true, "full_module": "LowParse.TacLib", "short_module": "T" }, { "abbrev": false, "full_module": "LowParse.SLow.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Tac.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": 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
s32: LowParse.SLow.Base.size32 s -> e: LowParse.Spec.Enum.enum key repr {Cons? e} -> _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "LowParse.Spec.Enum.enum", "Prims.b2t", "Prims.uu___is_Cons", "FStar.Pervasives.Native.tuple2", "Prims.unit", "FStar.Tactics.V1.Derived.iseq", "Prims.Cons", "LowParse.TacLib.solve_vc", "LowParse.Spec.Tac.Enum.enum_repr_of_key_tac", "Prims.Nil", "LowParse.SLow.Tac.Enum.apply", "FStar.Stubs.Reflection.Types.term", "LowParse.SLow.Enum.size32_enum_key_gen" ]
[]
false
true
false
false
false
let size32_enum_key_gen_tac (#k: parser_kind) (#key: eqtype) (#repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr {Cons? e}) () : T.Tac unit =
let fu = quote (size32_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e)]
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.validate_bounded_int32_le
val validate_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val validate_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
let validate_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_le_3 min32 max32 sl pos else validate_bounded_int32_le_4 min32 max32 sl pos )
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 457, "start_col": 0, "start_line": 445 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos ) inline_for_extraction let validate_u16_le () : validator parse_u16_le = validate_total_constant_size parse_u16_le 2uL () inline_for_extraction let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le = validate_total_constant_size_with_error_code parse_u16_le 2uL c inline_for_extraction let validate_u32_le () : validator parse_u32_le = validate_total_constant_size parse_u32_le 4uL () inline_for_extraction let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le = validate_total_constant_size_with_error_code parse_u32_le 4uL c inline_for_extraction let jump_u16_le : jumper parse_u16_le = jump_constant_size parse_u16_le 2ul () inline_for_extraction let jump_u32_le : jumper parse_u32_le = jump_constant_size parse_u32_le 4ul () inline_for_extraction val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1) inline_for_extraction val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2) inline_for_extraction val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3) inline_for_extraction val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4) inline_for_extraction noextract let read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_le_1 | 2 -> read_bounded_integer_le_2 | 3 -> read_bounded_integer_le_3 | 4 -> read_bounded_integer_le_4 inline_for_extraction val read_u16_le : leaf_reader parse_u16_le inline_for_extraction val read_u32_le : leaf_reader parse_u32_le inline_for_extraction val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) inline_for_extraction val write_bounded_integer_le_1 : leaf_writer_strong (serialize_bounded_integer_le 1) inline_for_extraction val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) inline_for_extraction val write_bounded_integer_le_2 : leaf_writer_strong (serialize_bounded_integer_le 2) inline_for_extraction val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) inline_for_extraction val write_bounded_integer_le_3 : leaf_writer_strong (serialize_bounded_integer_le 3) inline_for_extraction val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) inline_for_extraction val write_bounded_integer_le_4 : leaf_writer_strong (serialize_bounded_integer_le 4) inline_for_extraction noextract let write_bounded_integer_le (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer_le i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_le_1 | 2 -> write_bounded_integer_le_2 | 3 -> write_bounded_integer_le_3 | 4 -> write_bounded_integer_le_4 inline_for_extraction val write_u16_le : leaf_writer_strong serialize_u16_le inline_for_extraction val write_u32_le : leaf_writer_strong serialize_u32_le val validate_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.Low.Base.validator (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt64.t", "LowParse.Low.BoundedInt.validate_bounded_int32_le_1", "Prims.bool", "LowParse.Low.BoundedInt.validate_bounded_int32_le_2", "LowParse.Low.BoundedInt.validate_bounded_int32_le_3", "LowParse.Low.BoundedInt.validate_bounded_int32_le_4", "LowParse.Low.Base.validator", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le" ]
[]
false
false
false
false
false
let validate_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) =
fun #rrel #rel sl pos -> (if (U32.v max32) < 256 then validate_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_le_3 min32 max32 sl pos else validate_bounded_int32_le_4 min32 max32 sl pos)
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.jump_bounded_int32_le
val jump_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
let jump_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_le_3 min32 max32 sl pos else jump_bounded_int32_le_4 min32 max32 sl pos )
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 492, "start_col": 0, "start_line": 480 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos ) inline_for_extraction let validate_u16_le () : validator parse_u16_le = validate_total_constant_size parse_u16_le 2uL () inline_for_extraction let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le = validate_total_constant_size_with_error_code parse_u16_le 2uL c inline_for_extraction let validate_u32_le () : validator parse_u32_le = validate_total_constant_size parse_u32_le 4uL () inline_for_extraction let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le = validate_total_constant_size_with_error_code parse_u32_le 4uL c inline_for_extraction let jump_u16_le : jumper parse_u16_le = jump_constant_size parse_u16_le 2ul () inline_for_extraction let jump_u32_le : jumper parse_u32_le = jump_constant_size parse_u32_le 4ul () inline_for_extraction val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1) inline_for_extraction val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2) inline_for_extraction val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3) inline_for_extraction val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4) inline_for_extraction noextract let read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_le_1 | 2 -> read_bounded_integer_le_2 | 3 -> read_bounded_integer_le_3 | 4 -> read_bounded_integer_le_4 inline_for_extraction val read_u16_le : leaf_reader parse_u16_le inline_for_extraction val read_u32_le : leaf_reader parse_u32_le inline_for_extraction val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) inline_for_extraction val write_bounded_integer_le_1 : leaf_writer_strong (serialize_bounded_integer_le 1) inline_for_extraction val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) inline_for_extraction val write_bounded_integer_le_2 : leaf_writer_strong (serialize_bounded_integer_le 2) inline_for_extraction val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) inline_for_extraction val write_bounded_integer_le_3 : leaf_writer_strong (serialize_bounded_integer_le 3) inline_for_extraction val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) inline_for_extraction val write_bounded_integer_le_4 : leaf_writer_strong (serialize_bounded_integer_le 4) inline_for_extraction noextract let write_bounded_integer_le (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer_le i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_le_1 | 2 -> write_bounded_integer_le_2 | 3 -> write_bounded_integer_le_3 | 4 -> write_bounded_integer_le_4 inline_for_extraction val write_u16_le : leaf_writer_strong serialize_u16_le inline_for_extraction val write_u32_le : leaf_writer_strong serialize_u32_le val validate_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_le_3 min32 max32 sl pos else validate_bounded_int32_le_4 min32 max32 sl pos ) val jump_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val jump_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val jump_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val jump_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.Low.Base.jumper (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "LowParse.Low.BoundedInt.jump_bounded_int32_le_1", "Prims.bool", "LowParse.Low.BoundedInt.jump_bounded_int32_le_2", "LowParse.Low.BoundedInt.jump_bounded_int32_le_3", "LowParse.Low.BoundedInt.jump_bounded_int32_le_4", "LowParse.Low.Base.jumper", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le" ]
[]
false
false
false
false
false
let jump_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) =
fun #rrel #rel sl pos -> (if (U32.v max32) < 256 then jump_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_le_3 min32 max32 sl pos else jump_bounded_int32_le_4 min32 max32 sl pos)
false
LowParse.SLow.Tac.Enum.fst
LowParse.SLow.Tac.Enum.size32_maybe_enum_key_tac
val size32_maybe_enum_key_tac: #k: parser_kind -> #key: eqtype -> #repr: eqtype -> #p: parser k repr -> #s: serializer p -> s32: size32 s -> e: enum key repr {Cons? e} -> Prims.unit -> T.Tac unit
val size32_maybe_enum_key_tac: #k: parser_kind -> #key: eqtype -> #repr: eqtype -> #p: parser k repr -> #s: serializer p -> s32: size32 s -> e: enum key repr {Cons? e} -> Prims.unit -> T.Tac unit
let size32_maybe_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (size32_maybe_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e); ]
{ "file_name": "src/lowparse/LowParse.SLow.Tac.Enum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 136, "start_col": 0, "start_line": 119 }
module LowParse.SLow.Tac.Enum include LowParse.Spec.Tac.Enum include LowParse.SLow.Enum module T = LowParse.TacLib // // The enum tactic solves goals of type ?u:eqtype with enum types that are // in the environment at type Type0 // So typechecking such uvars fails since F* 2635 bug fix // (since uvar solutions are checked with smt off) // // To circumvent that, we use t_apply with tc_resolve_uvars flag on, // so that ?u will be typechecked as soon as it is resolved, // resulting in an smt guard that will be added to the proofstate // let apply (t:T.term) : T.Tac unit = T.t_apply true false true t noextract let parse32_maybe_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (parse32_maybe_enum_key_gen #k #key #repr #p p32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> maybe_enum_key_of_repr_tac #key #repr e); ] noextract let parse32_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) () : T.Tac unit = T.tassert (Cons? e); let fu = quote (parse32_enum_key_gen #k #key #repr p e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> parse32_maybe_enum_key_tac p32 e ()) ] noextract let serialize32_enum_key_gen_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (serialize32_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e); ] noextract let serialize32_maybe_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: serializer32 s) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (serialize32_maybe_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e); ] noextract let size32_enum_key_gen_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (size32_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e); ]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.TacLib.fst.checked", "LowParse.Spec.Tac.Enum.fst.checked", "LowParse.SLow.Enum.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Tac.Enum.fst" }
[ { "abbrev": true, "full_module": "LowParse.TacLib", "short_module": "T" }, { "abbrev": false, "full_module": "LowParse.SLow.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Tac.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": 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
s32: LowParse.SLow.Base.size32 s -> e: LowParse.Spec.Enum.enum key repr {Cons? e} -> _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "LowParse.Spec.Enum.enum", "Prims.b2t", "Prims.uu___is_Cons", "FStar.Pervasives.Native.tuple2", "Prims.unit", "FStar.Tactics.V1.Derived.iseq", "Prims.Cons", "LowParse.TacLib.solve_vc", "LowParse.Spec.Tac.Enum.enum_repr_of_key_tac", "Prims.Nil", "LowParse.SLow.Tac.Enum.apply", "FStar.Stubs.Reflection.Types.term", "LowParse.SLow.Enum.size32_maybe_enum_key_gen" ]
[]
false
true
false
false
false
let size32_maybe_enum_key_tac (#k: parser_kind) (#key: eqtype) (#repr: eqtype) (#p: parser k repr) (#s: serializer p) (s32: size32 s) (e: enum key repr {Cons? e}) () : T.Tac unit =
let fu = quote (size32_maybe_enum_key_gen #k #key #repr #p #s s32 e) in apply fu; T.iseq [T.solve_vc; T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> enum_repr_of_key_tac e)]
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.write_bounded_int32_le
val write_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
val write_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
let write_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_le_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_le_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_le_3 min32 max32 input out pos else write_bounded_int32_le_4 min32 max32 input out pos )
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 527, "start_col": 0, "start_line": 515 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos ) inline_for_extraction let validate_u16_le () : validator parse_u16_le = validate_total_constant_size parse_u16_le 2uL () inline_for_extraction let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le = validate_total_constant_size_with_error_code parse_u16_le 2uL c inline_for_extraction let validate_u32_le () : validator parse_u32_le = validate_total_constant_size parse_u32_le 4uL () inline_for_extraction let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le = validate_total_constant_size_with_error_code parse_u32_le 4uL c inline_for_extraction let jump_u16_le : jumper parse_u16_le = jump_constant_size parse_u16_le 2ul () inline_for_extraction let jump_u32_le : jumper parse_u32_le = jump_constant_size parse_u32_le 4ul () inline_for_extraction val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1) inline_for_extraction val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2) inline_for_extraction val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3) inline_for_extraction val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4) inline_for_extraction noextract let read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_le_1 | 2 -> read_bounded_integer_le_2 | 3 -> read_bounded_integer_le_3 | 4 -> read_bounded_integer_le_4 inline_for_extraction val read_u16_le : leaf_reader parse_u16_le inline_for_extraction val read_u32_le : leaf_reader parse_u32_le inline_for_extraction val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) inline_for_extraction val write_bounded_integer_le_1 : leaf_writer_strong (serialize_bounded_integer_le 1) inline_for_extraction val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) inline_for_extraction val write_bounded_integer_le_2 : leaf_writer_strong (serialize_bounded_integer_le 2) inline_for_extraction val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) inline_for_extraction val write_bounded_integer_le_3 : leaf_writer_strong (serialize_bounded_integer_le 3) inline_for_extraction val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) inline_for_extraction val write_bounded_integer_le_4 : leaf_writer_strong (serialize_bounded_integer_le 4) inline_for_extraction noextract let write_bounded_integer_le (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer_le i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_le_1 | 2 -> write_bounded_integer_le_2 | 3 -> write_bounded_integer_le_3 | 4 -> write_bounded_integer_le_4 inline_for_extraction val write_u16_le : leaf_writer_strong serialize_u16_le inline_for_extraction val write_u32_le : leaf_writer_strong serialize_u32_le val validate_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_le_3 min32 max32 sl pos else validate_bounded_int32_le_4 min32 max32 sl pos ) val jump_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val jump_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val jump_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val jump_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_le_3 min32 max32 sl pos else jump_bounded_int32_le_4 min32 max32 sl pos ) val write_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) val write_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) val write_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) val write_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.Low.Base.leaf_writer_strong (LowParse.Spec.BoundedInt.serialize_bounded_int32_le (FStar.UInt32.v min32) (FStar.UInt32.v max32))
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "LowParse.Low.BoundedInt.write_bounded_int32_le_1", "Prims.bool", "LowParse.Low.BoundedInt.write_bounded_int32_le_2", "LowParse.Low.BoundedInt.write_bounded_int32_le_3", "LowParse.Low.BoundedInt.write_bounded_int32_le_4", "LowParse.Low.Base.leaf_writer_strong", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32_le", "LowParse.Spec.BoundedInt.serialize_bounded_int32_le" ]
[]
false
false
false
false
false
let write_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) =
fun input #rrel #rel out pos -> (if (U32.v max32) < 256 then write_bounded_int32_le_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_le_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_le_3 min32 max32 input out pos else write_bounded_int32_le_4 min32 max32 input out pos)
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.jump_bounded_int32_le_fixed_size
val jump_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t{U32.v min32 <= U32.v max32}) : Tot (jumper (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)))
val jump_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t{U32.v min32 <= U32.v max32}) : Tot (jumper (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)))
let jump_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t { U32.v min32 <= U32.v max32 }) : Tot (jumper (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32))) = jump_constant_size (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)) 4ul ()
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 91, "end_line": 574, "start_col": 0, "start_line": 570 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos ) inline_for_extraction let validate_u16_le () : validator parse_u16_le = validate_total_constant_size parse_u16_le 2uL () inline_for_extraction let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le = validate_total_constant_size_with_error_code parse_u16_le 2uL c inline_for_extraction let validate_u32_le () : validator parse_u32_le = validate_total_constant_size parse_u32_le 4uL () inline_for_extraction let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le = validate_total_constant_size_with_error_code parse_u32_le 4uL c inline_for_extraction let jump_u16_le : jumper parse_u16_le = jump_constant_size parse_u16_le 2ul () inline_for_extraction let jump_u32_le : jumper parse_u32_le = jump_constant_size parse_u32_le 4ul () inline_for_extraction val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1) inline_for_extraction val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2) inline_for_extraction val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3) inline_for_extraction val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4) inline_for_extraction noextract let read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_le_1 | 2 -> read_bounded_integer_le_2 | 3 -> read_bounded_integer_le_3 | 4 -> read_bounded_integer_le_4 inline_for_extraction val read_u16_le : leaf_reader parse_u16_le inline_for_extraction val read_u32_le : leaf_reader parse_u32_le inline_for_extraction val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) inline_for_extraction val write_bounded_integer_le_1 : leaf_writer_strong (serialize_bounded_integer_le 1) inline_for_extraction val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) inline_for_extraction val write_bounded_integer_le_2 : leaf_writer_strong (serialize_bounded_integer_le 2) inline_for_extraction val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) inline_for_extraction val write_bounded_integer_le_3 : leaf_writer_strong (serialize_bounded_integer_le 3) inline_for_extraction val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) inline_for_extraction val write_bounded_integer_le_4 : leaf_writer_strong (serialize_bounded_integer_le 4) inline_for_extraction noextract let write_bounded_integer_le (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer_le i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_le_1 | 2 -> write_bounded_integer_le_2 | 3 -> write_bounded_integer_le_3 | 4 -> write_bounded_integer_le_4 inline_for_extraction val write_u16_le : leaf_writer_strong serialize_u16_le inline_for_extraction val write_u32_le : leaf_writer_strong serialize_u32_le val validate_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_le_3 min32 max32 sl pos else validate_bounded_int32_le_4 min32 max32 sl pos ) val jump_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val jump_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val jump_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val jump_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_le_3 min32 max32 sl pos else jump_bounded_int32_le_4 min32 max32 sl pos ) val write_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) val write_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) val write_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) val write_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_le_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_le_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_le_3 min32 max32 input out pos else write_bounded_int32_le_4 min32 max32 input out pos ) val read_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val read_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val read_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val read_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_le_3 min32 max32 sl pos else read_bounded_int32_le_4 min32 max32 sl pos ) val validate_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t { U32.v min32 <= U32.v max32 }) : Tot (validator (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
min32: FStar.UInt32.t -> max32: FStar.UInt32.t{FStar.UInt32.v min32 <= FStar.UInt32.v max32} -> LowParse.Low.Base.jumper (LowParse.Spec.BoundedInt.parse_bounded_int32_le_fixed_size (FStar.UInt32.v min32) (FStar.UInt32.v max32))
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "LowParse.Low.Base.jump_constant_size", "LowParse.Spec.BoundedInt.parse_bounded_int32_fixed_size_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le_fixed_size", "FStar.UInt32.__uint_to_t", "LowParse.Low.Base.jumper" ]
[]
false
false
false
false
false
let jump_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t{U32.v min32 <= U32.v max32}) : Tot (jumper (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32))) =
jump_constant_size (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)) 4ul ()
false
Hacl.Spec.K256.GLV.Lemmas.fst
Hacl.Spec.K256.GLV.Lemmas.point_mul_def
val point_mul_def : a: Prims.nat -> p: Spec.K256.PointOps.proj_point -> Spec.K256.PointOps.proj_point
let point_mul_def a p = SE.pow S.mk_k256_concrete_ops p a
{ "file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 57, "end_line": 236, "start_col": 0, "start_line": 236 }
module Hacl.Spec.K256.GLV.Lemmas open FStar.Mul module M = Lib.NatMod module LE = Lib.Exponentiation module SE = Spec.Exponentiation module S = Spec.K256 module LS = Spec.K256.Lemmas module SM = Hacl.Spec.K256.ECSM.Lemmas open Hacl.Spec.K256.GLV #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" // [lambda](px, py) = (beta * px, py) assume val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p) val lemma_glv : p:S.proj_point -> Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p)) let lemma_glv p = let (pX, pY, pZ) = p in let (px, py) = S.to_aff_point p in assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ)); let (qx, qy) = aff_point_mul lambda (px, py) in lemma_glv_aff (px, py); assert (qx = S.(beta *% px) /\ qy = py); assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ)); let (rX, rY, rZ) = point_mul_lambda p in assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ); let (rx, ry) = S.to_aff_point (rX, rY, rZ) in assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ)); assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ)); assert (qy = ry); // S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ)) assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ)); assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ))); M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ); assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ))) //-------------------------------------------- val lemma_scalar_split_lambda_eval (k:S.qelem) : Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda)) let lemma_scalar_split_lambda_eval k = assert_norm ((minus_lambda + lambda) % S.q = 0); let r1, r2 = scalar_split_lambda k in assert (r1 = S.(k +^ r2 *^ minus_lambda)); calc (==) { (r1 + (r2 * lambda % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } (r1 + r2 * lambda) % S.q; (==) { } ((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q } ((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q } (k + r2 * minus_lambda + r2 * lambda) % S.q; (==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda } (k + r2 * (minus_lambda + lambda)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q } (k + (r2 * (minus_lambda + lambda) % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q } (k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q; (==) { } k % S.q; (==) { Math.Lemmas.small_mod k S.q } k; } //-------------------------------------------- (** Fast computation of [k]P in affine coordinates *) val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point -> Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p == S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p))) let lemma_aff_point_mul_split_lambda k p = let r1, r2 = scalar_split_lambda k in calc (==) { aff_point_mul k p; (==) { lemma_scalar_split_lambda_eval k } aff_point_mul S.(r1 +^ r2 *^ lambda) p; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } aff_point_mul ((r1 + r2 * lambda) % S.q) p; (==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p } aff_point_mul (r1 + r2 * lambda) p; (==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p } S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p); (==) { lemma_glv_aff p } S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p); (==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) } S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)); } val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point -> Lemma (aff_point_mul_endo_split k p == aff_point_mul k p) let lemma_aff_point_mul_endo_split k p = let r10, r20 = scalar_split_lambda k in let lambda_p = aff_point_mul_lambda p in let r1, p1 = aff_negate_point_and_scalar_cond r10 p in let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else begin if is_high1 && not is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; lemma_aff_point_mul_split_lambda k p end else begin if not is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else lemma_aff_point_mul_split_lambda k p end end //--------------------------------- val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma (let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2) let lemma_ecmult_endo_split_to_aff k p = let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in assert (r1 == ar1 /\ r2 == ar2); let r10, r20 = scalar_split_lambda k in let p_aff = S.to_aff_point p in let lambda_p = point_mul_lambda p in let lambda_p_aff = aff_point_mul_lambda p_aff in lemma_glv p; lemma_glv_aff p_aff; assert (S.to_aff_point lambda_p == lambda_p_aff); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if not is_high1 && not is_high2 then () else begin if not is_high1 && is_high2 then LS.to_aff_point_negate_lemma lambda_p else begin if is_high1 && not is_high2 then LS.to_aff_point_negate_lemma p else begin LS.to_aff_point_negate_lemma p; LS.to_aff_point_negate_lemma lambda_p end end end (** Fast computation of [k1]P1 + [k2]P2 in projective coordinates *) // [k1]P1 + [k2]P2 = [r11 + r12 * lambda]P1 + [r21 + r22 * lambda]P2 // = [r11]P1 + [r12]([lambda]P1) + [r21]P2 + [r22]([lambda]P2) // = [r11](p1_x, p1_y) + [r12](beta * p1_x, p1_y) + [r21](p2_x, p2_y) + [r22](beta * p2_x, p2_y) let aff_proj_point_mul_double_split_lambda (k1:S.qelem) (p1:S.proj_point) (k2:S.qelem) (p2:S.proj_point) : S.aff_point = let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then LE.exp_four_fw S.mk_k256_comm_monoid (S.to_aff_point p11) 128 r11 (S.to_aff_point p12) r12 (S.to_aff_point p21) r21 (S.to_aff_point p22) r22 5 else S.to_aff_point (S.point_mul_double k1 p1 k2 p2) val lemma_aff_proj_point_mul_double_split_lambda: k1:S.qelem -> p1:S.proj_point -> k2:S.qelem -> p2:S.proj_point -> Lemma (aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 == S.aff_point_add (aff_point_mul k1 (S.to_aff_point p1)) (aff_point_mul k2 (S.to_aff_point p2))) let lemma_aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 = let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then begin let p1_aff = S.to_aff_point p1 in let p2_aff = S.to_aff_point p2 in let p11_aff = S.to_aff_point p11 in let p12_aff = S.to_aff_point p12 in let p21_aff = S.to_aff_point p21 in let p22_aff = S.to_aff_point p22 in calc (==) { aff_proj_point_mul_double_split_lambda k1 p1 k2 p2; (==) { LE.exp_four_fw_lemma S.mk_k256_comm_monoid p11_aff 128 r11 p12_aff r12 p21_aff r21 p22_aff r22 5 } S.aff_point_add (S.aff_point_add (S.aff_point_add (aff_point_mul r11 p11_aff) (aff_point_mul r12 p12_aff)) (aff_point_mul r21 p21_aff)) (aff_point_mul r22 p22_aff); (==) { lemma_aff_point_mul_endo_split k1 p1_aff; lemma_ecmult_endo_split_to_aff k1 p1 } S.aff_point_add (S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff)) (aff_point_mul r22 p22_aff); (==) { LS.aff_point_add_assoc_lemma (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff) } S.aff_point_add (aff_point_mul k1 p1_aff) (S.aff_point_add (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff)); (==) { lemma_aff_point_mul_endo_split k2 p2_aff; lemma_ecmult_endo_split_to_aff k2 p2 } S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul k2 p2_aff); } end else begin SE.exp_double_fw_lemma S.mk_k256_concrete_ops p1 256 k1 p2 k2 5; LE.exp_double_fw_lemma S.mk_k256_comm_monoid (S.to_aff_point p1) 256 k1 (S.to_aff_point p2) k2 5 end //-----------------------------------
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.K256.ECSM.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.GLV.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.K256.ECSM.Lemmas", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": 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
a: Prims.nat -> p: Spec.K256.PointOps.proj_point -> Spec.K256.PointOps.proj_point
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Spec.K256.PointOps.proj_point", "Spec.Exponentiation.pow", "Spec.K256.mk_k256_concrete_ops" ]
[]
false
false
false
true
false
let point_mul_def a p =
SE.pow S.mk_k256_concrete_ops p a
false
LowParse.Low.BoundedInt.fsti
LowParse.Low.BoundedInt.read_bounded_int32_le
val read_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
val read_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
let read_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_le_3 min32 max32 sl pos else read_bounded_int32_le_4 min32 max32 sl pos )
{ "file_name": "src/lowparse/LowParse.Low.BoundedInt.fsti", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 562, "start_col": 0, "start_line": 550 }
module LowParse.Low.BoundedInt include LowParse.Spec.BoundedInt include LowParse.Low.Base module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST module B = LowStar.Monotonic.Buffer module U64 = FStar.UInt64 (* bounded integers *) inline_for_extraction val read_bounded_integer_1 : unit -> Tot (leaf_reader (parse_bounded_integer 1)) inline_for_extraction val read_bounded_integer_2 : unit -> Tot (leaf_reader (parse_bounded_integer 2)) inline_for_extraction val read_bounded_integer_3 : unit -> Tot (leaf_reader (parse_bounded_integer 3)) inline_for_extraction val read_bounded_integer_4 : unit -> Tot (leaf_reader (parse_bounded_integer 4)) inline_for_extraction noextract let read_bounded_integer (i: integer_size) : Tot (leaf_reader (parse_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_1 () | 2 -> read_bounded_integer_2 () | 3 -> read_bounded_integer_3 () | 4 -> read_bounded_integer_4 () let read_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_reader (parse_bounded_integer (U32.v i))) = fun #rrel #rel sl pos -> if i = 1ul then read_bounded_integer_1 () sl pos else if i = 2ul then read_bounded_integer_2 () sl pos else if i = 3ul then read_bounded_integer_3 () sl pos else read_bounded_integer_4 () sl pos inline_for_extraction val read_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (#rrel: _) (#rel: _) (sl: slice rrel rel) (pos: U32.t) : HST.Stack (bounded_integer (U32.v i)) (requires (fun h -> live_slice h sl /\ U32.v pos + 4 <= U32.v sl.len )) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ valid_content (parse_bounded_integer (U32.v i)) h sl pos res )) inline_for_extraction noextract let validate_bounded_integer (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer i)) = validate_total_constant_size (parse_bounded_integer i) (U64.uint_to_t i) () inline_for_extraction let validate_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (validator (parse_bounded_integer (U32.v i))) = validate_total_constant_size (parse_bounded_integer (U32.v i)) (FStar.Int.Cast.uint32_to_uint64 i) () inline_for_extraction noextract let validate_bounded_integer_le (i: integer_size) // must be a constant : Tot (validator (parse_bounded_integer_le i)) = validate_total_constant_size (parse_bounded_integer_le i) (U64.uint_to_t i) () inline_for_extraction noextract let jump_bounded_integer (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer i)) = jump_constant_size (parse_bounded_integer i) (U32.uint_to_t i) () inline_for_extraction let jump_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (jumper (parse_bounded_integer (U32.v i))) = jump_constant_size (parse_bounded_integer (U32.v i)) (i) () inline_for_extraction noextract let jump_bounded_integer_le (i: integer_size) // must be a constant : Tot (jumper (parse_bounded_integer_le i)) = jump_constant_size (parse_bounded_integer_le i) (U32.uint_to_t i) () inline_for_extraction val serialize32_bounded_integer_1 : unit -> Tot (serializer32 (serialize_bounded_integer 1)) inline_for_extraction val serialize32_bounded_integer_2 : unit -> Tot (serializer32 (serialize_bounded_integer 2)) inline_for_extraction val serialize32_bounded_integer_3 : unit -> Tot (serializer32 (serialize_bounded_integer 3)) inline_for_extraction val serialize32_bounded_integer_4 : unit -> Tot (serializer32 (serialize_bounded_integer 4)) inline_for_extraction let write_bounded_integer_1 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_1 ()) () inline_for_extraction let write_bounded_integer_2 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_2 ()) () inline_for_extraction let write_bounded_integer_3 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_3 ()) () inline_for_extraction let write_bounded_integer_4 () = leaf_writer_strong_of_serializer32 (serialize32_bounded_integer_4 ()) () inline_for_extraction noextract let write_bounded_integer (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1 () | 2 -> write_bounded_integer_2 () | 3 -> write_bounded_integer_3 () | 4 -> write_bounded_integer_4 () inline_for_extraction let write_bounded_integer' (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) : Tot (leaf_writer_strong (serialize_bounded_integer (U32.v i))) = fun v #rrel #rel sl pos -> if i = 1ul then write_bounded_integer_1 () v sl pos else if i = 2ul then write_bounded_integer_2 () v sl pos else if i = 3ul then write_bounded_integer_3 () v sl pos else write_bounded_integer_4 () v sl pos inline_for_extraction let write_bounded_integer_1_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 1)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_1 ()) 1ul () inline_for_extraction let write_bounded_integer_2_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 2)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_2 ()) 2ul () inline_for_extraction let write_bounded_integer_3_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 3)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_3 ()) 3ul () inline_for_extraction let write_bounded_integer_4_weak (_ : unit) : Tot (leaf_writer_weak (serialize_bounded_integer 4)) = leaf_writer_weak_of_strong_constant_size (write_bounded_integer_4 ()) 4ul () inline_for_extraction noextract let write_bounded_integer_weak (i: integer_size) : Tot (leaf_writer_weak (serialize_bounded_integer i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_1_weak () | 2 -> write_bounded_integer_2_weak () | 3 -> write_bounded_integer_3_weak () | 4 -> write_bounded_integer_4_weak () val write_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) val write_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_3 min32 max32 input out pos else write_bounded_int32_4 min32 max32 input out pos ) val read_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) val read_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let read_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then read_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_3 min32 max32 sl pos else read_bounded_int32_4 min32 max32 sl pos ) val validate_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) val validate_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_3 min32 max32 sl pos else validate_bounded_int32_4 min32 max32 sl pos ) val jump_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) val jump_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32 (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_3 min32 max32 sl pos else jump_bounded_int32_4 min32 max32 sl pos ) inline_for_extraction let validate_u16_le () : validator parse_u16_le = validate_total_constant_size parse_u16_le 2uL () inline_for_extraction let validate_u16_le_with_error_code (c: error_code) : validator parse_u16_le = validate_total_constant_size_with_error_code parse_u16_le 2uL c inline_for_extraction let validate_u32_le () : validator parse_u32_le = validate_total_constant_size parse_u32_le 4uL () inline_for_extraction let validate_u32_le_with_error_code (c: error_code) : validator parse_u32_le = validate_total_constant_size_with_error_code parse_u32_le 4uL c inline_for_extraction let jump_u16_le : jumper parse_u16_le = jump_constant_size parse_u16_le 2ul () inline_for_extraction let jump_u32_le : jumper parse_u32_le = jump_constant_size parse_u32_le 4ul () inline_for_extraction val read_bounded_integer_le_1 : leaf_reader (parse_bounded_integer_le 1) inline_for_extraction val read_bounded_integer_le_2 : leaf_reader (parse_bounded_integer_le 2) inline_for_extraction val read_bounded_integer_le_3 : leaf_reader (parse_bounded_integer_le 3) inline_for_extraction val read_bounded_integer_le_4 : leaf_reader (parse_bounded_integer_le 4) inline_for_extraction noextract let read_bounded_integer_le (i: integer_size) : Tot (leaf_reader (parse_bounded_integer_le i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> read_bounded_integer_le_1 | 2 -> read_bounded_integer_le_2 | 3 -> read_bounded_integer_le_3 | 4 -> read_bounded_integer_le_4 inline_for_extraction val read_u16_le : leaf_reader parse_u16_le inline_for_extraction val read_u32_le : leaf_reader parse_u32_le inline_for_extraction val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) inline_for_extraction val write_bounded_integer_le_1 : leaf_writer_strong (serialize_bounded_integer_le 1) inline_for_extraction val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) inline_for_extraction val write_bounded_integer_le_2 : leaf_writer_strong (serialize_bounded_integer_le 2) inline_for_extraction val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) inline_for_extraction val write_bounded_integer_le_3 : leaf_writer_strong (serialize_bounded_integer_le 3) inline_for_extraction val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) inline_for_extraction val write_bounded_integer_le_4 : leaf_writer_strong (serialize_bounded_integer_le 4) inline_for_extraction noextract let write_bounded_integer_le (i: integer_size) : Tot (leaf_writer_strong (serialize_bounded_integer_le i)) = [@inline_let] let _ = integer_size_values i in match i with | 1 -> write_bounded_integer_le_1 | 2 -> write_bounded_integer_le_2 | 3 -> write_bounded_integer_le_3 | 4 -> write_bounded_integer_le_4 inline_for_extraction val write_u16_le : leaf_writer_strong serialize_u16_le inline_for_extraction val write_u32_le : leaf_writer_strong serialize_u32_le val validate_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val validate_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) inline_for_extraction let validate_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (validator (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then validate_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then validate_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then validate_bounded_int32_le_3 min32 max32 sl pos else validate_bounded_int32_le_4 min32 max32 sl pos ) val jump_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val jump_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val jump_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val jump_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) inline_for_extraction let jump_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (jumper (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = fun #rrel #rel sl pos -> ( if (U32.v max32) < 256 then jump_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then jump_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then jump_bounded_int32_le_3 min32 max32 sl pos else jump_bounded_int32_le_4 min32 max32 sl pos ) val write_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) val write_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) val write_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) val write_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) inline_for_extraction let write_bounded_int32_le (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_writer_strong (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) = fun input #rrel #rel out pos -> ( if (U32.v max32) < 256 then write_bounded_int32_le_1 min32 max32 input out pos else if (U32.v max32) < 65536 then write_bounded_int32_le_2 min32 max32 input out pos else if (U32.v max32) < 16777216 then write_bounded_int32_le_3 min32 max32 input out pos else write_bounded_int32_le_4 min32 max32 input out pos ) val read_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val read_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val read_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32))) val read_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowParse.Spec.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.BoundedInt.fsti" }
[ { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.Low.Base.leaf_reader (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "LowParse.Low.BoundedInt.read_bounded_int32_le_1", "LowParse.Spec.BoundedInt.bounded_int32", "Prims.bool", "LowParse.Low.BoundedInt.read_bounded_int32_le_2", "LowParse.Low.BoundedInt.read_bounded_int32_le_3", "LowParse.Low.BoundedInt.read_bounded_int32_le_4", "LowParse.Low.Base.leaf_reader", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32_le" ]
[]
false
false
false
false
false
let read_bounded_int32_le (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) : Tot (leaf_reader (parse_bounded_int32_le (U32.v min32) (U32.v max32))) =
fun #rrel #rel sl pos -> (if (U32.v max32) < 256 then read_bounded_int32_le_1 min32 max32 sl pos else if (U32.v max32) < 65536 then read_bounded_int32_le_2 min32 max32 sl pos else if (U32.v max32) < 16777216 then read_bounded_int32_le_3 min32 max32 sl pos else read_bounded_int32_le_4 min32 max32 sl pos)
false
Hacl.Spec.K256.GLV.Lemmas.fst
Hacl.Spec.K256.GLV.Lemmas.lemma_glv
val lemma_glv : p:S.proj_point -> Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p))
val lemma_glv : p:S.proj_point -> Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p))
let lemma_glv p = let (pX, pY, pZ) = p in let (px, py) = S.to_aff_point p in assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ)); let (qx, qy) = aff_point_mul lambda (px, py) in lemma_glv_aff (px, py); assert (qx = S.(beta *% px) /\ qy = py); assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ)); let (rX, rY, rZ) = point_mul_lambda p in assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ); let (rx, ry) = S.to_aff_point (rX, rY, rZ) in assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ)); assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ)); assert (qy = ry); // S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ)) assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ)); assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ))); M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ); assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ)))
{ "file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 70, "end_line": 43, "start_col": 0, "start_line": 24 }
module Hacl.Spec.K256.GLV.Lemmas open FStar.Mul module M = Lib.NatMod module LE = Lib.Exponentiation module SE = Spec.Exponentiation module S = Spec.K256 module LS = Spec.K256.Lemmas module SM = Hacl.Spec.K256.ECSM.Lemmas open Hacl.Spec.K256.GLV #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" // [lambda](px, py) = (beta * px, py) assume val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p) val lemma_glv : p:S.proj_point -> Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p))
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.K256.ECSM.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.GLV.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.K256.ECSM.Lemmas", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": 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
p: Spec.K256.PointOps.proj_point -> FStar.Pervasives.Lemma (ensures Spec.K256.PointOps.to_aff_point (Hacl.Spec.K256.GLV.point_mul_lambda p) == Hacl.Spec.K256.GLV.aff_point_mul Hacl.Spec.K256.GLV.lambda (Spec.K256.PointOps.to_aff_point p) )
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.K256.PointOps.proj_point", "Spec.K256.PointOps.felem", "Prims._assert", "Prims.b2t", "Prims.op_Equality", "Spec.K256.PointOps.op_Star_Percent", "Hacl.Spec.K256.GLV.beta", "Spec.K256.PointOps.finv", "Prims.unit", "Lib.NatMod.lemma_mul_mod_assoc", "Spec.K256.PointOps.prime", "Spec.K256.PointOps.op_Slash_Percent", "Prims.l_and", "Spec.K256.PointOps.aff_point", "Spec.K256.PointOps.to_aff_point", "FStar.Pervasives.Native.Mktuple3", "Hacl.Spec.K256.GLV.point_mul_lambda", "Hacl.Spec.K256.GLV.Lemmas.lemma_glv_aff", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.K256.GLV.aff_point_mul", "Hacl.Spec.K256.GLV.lambda" ]
[]
false
false
true
false
false
let lemma_glv p =
let pX, pY, pZ = p in let px, py = S.to_aff_point p in assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ)); let qx, qy = aff_point_mul lambda (px, py) in lemma_glv_aff (px, py); assert (qx = S.(beta *% px) /\ qy = py); assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ)); let rX, rY, rZ = point_mul_lambda p in assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ); let rx, ry = S.to_aff_point (rX, rY, rZ) in assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ)); assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ)); assert (qy = ry); assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ)); assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ))); M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ); assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ)))
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.t
val t: eqtype -> Type0 -> Type0
val t: eqtype -> Type0 -> Type0
let t k v = LL2.t (k & v)
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 15, "end_line": 28, "start_col": 0, "start_line": 27 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: Prims.eqtype -> v: Type0 -> Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "LowStar.Lib.LinkedList2.t", "FStar.Pervasives.Native.tuple2" ]
[]
false
false
false
true
true
let t k v =
LL2.t (k & v)
false
Hacl.Spec.K256.GLV.Lemmas.fst
Hacl.Spec.K256.GLV.Lemmas.lemma_ecmult_endo_split_to_aff
val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma (let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2)
val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma (let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2)
let lemma_ecmult_endo_split_to_aff k p = let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in assert (r1 == ar1 /\ r2 == ar2); let r10, r20 = scalar_split_lambda k in let p_aff = S.to_aff_point p in let lambda_p = point_mul_lambda p in let lambda_p_aff = aff_point_mul_lambda p_aff in lemma_glv p; lemma_glv_aff p_aff; assert (S.to_aff_point lambda_p == lambda_p_aff); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if not is_high1 && not is_high2 then () else begin if not is_high1 && is_high2 then LS.to_aff_point_negate_lemma lambda_p else begin if is_high1 && not is_high2 then LS.to_aff_point_negate_lemma p else begin LS.to_aff_point_negate_lemma p; LS.to_aff_point_negate_lemma lambda_p end end end
{ "file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 168, "start_col": 0, "start_line": 141 }
module Hacl.Spec.K256.GLV.Lemmas open FStar.Mul module M = Lib.NatMod module LE = Lib.Exponentiation module SE = Spec.Exponentiation module S = Spec.K256 module LS = Spec.K256.Lemmas module SM = Hacl.Spec.K256.ECSM.Lemmas open Hacl.Spec.K256.GLV #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" // [lambda](px, py) = (beta * px, py) assume val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p) val lemma_glv : p:S.proj_point -> Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p)) let lemma_glv p = let (pX, pY, pZ) = p in let (px, py) = S.to_aff_point p in assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ)); let (qx, qy) = aff_point_mul lambda (px, py) in lemma_glv_aff (px, py); assert (qx = S.(beta *% px) /\ qy = py); assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ)); let (rX, rY, rZ) = point_mul_lambda p in assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ); let (rx, ry) = S.to_aff_point (rX, rY, rZ) in assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ)); assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ)); assert (qy = ry); // S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ)) assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ)); assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ))); M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ); assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ))) //-------------------------------------------- val lemma_scalar_split_lambda_eval (k:S.qelem) : Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda)) let lemma_scalar_split_lambda_eval k = assert_norm ((minus_lambda + lambda) % S.q = 0); let r1, r2 = scalar_split_lambda k in assert (r1 = S.(k +^ r2 *^ minus_lambda)); calc (==) { (r1 + (r2 * lambda % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } (r1 + r2 * lambda) % S.q; (==) { } ((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q } ((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q } (k + r2 * minus_lambda + r2 * lambda) % S.q; (==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda } (k + r2 * (minus_lambda + lambda)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q } (k + (r2 * (minus_lambda + lambda) % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q } (k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q; (==) { } k % S.q; (==) { Math.Lemmas.small_mod k S.q } k; } //-------------------------------------------- (** Fast computation of [k]P in affine coordinates *) val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point -> Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p == S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p))) let lemma_aff_point_mul_split_lambda k p = let r1, r2 = scalar_split_lambda k in calc (==) { aff_point_mul k p; (==) { lemma_scalar_split_lambda_eval k } aff_point_mul S.(r1 +^ r2 *^ lambda) p; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } aff_point_mul ((r1 + r2 * lambda) % S.q) p; (==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p } aff_point_mul (r1 + r2 * lambda) p; (==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p } S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p); (==) { lemma_glv_aff p } S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p); (==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) } S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)); } val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point -> Lemma (aff_point_mul_endo_split k p == aff_point_mul k p) let lemma_aff_point_mul_endo_split k p = let r10, r20 = scalar_split_lambda k in let lambda_p = aff_point_mul_lambda p in let r1, p1 = aff_negate_point_and_scalar_cond r10 p in let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else begin if is_high1 && not is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; lemma_aff_point_mul_split_lambda k p end else begin if not is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else lemma_aff_point_mul_split_lambda k p end end //--------------------------------- val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma (let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.K256.ECSM.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.GLV.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.K256.ECSM.Lemmas", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": 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
k: Spec.K256.PointOps.qelem -> p: Spec.K256.PointOps.proj_point -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.K256.GLV.ecmult_endo_split k p in (let FStar.Pervasives.Native.Mktuple4 #_ #_ #_ #_ r1 p1 r2 p2 = _ in let _ = Hacl.Spec.K256.GLV.aff_ecmult_endo_split k (Spec.K256.PointOps.to_aff_point p) in (let FStar.Pervasives.Native.Mktuple4 #_ #_ #_ #_ ar1 ap1 ar2 ap2 = _ in r1 == ar1 /\ Spec.K256.PointOps.to_aff_point p1 == ap1 /\ r2 == ar2 /\ Spec.K256.PointOps.to_aff_point p2 == ap2) <: Type0) <: Type0))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.K256.PointOps.qelem", "Spec.K256.PointOps.proj_point", "Spec.K256.PointOps.aff_point", "Prims.op_AmpAmp", "Prims.op_Negation", "Prims.bool", "Spec.K256.Lemmas.to_aff_point_negate_lemma", "Prims.unit", "Spec.K256.PointOps.scalar_is_high", "Prims._assert", "Prims.eq2", "Spec.K256.PointOps.to_aff_point", "Hacl.Spec.K256.GLV.Lemmas.lemma_glv_aff", "Hacl.Spec.K256.GLV.Lemmas.lemma_glv", "Hacl.Spec.K256.GLV.aff_point_mul_lambda", "Hacl.Spec.K256.GLV.point_mul_lambda", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.K256.GLV.scalar_split_lambda", "Prims.l_and", "FStar.Pervasives.Native.tuple4", "Hacl.Spec.K256.GLV.aff_ecmult_endo_split", "Hacl.Spec.K256.GLV.ecmult_endo_split" ]
[]
false
false
true
false
false
let lemma_ecmult_endo_split_to_aff k p =
let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in assert (r1 == ar1 /\ r2 == ar2); let r10, r20 = scalar_split_lambda k in let p_aff = S.to_aff_point p in let lambda_p = point_mul_lambda p in let lambda_p_aff = aff_point_mul_lambda p_aff in lemma_glv p; lemma_glv_aff p_aff; assert (S.to_aff_point lambda_p == lambda_p_aff); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if not is_high1 && not is_high2 then () else if not is_high1 && is_high2 then LS.to_aff_point_negate_lemma lambda_p else if is_high1 && not is_high2 then LS.to_aff_point_negate_lemma p else (LS.to_aff_point_negate_lemma p; LS.to_aff_point_negate_lemma lambda_p)
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.v
val v: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> GTot (map t_k t_v)
val v: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> GTot (map t_k t_v)
let v #_ #_ h ll = let l = LL2.v h ll in v_ l
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 6, "end_line": 39, "start_col": 0, "start_line": 37 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2. val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v) let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> ll: LowStar.Lib.AssocList.t t_k t_v -> Prims.GTot (LowStar.Lib.AssocList.map t_k t_v)
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.eqtype", "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.AssocList.t", "LowStar.Lib.AssocList.v_", "Prims.list", "FStar.Pervasives.Native.tuple2", "LowStar.Lib.LinkedList2.v", "LowStar.Lib.AssocList.map" ]
[]
false
false
false
false
false
let v #_ #_ h ll =
let l = LL2.v h ll in v_ l
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.v_
val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v)
val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v)
let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v))
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 82, "end_line": 34, "start_col": 0, "start_line": 33 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: Prims.list (t_k * t_v) -> LowStar.Lib.AssocList.map t_k t_v
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "Prims.list", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.fold_right", "FStar.Map.t", "FStar.Pervasives.Native.option", "FStar.Map.upd", "FStar.Pervasives.Native.Some", "FStar.Map.const", "FStar.Pervasives.Native.None", "LowStar.Lib.AssocList.map" ]
[]
false
false
false
false
false
let v_ #_ #t_v l =
List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v))
false
FStar.DM4F.Heap.ST.fst
FStar.DM4F.Heap.ST.runST
val runST : (#a:Type) -> (#post:(heap -> a -> heap -> Type0)) -> (unit -> ST a (requires (fun h -> True)) (ensures post)) -> Pure a (requires True) (ensures (fun x -> exists h0 h1. post h0 x h1))
val runST : (#a:Type) -> (#post:(heap -> a -> heap -> Type0)) -> (unit -> ST a (requires (fun h -> True)) (ensures post)) -> Pure a (requires True) (ensures (fun x -> exists h0 h1. post h0 x h1))
let runST #a #post s = fst (reify (s ()) FStar.DM4F.Heap.emp)
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 61, "end_line": 30, "start_col": 0, "start_line": 30 }
(* Copyright 2008-2018 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. *) (* A state monad with local state built using FStar.DM4F.Heap. The very end of the file illustrates how recursion through the heap is forbidden because of the universe constraints. As such, in this model, storing stateful functions in the heap is forbidden. However, storing non-stateful functions, e.g,. Tot or Exception function in the heap is acceptable. *) module FStar.DM4F.Heap.ST open FStar.DM4F.Heap open FStar.DM4F.ST
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.ST.fst.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": true, "source_file": "FStar.DM4F.Heap.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": 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
s: (_: Prims.unit -> FStar.DM4F.Heap.ST.ST a) -> Prims.Pure a
Prims.Pure
[]
[]
[ "FStar.DM4F.Heap.heap", "Prims.unit", "Prims.l_True", "FStar.Pervasives.Native.fst", "FStar.DM4F.Heap.emp" ]
[]
false
false
false
false
false
let runST #a #post s =
fst (reify (s ()) FStar.DM4F.Heap.emp)
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.invariant
val invariant: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Type0
val invariant: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Type0
let invariant #_ #_ h ll = LL2.invariant h ll
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 20, "end_line": 42, "start_col": 0, "start_line": 41 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2. val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v) let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v)) /// Reflecting a stateful, imperative map as a functional one in a given heap. let v #_ #_ h ll = let l = LL2.v h ll in v_ l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> ll: LowStar.Lib.AssocList.t t_k t_v -> Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.eqtype", "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.AssocList.t", "LowStar.Lib.LinkedList2.invariant", "FStar.Pervasives.Native.tuple2" ]
[]
false
false
false
false
true
let invariant #_ #_ h ll =
LL2.invariant h ll
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.region_of
val region_of: #t_k:eqtype -> #t_v:Type0 -> ll:t t_k t_v -> GTot B.loc
val region_of: #t_k:eqtype -> #t_v:Type0 -> ll:t t_k t_v -> GTot B.loc
let region_of #_ #_ ll = LL2.region_of ll
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 18, "end_line": 53, "start_col": 0, "start_line": 52 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2. val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v) let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v)) /// Reflecting a stateful, imperative map as a functional one in a given heap. let v #_ #_ h ll = let l = LL2.v h ll in v_ l let invariant #_ #_ h ll = LL2.invariant h ll // No longer needed in the fsti. val footprint: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Ghost B.loc (requires invariant h ll) (ensures fun _ -> True) let footprint #_ #_ h ll = LL2.footprint h ll
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ll: LowStar.Lib.AssocList.t t_k t_v -> Prims.GTot LowStar.Monotonic.Buffer.loc
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.eqtype", "LowStar.Lib.AssocList.t", "LowStar.Lib.LinkedList2.region_of", "FStar.Pervasives.Native.tuple2", "LowStar.Monotonic.Buffer.loc" ]
[]
false
false
false
false
false
let region_of #_ #_ ll =
LL2.region_of ll
false
Hacl.Spec.K256.GLV.Lemmas.fst
Hacl.Spec.K256.GLV.Lemmas.lemma_aff_point_mul_endo_split
val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point -> Lemma (aff_point_mul_endo_split k p == aff_point_mul k p)
val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point -> Lemma (aff_point_mul_endo_split k p == aff_point_mul k p)
let lemma_aff_point_mul_endo_split k p = let r10, r20 = scalar_split_lambda k in let lambda_p = aff_point_mul_lambda p in let r1, p1 = aff_negate_point_and_scalar_cond r10 p in let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else begin if is_high1 && not is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; lemma_aff_point_mul_split_lambda k p end else begin if not is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else lemma_aff_point_mul_split_lambda k p end end
{ "file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 132, "start_col": 0, "start_line": 109 }
module Hacl.Spec.K256.GLV.Lemmas open FStar.Mul module M = Lib.NatMod module LE = Lib.Exponentiation module SE = Spec.Exponentiation module S = Spec.K256 module LS = Spec.K256.Lemmas module SM = Hacl.Spec.K256.ECSM.Lemmas open Hacl.Spec.K256.GLV #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" // [lambda](px, py) = (beta * px, py) assume val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p) val lemma_glv : p:S.proj_point -> Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p)) let lemma_glv p = let (pX, pY, pZ) = p in let (px, py) = S.to_aff_point p in assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ)); let (qx, qy) = aff_point_mul lambda (px, py) in lemma_glv_aff (px, py); assert (qx = S.(beta *% px) /\ qy = py); assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ)); let (rX, rY, rZ) = point_mul_lambda p in assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ); let (rx, ry) = S.to_aff_point (rX, rY, rZ) in assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ)); assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ)); assert (qy = ry); // S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ)) assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ)); assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ))); M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ); assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ))) //-------------------------------------------- val lemma_scalar_split_lambda_eval (k:S.qelem) : Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda)) let lemma_scalar_split_lambda_eval k = assert_norm ((minus_lambda + lambda) % S.q = 0); let r1, r2 = scalar_split_lambda k in assert (r1 = S.(k +^ r2 *^ minus_lambda)); calc (==) { (r1 + (r2 * lambda % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } (r1 + r2 * lambda) % S.q; (==) { } ((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q } ((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q } (k + r2 * minus_lambda + r2 * lambda) % S.q; (==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda } (k + r2 * (minus_lambda + lambda)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q } (k + (r2 * (minus_lambda + lambda) % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q } (k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q; (==) { } k % S.q; (==) { Math.Lemmas.small_mod k S.q } k; } //-------------------------------------------- (** Fast computation of [k]P in affine coordinates *) val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point -> Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p == S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p))) let lemma_aff_point_mul_split_lambda k p = let r1, r2 = scalar_split_lambda k in calc (==) { aff_point_mul k p; (==) { lemma_scalar_split_lambda_eval k } aff_point_mul S.(r1 +^ r2 *^ lambda) p; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } aff_point_mul ((r1 + r2 * lambda) % S.q) p; (==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p } aff_point_mul (r1 + r2 * lambda) p; (==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p } S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p); (==) { lemma_glv_aff p } S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p); (==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) } S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)); } val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point -> Lemma (aff_point_mul_endo_split k p == aff_point_mul k p)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.K256.ECSM.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.GLV.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.K256.ECSM.Lemmas", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": 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
k: Spec.K256.PointOps.qelem -> p: Spec.K256.PointOps.aff_point -> FStar.Pervasives.Lemma (ensures Hacl.Spec.K256.GLV.aff_point_mul_endo_split k p == Hacl.Spec.K256.GLV.aff_point_mul k p )
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.K256.PointOps.qelem", "Spec.K256.PointOps.aff_point", "Prims.op_AmpAmp", "Hacl.Spec.K256.GLV.Lemmas.lemma_aff_point_mul_split_lambda", "Prims.unit", "Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg", "Prims.bool", "Prims.op_Negation", "Spec.K256.PointOps.scalar_is_high", "Prims._assert", "Prims.eq2", "FStar.Pervasives.Native.tuple4", "FStar.Pervasives.Native.Mktuple4", "Hacl.Spec.K256.GLV.aff_ecmult_endo_split", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.K256.GLV.aff_negate_point_and_scalar_cond", "Hacl.Spec.K256.GLV.aff_point_mul_lambda", "Hacl.Spec.K256.GLV.scalar_split_lambda" ]
[]
false
false
true
false
false
let lemma_aff_point_mul_endo_split k p =
let r10, r20 = scalar_split_lambda k in let lambda_p = aff_point_mul_lambda p in let r1, p1 = aff_negate_point_and_scalar_cond r10 p in let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if is_high1 && is_high2 then (SM.lemma_aff_point_mul_neg r10 p; SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p) else if is_high1 && not is_high2 then (SM.lemma_aff_point_mul_neg r10 p; lemma_aff_point_mul_split_lambda k p) else if not is_high1 && is_high2 then (SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p) else lemma_aff_point_mul_split_lambda k p
false
Hacl.Spec.K256.GLV.Lemmas.fst
Hacl.Spec.K256.GLV.Lemmas.lemma_aff_proj_point_mul_double_split_lambda
val lemma_aff_proj_point_mul_double_split_lambda: k1:S.qelem -> p1:S.proj_point -> k2:S.qelem -> p2:S.proj_point -> Lemma (aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 == S.aff_point_add (aff_point_mul k1 (S.to_aff_point p1)) (aff_point_mul k2 (S.to_aff_point p2)))
val lemma_aff_proj_point_mul_double_split_lambda: k1:S.qelem -> p1:S.proj_point -> k2:S.qelem -> p2:S.proj_point -> Lemma (aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 == S.aff_point_add (aff_point_mul k1 (S.to_aff_point p1)) (aff_point_mul k2 (S.to_aff_point p2)))
let lemma_aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 = let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then begin let p1_aff = S.to_aff_point p1 in let p2_aff = S.to_aff_point p2 in let p11_aff = S.to_aff_point p11 in let p12_aff = S.to_aff_point p12 in let p21_aff = S.to_aff_point p21 in let p22_aff = S.to_aff_point p22 in calc (==) { aff_proj_point_mul_double_split_lambda k1 p1 k2 p2; (==) { LE.exp_four_fw_lemma S.mk_k256_comm_monoid p11_aff 128 r11 p12_aff r12 p21_aff r21 p22_aff r22 5 } S.aff_point_add (S.aff_point_add (S.aff_point_add (aff_point_mul r11 p11_aff) (aff_point_mul r12 p12_aff)) (aff_point_mul r21 p21_aff)) (aff_point_mul r22 p22_aff); (==) { lemma_aff_point_mul_endo_split k1 p1_aff; lemma_ecmult_endo_split_to_aff k1 p1 } S.aff_point_add (S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff)) (aff_point_mul r22 p22_aff); (==) { LS.aff_point_add_assoc_lemma (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff) } S.aff_point_add (aff_point_mul k1 p1_aff) (S.aff_point_add (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff)); (==) { lemma_aff_point_mul_endo_split k2 p2_aff; lemma_ecmult_endo_split_to_aff k2 p2 } S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul k2 p2_aff); } end else begin SE.exp_double_fw_lemma S.mk_k256_concrete_ops p1 256 k1 p2 k2 5; LE.exp_double_fw_lemma S.mk_k256_comm_monoid (S.to_aff_point p1) 256 k1 (S.to_aff_point p2) k2 5 end
{ "file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 61, "end_line": 231, "start_col": 0, "start_line": 195 }
module Hacl.Spec.K256.GLV.Lemmas open FStar.Mul module M = Lib.NatMod module LE = Lib.Exponentiation module SE = Spec.Exponentiation module S = Spec.K256 module LS = Spec.K256.Lemmas module SM = Hacl.Spec.K256.ECSM.Lemmas open Hacl.Spec.K256.GLV #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" // [lambda](px, py) = (beta * px, py) assume val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p) val lemma_glv : p:S.proj_point -> Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p)) let lemma_glv p = let (pX, pY, pZ) = p in let (px, py) = S.to_aff_point p in assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ)); let (qx, qy) = aff_point_mul lambda (px, py) in lemma_glv_aff (px, py); assert (qx = S.(beta *% px) /\ qy = py); assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ)); let (rX, rY, rZ) = point_mul_lambda p in assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ); let (rx, ry) = S.to_aff_point (rX, rY, rZ) in assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ)); assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ)); assert (qy = ry); // S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ)) assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ)); assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ))); M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ); assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ))) //-------------------------------------------- val lemma_scalar_split_lambda_eval (k:S.qelem) : Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda)) let lemma_scalar_split_lambda_eval k = assert_norm ((minus_lambda + lambda) % S.q = 0); let r1, r2 = scalar_split_lambda k in assert (r1 = S.(k +^ r2 *^ minus_lambda)); calc (==) { (r1 + (r2 * lambda % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } (r1 + r2 * lambda) % S.q; (==) { } ((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q } ((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q } (k + r2 * minus_lambda + r2 * lambda) % S.q; (==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda } (k + r2 * (minus_lambda + lambda)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q } (k + (r2 * (minus_lambda + lambda) % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q } (k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q; (==) { } k % S.q; (==) { Math.Lemmas.small_mod k S.q } k; } //-------------------------------------------- (** Fast computation of [k]P in affine coordinates *) val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point -> Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p == S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p))) let lemma_aff_point_mul_split_lambda k p = let r1, r2 = scalar_split_lambda k in calc (==) { aff_point_mul k p; (==) { lemma_scalar_split_lambda_eval k } aff_point_mul S.(r1 +^ r2 *^ lambda) p; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } aff_point_mul ((r1 + r2 * lambda) % S.q) p; (==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p } aff_point_mul (r1 + r2 * lambda) p; (==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p } S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p); (==) { lemma_glv_aff p } S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p); (==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) } S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)); } val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point -> Lemma (aff_point_mul_endo_split k p == aff_point_mul k p) let lemma_aff_point_mul_endo_split k p = let r10, r20 = scalar_split_lambda k in let lambda_p = aff_point_mul_lambda p in let r1, p1 = aff_negate_point_and_scalar_cond r10 p in let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else begin if is_high1 && not is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; lemma_aff_point_mul_split_lambda k p end else begin if not is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else lemma_aff_point_mul_split_lambda k p end end //--------------------------------- val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma (let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2) let lemma_ecmult_endo_split_to_aff k p = let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in assert (r1 == ar1 /\ r2 == ar2); let r10, r20 = scalar_split_lambda k in let p_aff = S.to_aff_point p in let lambda_p = point_mul_lambda p in let lambda_p_aff = aff_point_mul_lambda p_aff in lemma_glv p; lemma_glv_aff p_aff; assert (S.to_aff_point lambda_p == lambda_p_aff); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if not is_high1 && not is_high2 then () else begin if not is_high1 && is_high2 then LS.to_aff_point_negate_lemma lambda_p else begin if is_high1 && not is_high2 then LS.to_aff_point_negate_lemma p else begin LS.to_aff_point_negate_lemma p; LS.to_aff_point_negate_lemma lambda_p end end end (** Fast computation of [k1]P1 + [k2]P2 in projective coordinates *) // [k1]P1 + [k2]P2 = [r11 + r12 * lambda]P1 + [r21 + r22 * lambda]P2 // = [r11]P1 + [r12]([lambda]P1) + [r21]P2 + [r22]([lambda]P2) // = [r11](p1_x, p1_y) + [r12](beta * p1_x, p1_y) + [r21](p2_x, p2_y) + [r22](beta * p2_x, p2_y) let aff_proj_point_mul_double_split_lambda (k1:S.qelem) (p1:S.proj_point) (k2:S.qelem) (p2:S.proj_point) : S.aff_point = let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then LE.exp_four_fw S.mk_k256_comm_monoid (S.to_aff_point p11) 128 r11 (S.to_aff_point p12) r12 (S.to_aff_point p21) r21 (S.to_aff_point p22) r22 5 else S.to_aff_point (S.point_mul_double k1 p1 k2 p2) val lemma_aff_proj_point_mul_double_split_lambda: k1:S.qelem -> p1:S.proj_point -> k2:S.qelem -> p2:S.proj_point -> Lemma (aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 == S.aff_point_add (aff_point_mul k1 (S.to_aff_point p1)) (aff_point_mul k2 (S.to_aff_point p2)))
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.K256.ECSM.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.GLV.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.K256.ECSM.Lemmas", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": 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
k1: Spec.K256.PointOps.qelem -> p1: Spec.K256.PointOps.proj_point -> k2: Spec.K256.PointOps.qelem -> p2: Spec.K256.PointOps.proj_point -> FStar.Pervasives.Lemma (ensures Hacl.Spec.K256.GLV.Lemmas.aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 == Spec.K256.PointOps.aff_point_add (Hacl.Spec.K256.GLV.aff_point_mul k1 (Spec.K256.PointOps.to_aff_point p1)) (Hacl.Spec.K256.GLV.aff_point_mul k2 (Spec.K256.PointOps.to_aff_point p2)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.K256.PointOps.qelem", "Spec.K256.PointOps.proj_point", "Prims.op_AmpAmp", "Prims.op_LessThan", "Prims.pow2", "FStar.Calc.calc_finish", "Spec.K256.PointOps.aff_point", "Prims.eq2", "Hacl.Spec.K256.GLV.Lemmas.aff_proj_point_mul_double_split_lambda", "Spec.K256.PointOps.aff_point_add", "Hacl.Spec.K256.GLV.aff_point_mul", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Lib.Exponentiation.exp_four_fw_lemma", "Spec.K256.mk_k256_comm_monoid", "Prims.squash", "Hacl.Spec.K256.GLV.Lemmas.lemma_ecmult_endo_split_to_aff", "Hacl.Spec.K256.GLV.Lemmas.lemma_aff_point_mul_endo_split", "Spec.K256.Lemmas.aff_point_add_assoc_lemma", "Spec.K256.PointOps.to_aff_point", "Prims.bool", "Lib.Exponentiation.exp_double_fw_lemma", "Spec.Exponentiation.exp_double_fw_lemma", "Spec.K256.mk_k256_concrete_ops", "FStar.Pervasives.Native.tuple4", "Hacl.Spec.K256.GLV.ecmult_endo_split" ]
[]
false
false
true
false
false
let lemma_aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 =
let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then let p1_aff = S.to_aff_point p1 in let p2_aff = S.to_aff_point p2 in let p11_aff = S.to_aff_point p11 in let p12_aff = S.to_aff_point p12 in let p21_aff = S.to_aff_point p21 in let p22_aff = S.to_aff_point p22 in calc ( == ) { aff_proj_point_mul_double_split_lambda k1 p1 k2 p2; ( == ) { LE.exp_four_fw_lemma S.mk_k256_comm_monoid p11_aff 128 r11 p12_aff r12 p21_aff r21 p22_aff r22 5 } S.aff_point_add (S.aff_point_add (S.aff_point_add (aff_point_mul r11 p11_aff) (aff_point_mul r12 p12_aff)) (aff_point_mul r21 p21_aff)) (aff_point_mul r22 p22_aff); ( == ) { (lemma_aff_point_mul_endo_split k1 p1_aff; lemma_ecmult_endo_split_to_aff k1 p1) } S.aff_point_add (S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff)) (aff_point_mul r22 p22_aff); ( == ) { LS.aff_point_add_assoc_lemma (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff) } S.aff_point_add (aff_point_mul k1 p1_aff) (S.aff_point_add (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff)); ( == ) { (lemma_aff_point_mul_endo_split k2 p2_aff; lemma_ecmult_endo_split_to_aff k2 p2) } S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul k2 p2_aff); } else (SE.exp_double_fw_lemma S.mk_k256_concrete_ops p1 256 k1 p2 k2 5; LE.exp_double_fw_lemma S.mk_k256_comm_monoid (S.to_aff_point p1) 256 k1 (S.to_aff_point p2) k2 5 )
false
Hacl.Spec.K256.GLV.Lemmas.fst
Hacl.Spec.K256.GLV.Lemmas.aff_point_negate_cond_pow_lemma
val aff_point_negate_cond_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma (aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate == aff_point_mul k (S.to_aff_point (point_negate_cond p is_negate)))
val aff_point_negate_cond_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma (aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate == aff_point_mul k (S.to_aff_point (point_negate_cond p is_negate)))
let aff_point_negate_cond_pow_lemma is_negate p k = let p_aff = S.to_aff_point p in if is_negate then calc (==) { S.aff_point_negate (S.to_aff_point (point_mul_def k p)); (==) { SE.pow_lemma S.mk_k256_concrete_ops p k } S.aff_point_negate (aff_point_mul k p_aff); (==) { SM.aff_point_mul_neg_lemma k p_aff } aff_point_mul k (S.aff_point_negate p_aff); (==) { LS.to_aff_point_negate_lemma p } aff_point_mul k (S.to_aff_point (S.point_negate p)); } else SE.pow_lemma S.mk_k256_concrete_ops p k
{ "file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 43, "end_line": 256, "start_col": 0, "start_line": 243 }
module Hacl.Spec.K256.GLV.Lemmas open FStar.Mul module M = Lib.NatMod module LE = Lib.Exponentiation module SE = Spec.Exponentiation module S = Spec.K256 module LS = Spec.K256.Lemmas module SM = Hacl.Spec.K256.ECSM.Lemmas open Hacl.Spec.K256.GLV #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" // [lambda](px, py) = (beta * px, py) assume val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p) val lemma_glv : p:S.proj_point -> Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p)) let lemma_glv p = let (pX, pY, pZ) = p in let (px, py) = S.to_aff_point p in assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ)); let (qx, qy) = aff_point_mul lambda (px, py) in lemma_glv_aff (px, py); assert (qx = S.(beta *% px) /\ qy = py); assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ)); let (rX, rY, rZ) = point_mul_lambda p in assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ); let (rx, ry) = S.to_aff_point (rX, rY, rZ) in assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ)); assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ)); assert (qy = ry); // S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ)) assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ)); assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ))); M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ); assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ))) //-------------------------------------------- val lemma_scalar_split_lambda_eval (k:S.qelem) : Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda)) let lemma_scalar_split_lambda_eval k = assert_norm ((minus_lambda + lambda) % S.q = 0); let r1, r2 = scalar_split_lambda k in assert (r1 = S.(k +^ r2 *^ minus_lambda)); calc (==) { (r1 + (r2 * lambda % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } (r1 + r2 * lambda) % S.q; (==) { } ((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q } ((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q } (k + r2 * minus_lambda + r2 * lambda) % S.q; (==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda } (k + r2 * (minus_lambda + lambda)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q } (k + (r2 * (minus_lambda + lambda) % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q } (k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q; (==) { } k % S.q; (==) { Math.Lemmas.small_mod k S.q } k; } //-------------------------------------------- (** Fast computation of [k]P in affine coordinates *) val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point -> Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p == S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p))) let lemma_aff_point_mul_split_lambda k p = let r1, r2 = scalar_split_lambda k in calc (==) { aff_point_mul k p; (==) { lemma_scalar_split_lambda_eval k } aff_point_mul S.(r1 +^ r2 *^ lambda) p; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } aff_point_mul ((r1 + r2 * lambda) % S.q) p; (==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p } aff_point_mul (r1 + r2 * lambda) p; (==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p } S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p); (==) { lemma_glv_aff p } S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p); (==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) } S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)); } val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point -> Lemma (aff_point_mul_endo_split k p == aff_point_mul k p) let lemma_aff_point_mul_endo_split k p = let r10, r20 = scalar_split_lambda k in let lambda_p = aff_point_mul_lambda p in let r1, p1 = aff_negate_point_and_scalar_cond r10 p in let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else begin if is_high1 && not is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; lemma_aff_point_mul_split_lambda k p end else begin if not is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else lemma_aff_point_mul_split_lambda k p end end //--------------------------------- val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma (let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2) let lemma_ecmult_endo_split_to_aff k p = let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in assert (r1 == ar1 /\ r2 == ar2); let r10, r20 = scalar_split_lambda k in let p_aff = S.to_aff_point p in let lambda_p = point_mul_lambda p in let lambda_p_aff = aff_point_mul_lambda p_aff in lemma_glv p; lemma_glv_aff p_aff; assert (S.to_aff_point lambda_p == lambda_p_aff); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if not is_high1 && not is_high2 then () else begin if not is_high1 && is_high2 then LS.to_aff_point_negate_lemma lambda_p else begin if is_high1 && not is_high2 then LS.to_aff_point_negate_lemma p else begin LS.to_aff_point_negate_lemma p; LS.to_aff_point_negate_lemma lambda_p end end end (** Fast computation of [k1]P1 + [k2]P2 in projective coordinates *) // [k1]P1 + [k2]P2 = [r11 + r12 * lambda]P1 + [r21 + r22 * lambda]P2 // = [r11]P1 + [r12]([lambda]P1) + [r21]P2 + [r22]([lambda]P2) // = [r11](p1_x, p1_y) + [r12](beta * p1_x, p1_y) + [r21](p2_x, p2_y) + [r22](beta * p2_x, p2_y) let aff_proj_point_mul_double_split_lambda (k1:S.qelem) (p1:S.proj_point) (k2:S.qelem) (p2:S.proj_point) : S.aff_point = let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then LE.exp_four_fw S.mk_k256_comm_monoid (S.to_aff_point p11) 128 r11 (S.to_aff_point p12) r12 (S.to_aff_point p21) r21 (S.to_aff_point p22) r22 5 else S.to_aff_point (S.point_mul_double k1 p1 k2 p2) val lemma_aff_proj_point_mul_double_split_lambda: k1:S.qelem -> p1:S.proj_point -> k2:S.qelem -> p2:S.proj_point -> Lemma (aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 == S.aff_point_add (aff_point_mul k1 (S.to_aff_point p1)) (aff_point_mul k2 (S.to_aff_point p2))) let lemma_aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 = let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then begin let p1_aff = S.to_aff_point p1 in let p2_aff = S.to_aff_point p2 in let p11_aff = S.to_aff_point p11 in let p12_aff = S.to_aff_point p12 in let p21_aff = S.to_aff_point p21 in let p22_aff = S.to_aff_point p22 in calc (==) { aff_proj_point_mul_double_split_lambda k1 p1 k2 p2; (==) { LE.exp_four_fw_lemma S.mk_k256_comm_monoid p11_aff 128 r11 p12_aff r12 p21_aff r21 p22_aff r22 5 } S.aff_point_add (S.aff_point_add (S.aff_point_add (aff_point_mul r11 p11_aff) (aff_point_mul r12 p12_aff)) (aff_point_mul r21 p21_aff)) (aff_point_mul r22 p22_aff); (==) { lemma_aff_point_mul_endo_split k1 p1_aff; lemma_ecmult_endo_split_to_aff k1 p1 } S.aff_point_add (S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff)) (aff_point_mul r22 p22_aff); (==) { LS.aff_point_add_assoc_lemma (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff) } S.aff_point_add (aff_point_mul k1 p1_aff) (S.aff_point_add (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff)); (==) { lemma_aff_point_mul_endo_split k2 p2_aff; lemma_ecmult_endo_split_to_aff k2 p2 } S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul k2 p2_aff); } end else begin SE.exp_double_fw_lemma S.mk_k256_concrete_ops p1 256 k1 p2 k2 5; LE.exp_double_fw_lemma S.mk_k256_comm_monoid (S.to_aff_point p1) 256 k1 (S.to_aff_point p2) k2 5 end //----------------------------------- // [a]P in projective coordinates for a >= 0 let point_mul_def a p = SE.pow S.mk_k256_concrete_ops p a // [k]P or -[k]P = [k](-P) val aff_point_negate_cond_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma (aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate == aff_point_mul k (S.to_aff_point (point_negate_cond p is_negate)))
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.K256.ECSM.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.GLV.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.K256.ECSM.Lemmas", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": 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
is_negate: Prims.bool -> p: Spec.K256.PointOps.proj_point -> k: Prims.nat -> FStar.Pervasives.Lemma (ensures Hacl.Spec.K256.GLV.aff_point_negate_cond (Spec.K256.PointOps.to_aff_point (Hacl.Spec.K256.GLV.Lemmas.point_mul_def k p)) is_negate == Hacl.Spec.K256.GLV.aff_point_mul k (Spec.K256.PointOps.to_aff_point (Hacl.Spec.K256.GLV.point_negate_cond p is_negate)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.bool", "Spec.K256.PointOps.proj_point", "Prims.nat", "FStar.Calc.calc_finish", "Spec.K256.PointOps.aff_point", "Prims.eq2", "Spec.K256.PointOps.aff_point_negate", "Spec.K256.PointOps.to_aff_point", "Hacl.Spec.K256.GLV.Lemmas.point_mul_def", "Hacl.Spec.K256.GLV.aff_point_mul", "Spec.K256.PointOps.point_negate", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Spec.Exponentiation.pow_lemma", "Spec.K256.mk_k256_concrete_ops", "Prims.squash", "Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg_lemma", "Spec.K256.Lemmas.to_aff_point_negate_lemma" ]
[]
false
false
true
false
false
let aff_point_negate_cond_pow_lemma is_negate p k =
let p_aff = S.to_aff_point p in if is_negate then calc ( == ) { S.aff_point_negate (S.to_aff_point (point_mul_def k p)); ( == ) { SE.pow_lemma S.mk_k256_concrete_ops p k } S.aff_point_negate (aff_point_mul k p_aff); ( == ) { SM.aff_point_mul_neg_lemma k p_aff } aff_point_mul k (S.aff_point_negate p_aff); ( == ) { LS.to_aff_point_negate_lemma p } aff_point_mul k (S.to_aff_point (S.point_negate p)); } else SE.pow_lemma S.mk_k256_concrete_ops p k
false
LowParse.SLow.Tac.Enum.fst
LowParse.SLow.Tac.Enum.parse32_enum_key_tac
val parse32_enum_key_tac: #k: parser_kind -> #key: eqtype -> #repr: eqtype -> #p: parser k repr -> p32: parser32 p -> e: enum key repr -> Prims.unit -> T.Tac unit
val parse32_enum_key_tac: #k: parser_kind -> #key: eqtype -> #repr: eqtype -> #p: parser k repr -> p32: parser32 p -> e: enum key repr -> Prims.unit -> T.Tac unit
let parse32_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) () : T.Tac unit = T.tassert (Cons? e); let fu = quote (parse32_enum_key_gen #k #key #repr p e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> parse32_maybe_enum_key_tac p32 e ()) ]
{ "file_name": "src/lowparse/LowParse.SLow.Tac.Enum.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 56, "start_col": 0, "start_line": 40 }
module LowParse.SLow.Tac.Enum include LowParse.Spec.Tac.Enum include LowParse.SLow.Enum module T = LowParse.TacLib // // The enum tactic solves goals of type ?u:eqtype with enum types that are // in the environment at type Type0 // So typechecking such uvars fails since F* 2635 bug fix // (since uvar solutions are checked with smt off) // // To circumvent that, we use t_apply with tc_resolve_uvars flag on, // so that ?u will be typechecked as soon as it is resolved, // resulting in an smt guard that will be added to the proofstate // let apply (t:T.term) : T.Tac unit = T.t_apply true false true t noextract let parse32_maybe_enum_key_tac (#k: parser_kind) (#key #repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr { Cons? e } ) () : T.Tac unit = let fu = quote (parse32_maybe_enum_key_gen #k #key #repr #p p32 e) in apply fu; T.iseq [ T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> maybe_enum_key_of_repr_tac #key #repr e); ]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.TacLib.fst.checked", "LowParse.Spec.Tac.Enum.fst.checked", "LowParse.SLow.Enum.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Tac.Enum.fst" }
[ { "abbrev": true, "full_module": "LowParse.TacLib", "short_module": "T" }, { "abbrev": false, "full_module": "LowParse.SLow.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Tac.Enum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Tac", "short_module": null }, { "abbrev": 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
p32: LowParse.SLow.Base.parser32 p -> e: LowParse.Spec.Enum.enum key repr -> _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "LowParse.Spec.Base.parser_kind", "Prims.eqtype", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.Spec.Enum.enum", "Prims.unit", "FStar.Tactics.V1.Derived.iseq", "Prims.Cons", "LowParse.TacLib.solve_vc", "LowParse.SLow.Tac.Enum.parse32_maybe_enum_key_tac", "Prims.Nil", "LowParse.SLow.Tac.Enum.apply", "FStar.Stubs.Reflection.Types.term", "LowParse.SLow.Enum.parse32_enum_key_gen", "LowParse.TacLib.tassert", "Prims.uu___is_Cons", "FStar.Pervasives.Native.tuple2", "Prims.squash", "Prims.b2t" ]
[]
false
true
false
false
false
let parse32_enum_key_tac (#k: parser_kind) (#key: eqtype) (#repr: eqtype) (#p: parser k repr) (p32: parser32 p) (e: enum key repr) () : T.Tac unit =
T.tassert (Cons? e); let fu = quote (parse32_enum_key_gen #k #key #repr p e) in apply fu; T.iseq [T.solve_vc; T.solve_vc; T.solve_vc; (fun () -> parse32_maybe_enum_key_tac p32 e ())]
false
Hacl.Spec.K256.GLV.Lemmas.fst
Hacl.Spec.K256.GLV.Lemmas.aff_point_negate_cond_lambda_pow_lemma
val aff_point_negate_cond_lambda_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma (aff_point_mul lambda (aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate) == aff_point_mul k (S.to_aff_point (point_negate_cond (point_mul_lambda p) is_negate)))
val aff_point_negate_cond_lambda_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma (aff_point_mul lambda (aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate) == aff_point_mul k (S.to_aff_point (point_negate_cond (point_mul_lambda p) is_negate)))
let aff_point_negate_cond_lambda_pow_lemma is_negate p k = let p_aff = S.to_aff_point p in let p_lambda = point_mul_lambda p in if is_negate then calc (==) { aff_point_mul lambda (S.aff_point_negate (S.to_aff_point (point_mul_def k p))); (==) { SE.pow_lemma S.mk_k256_concrete_ops p k } aff_point_mul lambda (S.aff_point_negate (aff_point_mul k p_aff)); (==) { SM.aff_point_mul_mul_neg_lemma lambda k p_aff } aff_point_mul k (S.aff_point_negate (aff_point_mul lambda p_aff)); (==) { lemma_glv p } aff_point_mul k (S.aff_point_negate (S.to_aff_point p_lambda)); (==) { LS.to_aff_point_negate_lemma p_lambda } aff_point_mul k (S.to_aff_point (S.point_negate p_lambda)); } else calc (==) { aff_point_mul lambda (S.to_aff_point (point_mul_def k p)); (==) { SE.pow_lemma S.mk_k256_concrete_ops p k } aff_point_mul lambda (aff_point_mul k p_aff); (==) { SM.aff_point_mul_mul_lemma lambda k p_aff } aff_point_mul k (aff_point_mul lambda p_aff); (==) { lemma_glv p } aff_point_mul k (S.to_aff_point p_lambda); }
{ "file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 289, "start_col": 0, "start_line": 264 }
module Hacl.Spec.K256.GLV.Lemmas open FStar.Mul module M = Lib.NatMod module LE = Lib.Exponentiation module SE = Spec.Exponentiation module S = Spec.K256 module LS = Spec.K256.Lemmas module SM = Hacl.Spec.K256.ECSM.Lemmas open Hacl.Spec.K256.GLV #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" // [lambda](px, py) = (beta * px, py) assume val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p) val lemma_glv : p:S.proj_point -> Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p)) let lemma_glv p = let (pX, pY, pZ) = p in let (px, py) = S.to_aff_point p in assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ)); let (qx, qy) = aff_point_mul lambda (px, py) in lemma_glv_aff (px, py); assert (qx = S.(beta *% px) /\ qy = py); assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ)); let (rX, rY, rZ) = point_mul_lambda p in assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ); let (rx, ry) = S.to_aff_point (rX, rY, rZ) in assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ)); assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ)); assert (qy = ry); // S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ)) assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ)); assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ))); M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ); assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ))) //-------------------------------------------- val lemma_scalar_split_lambda_eval (k:S.qelem) : Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda)) let lemma_scalar_split_lambda_eval k = assert_norm ((minus_lambda + lambda) % S.q = 0); let r1, r2 = scalar_split_lambda k in assert (r1 = S.(k +^ r2 *^ minus_lambda)); calc (==) { (r1 + (r2 * lambda % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } (r1 + r2 * lambda) % S.q; (==) { } ((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q } ((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q } (k + r2 * minus_lambda + r2 * lambda) % S.q; (==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda } (k + r2 * (minus_lambda + lambda)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q } (k + (r2 * (minus_lambda + lambda) % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q } (k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q; (==) { } k % S.q; (==) { Math.Lemmas.small_mod k S.q } k; } //-------------------------------------------- (** Fast computation of [k]P in affine coordinates *) val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point -> Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p == S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p))) let lemma_aff_point_mul_split_lambda k p = let r1, r2 = scalar_split_lambda k in calc (==) { aff_point_mul k p; (==) { lemma_scalar_split_lambda_eval k } aff_point_mul S.(r1 +^ r2 *^ lambda) p; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } aff_point_mul ((r1 + r2 * lambda) % S.q) p; (==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p } aff_point_mul (r1 + r2 * lambda) p; (==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p } S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p); (==) { lemma_glv_aff p } S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p); (==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) } S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)); } val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point -> Lemma (aff_point_mul_endo_split k p == aff_point_mul k p) let lemma_aff_point_mul_endo_split k p = let r10, r20 = scalar_split_lambda k in let lambda_p = aff_point_mul_lambda p in let r1, p1 = aff_negate_point_and_scalar_cond r10 p in let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else begin if is_high1 && not is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; lemma_aff_point_mul_split_lambda k p end else begin if not is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else lemma_aff_point_mul_split_lambda k p end end //--------------------------------- val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma (let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2) let lemma_ecmult_endo_split_to_aff k p = let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in assert (r1 == ar1 /\ r2 == ar2); let r10, r20 = scalar_split_lambda k in let p_aff = S.to_aff_point p in let lambda_p = point_mul_lambda p in let lambda_p_aff = aff_point_mul_lambda p_aff in lemma_glv p; lemma_glv_aff p_aff; assert (S.to_aff_point lambda_p == lambda_p_aff); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if not is_high1 && not is_high2 then () else begin if not is_high1 && is_high2 then LS.to_aff_point_negate_lemma lambda_p else begin if is_high1 && not is_high2 then LS.to_aff_point_negate_lemma p else begin LS.to_aff_point_negate_lemma p; LS.to_aff_point_negate_lemma lambda_p end end end (** Fast computation of [k1]P1 + [k2]P2 in projective coordinates *) // [k1]P1 + [k2]P2 = [r11 + r12 * lambda]P1 + [r21 + r22 * lambda]P2 // = [r11]P1 + [r12]([lambda]P1) + [r21]P2 + [r22]([lambda]P2) // = [r11](p1_x, p1_y) + [r12](beta * p1_x, p1_y) + [r21](p2_x, p2_y) + [r22](beta * p2_x, p2_y) let aff_proj_point_mul_double_split_lambda (k1:S.qelem) (p1:S.proj_point) (k2:S.qelem) (p2:S.proj_point) : S.aff_point = let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then LE.exp_four_fw S.mk_k256_comm_monoid (S.to_aff_point p11) 128 r11 (S.to_aff_point p12) r12 (S.to_aff_point p21) r21 (S.to_aff_point p22) r22 5 else S.to_aff_point (S.point_mul_double k1 p1 k2 p2) val lemma_aff_proj_point_mul_double_split_lambda: k1:S.qelem -> p1:S.proj_point -> k2:S.qelem -> p2:S.proj_point -> Lemma (aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 == S.aff_point_add (aff_point_mul k1 (S.to_aff_point p1)) (aff_point_mul k2 (S.to_aff_point p2))) let lemma_aff_proj_point_mul_double_split_lambda k1 p1 k2 p2 = let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then begin let p1_aff = S.to_aff_point p1 in let p2_aff = S.to_aff_point p2 in let p11_aff = S.to_aff_point p11 in let p12_aff = S.to_aff_point p12 in let p21_aff = S.to_aff_point p21 in let p22_aff = S.to_aff_point p22 in calc (==) { aff_proj_point_mul_double_split_lambda k1 p1 k2 p2; (==) { LE.exp_four_fw_lemma S.mk_k256_comm_monoid p11_aff 128 r11 p12_aff r12 p21_aff r21 p22_aff r22 5 } S.aff_point_add (S.aff_point_add (S.aff_point_add (aff_point_mul r11 p11_aff) (aff_point_mul r12 p12_aff)) (aff_point_mul r21 p21_aff)) (aff_point_mul r22 p22_aff); (==) { lemma_aff_point_mul_endo_split k1 p1_aff; lemma_ecmult_endo_split_to_aff k1 p1 } S.aff_point_add (S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff)) (aff_point_mul r22 p22_aff); (==) { LS.aff_point_add_assoc_lemma (aff_point_mul k1 p1_aff) (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff) } S.aff_point_add (aff_point_mul k1 p1_aff) (S.aff_point_add (aff_point_mul r21 p21_aff) (aff_point_mul r22 p22_aff)); (==) { lemma_aff_point_mul_endo_split k2 p2_aff; lemma_ecmult_endo_split_to_aff k2 p2 } S.aff_point_add (aff_point_mul k1 p1_aff) (aff_point_mul k2 p2_aff); } end else begin SE.exp_double_fw_lemma S.mk_k256_concrete_ops p1 256 k1 p2 k2 5; LE.exp_double_fw_lemma S.mk_k256_comm_monoid (S.to_aff_point p1) 256 k1 (S.to_aff_point p2) k2 5 end //----------------------------------- // [a]P in projective coordinates for a >= 0 let point_mul_def a p = SE.pow S.mk_k256_concrete_ops p a // [k]P or -[k]P = [k](-P) val aff_point_negate_cond_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma (aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate == aff_point_mul k (S.to_aff_point (point_negate_cond p is_negate))) let aff_point_negate_cond_pow_lemma is_negate p k = let p_aff = S.to_aff_point p in if is_negate then calc (==) { S.aff_point_negate (S.to_aff_point (point_mul_def k p)); (==) { SE.pow_lemma S.mk_k256_concrete_ops p k } S.aff_point_negate (aff_point_mul k p_aff); (==) { SM.aff_point_mul_neg_lemma k p_aff } aff_point_mul k (S.aff_point_negate p_aff); (==) { LS.to_aff_point_negate_lemma p } aff_point_mul k (S.to_aff_point (S.point_negate p)); } else SE.pow_lemma S.mk_k256_concrete_ops p k // [k]([lambda]P) = [lambda]([k]P) or [k](-[lambda]P) = [lambda](-[k]P) val aff_point_negate_cond_lambda_pow_lemma: is_negate:bool -> p:S.proj_point -> k:nat -> Lemma (aff_point_mul lambda (aff_point_negate_cond (S.to_aff_point (point_mul_def k p)) is_negate) == aff_point_mul k (S.to_aff_point (point_negate_cond (point_mul_lambda p) is_negate)))
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.K256.ECSM.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.GLV.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.K256.ECSM.Lemmas", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": 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
is_negate: Prims.bool -> p: Spec.K256.PointOps.proj_point -> k: Prims.nat -> FStar.Pervasives.Lemma (ensures Hacl.Spec.K256.GLV.aff_point_mul Hacl.Spec.K256.GLV.lambda (Hacl.Spec.K256.GLV.aff_point_negate_cond (Spec.K256.PointOps.to_aff_point (Hacl.Spec.K256.GLV.Lemmas.point_mul_def k p)) is_negate) == Hacl.Spec.K256.GLV.aff_point_mul k (Spec.K256.PointOps.to_aff_point (Hacl.Spec.K256.GLV.point_negate_cond (Hacl.Spec.K256.GLV.point_mul_lambda p) is_negate)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.bool", "Spec.K256.PointOps.proj_point", "Prims.nat", "FStar.Calc.calc_finish", "Spec.K256.PointOps.aff_point", "Prims.eq2", "Hacl.Spec.K256.GLV.aff_point_mul", "Hacl.Spec.K256.GLV.lambda", "Spec.K256.PointOps.aff_point_negate", "Spec.K256.PointOps.to_aff_point", "Hacl.Spec.K256.GLV.Lemmas.point_mul_def", "Spec.K256.PointOps.point_negate", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Spec.Exponentiation.pow_lemma", "Spec.K256.mk_k256_concrete_ops", "Prims.squash", "Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_mul_neg_lemma", "Hacl.Spec.K256.GLV.Lemmas.lemma_glv", "Spec.K256.Lemmas.to_aff_point_negate_lemma", "Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_mul_lemma", "Hacl.Spec.K256.GLV.point_mul_lambda" ]
[]
false
false
true
false
false
let aff_point_negate_cond_lambda_pow_lemma is_negate p k =
let p_aff = S.to_aff_point p in let p_lambda = point_mul_lambda p in if is_negate then calc ( == ) { aff_point_mul lambda (S.aff_point_negate (S.to_aff_point (point_mul_def k p))); ( == ) { SE.pow_lemma S.mk_k256_concrete_ops p k } aff_point_mul lambda (S.aff_point_negate (aff_point_mul k p_aff)); ( == ) { SM.aff_point_mul_mul_neg_lemma lambda k p_aff } aff_point_mul k (S.aff_point_negate (aff_point_mul lambda p_aff)); ( == ) { lemma_glv p } aff_point_mul k (S.aff_point_negate (S.to_aff_point p_lambda)); ( == ) { LS.to_aff_point_negate_lemma p_lambda } aff_point_mul k (S.to_aff_point (S.point_negate p_lambda)); } else calc ( == ) { aff_point_mul lambda (S.to_aff_point (point_mul_def k p)); ( == ) { SE.pow_lemma S.mk_k256_concrete_ops p k } aff_point_mul lambda (aff_point_mul k p_aff); ( == ) { SM.aff_point_mul_mul_lemma lambda k p_aff } aff_point_mul k (aff_point_mul lambda p_aff); ( == ) { lemma_glv p } aff_point_mul k (S.to_aff_point p_lambda); }
false
Steel.Reference.fsti
Steel.Reference.ptr
val ptr (#a: Type0) (r: ref a) : slprop u#1
val ptr (#a: Type0) (r: ref a) : slprop u#1
let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 60, "end_line": 211, "start_col": 0, "start_line": 211 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__]
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ref a -> Steel.Memory.slprop
Prims.Tot
[ "total" ]
[]
[ "Steel.Reference.ref", "Steel.Reference.ptrp", "Steel.FractionalPermission.full_perm", "Steel.Memory.slprop" ]
[]
false
false
false
true
false
let ptr (#a: Type0) (r: ref a) : slprop u#1 =
ptrp r full_perm
false
Steel.Reference.fsti
Steel.Reference.pts_to
val pts_to : r: Steel.Reference.ref a -> p: Steel.FractionalPermission.perm -> v: a -> Steel.Effect.Common.vprop
let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v)
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 61, "start_col": 0, "start_line": 60 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ref a -> p: Steel.FractionalPermission.perm -> v: a -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.Reference.ref", "Steel.FractionalPermission.perm", "Steel.Effect.Common.to_vprop", "Steel.Reference.pts_to_sl", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let pts_to (#a: Type0) (r: ref a) ([@@@ smt_fallback]p: perm) ([@@@ smt_fallback]v: a) =
to_vprop (pts_to_sl r p v)
false
Steel.Reference.fsti
Steel.Reference.ptr_sel
val ptr_sel (#a: Type0) (r: ref a) : selector a (ptr r)
val ptr_sel (#a: Type0) (r: ref a) : selector a (ptr r)
let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 76, "end_line": 219, "start_col": 0, "start_line": 219 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm /// A selector for references, returning the value of type [a] stored in memory val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p) [@@ __steel_reduce__; __reduce__]
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ref a -> Steel.Effect.Common.selector a (Steel.Reference.ptr r)
Prims.Tot
[ "total" ]
[]
[ "Steel.Reference.ref", "Steel.Reference.ptrp_sel", "Steel.FractionalPermission.full_perm", "Steel.Effect.Common.selector", "Steel.Reference.ptr" ]
[]
false
false
false
false
false
let ptr_sel (#a: Type0) (r: ref a) : selector a (ptr r) =
ptrp_sel r full_perm
false
Hacl.Spec.K256.GLV.Lemmas.fst
Hacl.Spec.K256.GLV.Lemmas.aff_proj_point_mul_double_split_lambda
val aff_proj_point_mul_double_split_lambda (k1: S.qelem) (p1: S.proj_point) (k2: S.qelem) (p2: S.proj_point) : S.aff_point
val aff_proj_point_mul_double_split_lambda (k1: S.qelem) (p1: S.proj_point) (k2: S.qelem) (p2: S.proj_point) : S.aff_point
let aff_proj_point_mul_double_split_lambda (k1:S.qelem) (p1:S.proj_point) (k2:S.qelem) (p2:S.proj_point) : S.aff_point = let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then LE.exp_four_fw S.mk_k256_comm_monoid (S.to_aff_point p11) 128 r11 (S.to_aff_point p12) r12 (S.to_aff_point p21) r21 (S.to_aff_point p22) r22 5 else S.to_aff_point (S.point_mul_double k1 p1 k2 p2)
{ "file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 187, "start_col": 0, "start_line": 178 }
module Hacl.Spec.K256.GLV.Lemmas open FStar.Mul module M = Lib.NatMod module LE = Lib.Exponentiation module SE = Spec.Exponentiation module S = Spec.K256 module LS = Spec.K256.Lemmas module SM = Hacl.Spec.K256.ECSM.Lemmas open Hacl.Spec.K256.GLV #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" // [lambda](px, py) = (beta * px, py) assume val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p) val lemma_glv : p:S.proj_point -> Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p)) let lemma_glv p = let (pX, pY, pZ) = p in let (px, py) = S.to_aff_point p in assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ)); let (qx, qy) = aff_point_mul lambda (px, py) in lemma_glv_aff (px, py); assert (qx = S.(beta *% px) /\ qy = py); assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ)); let (rX, rY, rZ) = point_mul_lambda p in assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ); let (rx, ry) = S.to_aff_point (rX, rY, rZ) in assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ)); assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ)); assert (qy = ry); // S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ)) assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ)); assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ))); M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ); assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ))) //-------------------------------------------- val lemma_scalar_split_lambda_eval (k:S.qelem) : Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda)) let lemma_scalar_split_lambda_eval k = assert_norm ((minus_lambda + lambda) % S.q = 0); let r1, r2 = scalar_split_lambda k in assert (r1 = S.(k +^ r2 *^ minus_lambda)); calc (==) { (r1 + (r2 * lambda % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } (r1 + r2 * lambda) % S.q; (==) { } ((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q } ((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q } (k + r2 * minus_lambda + r2 * lambda) % S.q; (==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda } (k + r2 * (minus_lambda + lambda)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q } (k + (r2 * (minus_lambda + lambda) % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q } (k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q; (==) { } k % S.q; (==) { Math.Lemmas.small_mod k S.q } k; } //-------------------------------------------- (** Fast computation of [k]P in affine coordinates *) val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point -> Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p == S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p))) let lemma_aff_point_mul_split_lambda k p = let r1, r2 = scalar_split_lambda k in calc (==) { aff_point_mul k p; (==) { lemma_scalar_split_lambda_eval k } aff_point_mul S.(r1 +^ r2 *^ lambda) p; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } aff_point_mul ((r1 + r2 * lambda) % S.q) p; (==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p } aff_point_mul (r1 + r2 * lambda) p; (==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p } S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p); (==) { lemma_glv_aff p } S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p); (==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) } S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)); } val lemma_aff_point_mul_endo_split: k:S.qelem -> p:S.aff_point -> Lemma (aff_point_mul_endo_split k p == aff_point_mul k p) let lemma_aff_point_mul_endo_split k p = let r10, r20 = scalar_split_lambda k in let lambda_p = aff_point_mul_lambda p in let r1, p1 = aff_negate_point_and_scalar_cond r10 p in let r2, p2 = aff_negate_point_and_scalar_cond r20 lambda_p in assert ((r1, p1, r2, p2) == aff_ecmult_endo_split k p); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else begin if is_high1 && not is_high2 then begin SM.lemma_aff_point_mul_neg r10 p; lemma_aff_point_mul_split_lambda k p end else begin if not is_high1 && is_high2 then begin SM.lemma_aff_point_mul_neg r20 lambda_p; lemma_aff_point_mul_split_lambda k p end else lemma_aff_point_mul_split_lambda k p end end //--------------------------------- val lemma_ecmult_endo_split_to_aff: k:S.qelem -> p:S.proj_point -> Lemma (let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in r1 == ar1 /\ S.to_aff_point p1 == ap1 /\ r2 == ar2 /\ S.to_aff_point p2 == ap2) let lemma_ecmult_endo_split_to_aff k p = let r1, p1, r2, p2 = ecmult_endo_split k p in let ar1, ap1, ar2, ap2 = aff_ecmult_endo_split k (S.to_aff_point p) in assert (r1 == ar1 /\ r2 == ar2); let r10, r20 = scalar_split_lambda k in let p_aff = S.to_aff_point p in let lambda_p = point_mul_lambda p in let lambda_p_aff = aff_point_mul_lambda p_aff in lemma_glv p; lemma_glv_aff p_aff; assert (S.to_aff_point lambda_p == lambda_p_aff); let is_high1 = S.scalar_is_high r10 in let is_high2 = S.scalar_is_high r20 in if not is_high1 && not is_high2 then () else begin if not is_high1 && is_high2 then LS.to_aff_point_negate_lemma lambda_p else begin if is_high1 && not is_high2 then LS.to_aff_point_negate_lemma p else begin LS.to_aff_point_negate_lemma p; LS.to_aff_point_negate_lemma lambda_p end end end (** Fast computation of [k1]P1 + [k2]P2 in projective coordinates *) // [k1]P1 + [k2]P2 = [r11 + r12 * lambda]P1 + [r21 + r22 * lambda]P2 // = [r11]P1 + [r12]([lambda]P1) + [r21]P2 + [r22]([lambda]P2)
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.K256.ECSM.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.GLV.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.K256.ECSM.Lemmas", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": 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
k1: Spec.K256.PointOps.qelem -> p1: Spec.K256.PointOps.proj_point -> k2: Spec.K256.PointOps.qelem -> p2: Spec.K256.PointOps.proj_point -> Spec.K256.PointOps.aff_point
Prims.Tot
[ "total" ]
[]
[ "Spec.K256.PointOps.qelem", "Spec.K256.PointOps.proj_point", "Prims.op_AmpAmp", "Prims.op_LessThan", "Prims.pow2", "Lib.Exponentiation.exp_four_fw", "Spec.K256.PointOps.aff_point", "Spec.K256.mk_k256_comm_monoid", "Spec.K256.PointOps.to_aff_point", "Prims.bool", "Spec.K256.point_mul_double", "FStar.Pervasives.Native.tuple4", "Hacl.Spec.K256.GLV.ecmult_endo_split" ]
[]
false
false
false
true
false
let aff_proj_point_mul_double_split_lambda (k1: S.qelem) (p1: S.proj_point) (k2: S.qelem) (p2: S.proj_point) : S.aff_point =
let r11, p11, r12, p12 = ecmult_endo_split k1 p1 in let r21, p21, r22, p22 = ecmult_endo_split k2 p2 in if r11 < pow2 128 && r12 < pow2 128 && r21 < pow2 128 && r22 < pow2 128 then LE.exp_four_fw S.mk_k256_comm_monoid (S.to_aff_point p11) 128 r11 (S.to_aff_point p12) r12 (S.to_aff_point p21) r21 (S.to_aff_point p22) r22 5 else S.to_aff_point (S.point_mul_double k1 p1 k2 p2)
false
Steel.Reference.fsti
Steel.Reference.intro_ptr_interp
val intro_ptr_interp (#a: Type0) (r: ref a) (v: erased a) (m: mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m)
val intro_ptr_interp (#a: Type0) (r: ref a) (v: erased a) (m: mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m)
let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) = intro_ptrp_interp r full_perm v m
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 35, "end_line": 239, "start_col": 0, "start_line": 236 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm /// A selector for references, returning the value of type [a] stored in memory val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p) [@@ __steel_reduce__; __reduce__] unfold let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm /// Some lemmas to interoperate between the two versions of references val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma (requires interp (ptrp r p) m) (ensures interp (pts_to_sl r p (ptrp_sel r p m)) m) let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) = ptrp_sel_interp r full_perm m val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r p v) m) (ensures interp (ptrp r p) m)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ref a -> v: FStar.Ghost.erased a -> m: Steel.Memory.mem -> FStar.Pervasives.Lemma (requires Steel.Memory.interp (Steel.Reference.pts_to_sl r Steel.FractionalPermission.full_perm (FStar.Ghost.reveal v)) m) (ensures Steel.Memory.interp (Steel.Reference.ptr r) m)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Steel.Reference.ref", "FStar.Ghost.erased", "Steel.Memory.mem", "Steel.Reference.intro_ptrp_interp", "Steel.FractionalPermission.full_perm", "Prims.unit", "Steel.Memory.interp", "Steel.Reference.pts_to_sl", "FStar.Ghost.reveal", "Prims.squash", "Steel.Reference.ptr", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let intro_ptr_interp (#a: Type0) (r: ref a) (v: erased a) (m: mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) =
intro_ptrp_interp r full_perm v m
false
Steel.Reference.fsti
Steel.Reference.vptrp
val vptrp : r: Steel.Reference.ref a -> p: Steel.FractionalPermission.perm -> Steel.Effect.Common.vprop
let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p)
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 79, "end_line": 250, "start_col": 0, "start_line": 250 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm /// A selector for references, returning the value of type [a] stored in memory val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p) [@@ __steel_reduce__; __reduce__] unfold let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm /// Some lemmas to interoperate between the two versions of references val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma (requires interp (ptrp r p) m) (ensures interp (pts_to_sl r p (ptrp_sel r p m)) m) let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) = ptrp_sel_interp r full_perm m val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r p v) m) (ensures interp (ptrp r p) m) let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) = intro_ptrp_interp r full_perm v m /// Combining the separation logic predicate and selector into a vprop [@@ __steel_reduce__] let vptr' #a r p : vprop' = {hp = ptrp r p; t = a; sel = ptrp_sel r p} [@@ __steel_reduce__]
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ref a -> p: Steel.FractionalPermission.perm -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.Reference.ref", "Steel.FractionalPermission.perm", "Steel.Effect.Common.VUnit", "Steel.Reference.vptr'", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let vptrp (#a: Type) (r: ref a) ([@@@ smt_fallback]p: perm) =
VUnit (vptr' r p)
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.footprint
val footprint: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Ghost B.loc (requires invariant h ll) (ensures fun _ -> True)
val footprint: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Ghost B.loc (requires invariant h ll) (ensures fun _ -> True)
let footprint #_ #_ h ll = LL2.footprint h ll
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 20, "end_line": 50, "start_col": 0, "start_line": 49 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2. val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v) let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v)) /// Reflecting a stateful, imperative map as a functional one in a given heap. let v #_ #_ h ll = let l = LL2.v h ll in v_ l let invariant #_ #_ h ll = LL2.invariant h ll // No longer needed in the fsti. val footprint: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Ghost B.loc (requires invariant h ll) (ensures fun _ -> True)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> ll: LowStar.Lib.AssocList.t t_k t_v -> Prims.Ghost LowStar.Monotonic.Buffer.loc
Prims.Ghost
[]
[]
[ "Prims.eqtype", "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.AssocList.t", "LowStar.Lib.LinkedList2.footprint", "FStar.Pervasives.Native.tuple2", "LowStar.Monotonic.Buffer.loc" ]
[]
false
false
false
false
false
let footprint #_ #_ h ll =
LL2.footprint h ll
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.frame
val frame: #t_k:eqtype -> #t_v:Type0 -> ll:t t_k t_v -> l:B.loc -> h0:HS.mem -> h1: HS.mem -> Lemma (requires invariant h0 ll /\ B.loc_disjoint l (region_of ll) /\ B.modifies l h0 h1) (ensures invariant h1 ll /\ v h1 ll == v h0 ll) [ SMTPatOr [ [ SMTPat (invariant h1 ll); SMTPat (B.modifies l h0 h1) ]; [ SMTPat (v h1 ll); SMTPat (B.modifies l h0 h1) ]; ]]
val frame: #t_k:eqtype -> #t_v:Type0 -> ll:t t_k t_v -> l:B.loc -> h0:HS.mem -> h1: HS.mem -> Lemma (requires invariant h0 ll /\ B.loc_disjoint l (region_of ll) /\ B.modifies l h0 h1) (ensures invariant h1 ll /\ v h1 ll == v h0 ll) [ SMTPatOr [ [ SMTPat (invariant h1 ll); SMTPat (B.modifies l h0 h1) ]; [ SMTPat (v h1 ll); SMTPat (B.modifies l h0 h1) ]; ]]
let frame #_ #_ ll _ h0 _ = LL2.footprint_in_r h0 ll
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 26, "end_line": 56, "start_col": 0, "start_line": 55 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2. val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v) let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v)) /// Reflecting a stateful, imperative map as a functional one in a given heap. let v #_ #_ h ll = let l = LL2.v h ll in v_ l let invariant #_ #_ h ll = LL2.invariant h ll // No longer needed in the fsti. val footprint: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Ghost B.loc (requires invariant h ll) (ensures fun _ -> True) let footprint #_ #_ h ll = LL2.footprint h ll let region_of #_ #_ ll = LL2.region_of ll
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ll: LowStar.Lib.AssocList.t t_k t_v -> l: LowStar.Monotonic.Buffer.loc -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires LowStar.Lib.AssocList.invariant h0 ll /\ LowStar.Monotonic.Buffer.loc_disjoint l (LowStar.Lib.AssocList.region_of ll) /\ LowStar.Monotonic.Buffer.modifies l h0 h1) (ensures LowStar.Lib.AssocList.invariant h1 ll /\ LowStar.Lib.AssocList.v h1 ll == LowStar.Lib.AssocList.v h0 ll) [ SMTPatOr [ [ SMTPat (LowStar.Lib.AssocList.invariant h1 ll); SMTPat (LowStar.Monotonic.Buffer.modifies l h0 h1) ]; [ SMTPat (LowStar.Lib.AssocList.v h1 ll); SMTPat (LowStar.Monotonic.Buffer.modifies l h0 h1) ] ] ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "LowStar.Lib.AssocList.t", "LowStar.Monotonic.Buffer.loc", "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.LinkedList2.footprint_in_r", "FStar.Pervasives.Native.tuple2", "Prims.unit" ]
[]
true
false
true
false
false
let frame #_ #_ ll _ h0 _ =
LL2.footprint_in_r h0 ll
false
Steel.Reference.fsti
Steel.Reference.vptr
val vptr : r: Steel.Reference.ref _ -> Steel.Effect.Common.vprop
let vptr r = vptrp r full_perm
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 254, "start_col": 0, "start_line": 254 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm /// A selector for references, returning the value of type [a] stored in memory val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p) [@@ __steel_reduce__; __reduce__] unfold let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm /// Some lemmas to interoperate between the two versions of references val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma (requires interp (ptrp r p) m) (ensures interp (pts_to_sl r p (ptrp_sel r p m)) m) let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) = ptrp_sel_interp r full_perm m val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r p v) m) (ensures interp (ptrp r p) m) let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) = intro_ptrp_interp r full_perm v m /// Combining the separation logic predicate and selector into a vprop [@@ __steel_reduce__] let vptr' #a r p : vprop' = {hp = ptrp r p; t = a; sel = ptrp_sel r p} [@@ __steel_reduce__] unfold let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p) [@@ __steel_reduce__; __reduce__]
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ref _ -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.Reference.ref", "Steel.Reference.vptrp", "Steel.FractionalPermission.full_perm", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let vptr r =
vptrp r full_perm
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.find
val find (#t_k: eqtype) (#t_v: Type0) (ll: t t_k t_v) (k: t_k): Stack (option t_v) (requires fun h0 -> invariant h0 ll) (ensures fun h0 x h1 -> let m: map t_k t_v = v h0 ll in h0 == h1 /\ x == M.sel m k)
val find (#t_k: eqtype) (#t_v: Type0) (ll: t t_k t_v) (k: t_k): Stack (option t_v) (requires fun h0 -> invariant h0 ll) (ensures fun h0 x h1 -> let m: map t_k t_v = v h0 ll in h0 == h1 /\ x == M.sel m k)
let find #_ #_ ll k = find_ !*ll.LL2.ptr !*ll.LL2.v k
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 33, "end_line": 101, "start_col": 0, "start_line": 100 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2. val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v) let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v)) /// Reflecting a stateful, imperative map as a functional one in a given heap. let v #_ #_ h ll = let l = LL2.v h ll in v_ l let invariant #_ #_ h ll = LL2.invariant h ll // No longer needed in the fsti. val footprint: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Ghost B.loc (requires invariant h ll) (ensures fun _ -> True) let footprint #_ #_ h ll = LL2.footprint h ll let region_of #_ #_ ll = LL2.region_of ll let frame #_ #_ ll _ h0 _ = LL2.footprint_in_r h0 ll val footprint_in_r: #t_k:eqtype -> #t_v:Type0 -> h0:HS.mem -> ll:t t_k t_v -> Lemma (requires invariant h0 ll) (ensures B.(loc_includes (region_of ll) (footprint h0 ll))) [ SMTPat (footprint h0 ll) ] let footprint_in_r #_ #_ h0 ll = LL2.footprint_in_r h0 ll #push-options "--fuel 1" let create_in #_ #_ r = LL2.create_in r #pop-options /// Find /// ---- /// Proper recursion can only be done over the LL1.t type (unpacked representation). val find_ (#t_k: eqtype) (#t_v: Type0) (hd: LL1.t (t_k & t_v)) (l: G.erased (list (t_k & t_v))) (k: t_k): Stack (option t_v) (requires fun h0 -> LL1.well_formed h0 hd l /\ LL1.invariant h0 hd l) (ensures fun h0 x h1 -> let m: map t_k t_v = v_ l in h0 == h1 /\ x == M.sel m k) #push-options "--fuel 1 --ifuel 1" let rec find_ #_ #_ hd l k = if B.is_null hd then None else let cell = !* hd in if fst cell.LL1.data = k then Some (snd cell.LL1.data) else find_ cell.LL1.next (List.Tot.tl l) k #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ll: LowStar.Lib.AssocList.t t_k t_v -> k: t_k -> FStar.HyperStack.ST.Stack (FStar.Pervasives.Native.option t_v)
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.eqtype", "LowStar.Lib.AssocList.t", "LowStar.Lib.AssocList.find_", "FStar.Pervasives.Native.option", "FStar.Ghost.erased", "Prims.list", "FStar.Pervasives.Native.tuple2", "LowStar.BufferOps.op_Bang_Star", "LowStar.Buffer.trivial_preorder", "LowStar.Lib.LinkedList2.__proj__Mkt__item__v", "LowStar.Lib.LinkedList.t", "LowStar.Lib.LinkedList2.__proj__Mkt__item__ptr" ]
[]
false
true
false
false
false
let find #_ #_ ll k =
find_ !*ll.LL2.ptr !*ll.LL2.v k
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.add
val add (#t_k: eqtype) (#t_v: Type0) (ll: t t_k t_v) (k: t_k) (x: t_v): ST unit (requires fun h0 -> invariant h0 ll) (ensures fun h0 _ h1 -> B.modifies (region_of ll) h0 h1 /\ invariant h1 ll /\ v h1 ll == M.upd (v h0 ll) k (Some x))
val add (#t_k: eqtype) (#t_v: Type0) (ll: t t_k t_v) (k: t_k) (x: t_v): ST unit (requires fun h0 -> invariant h0 ll) (ensures fun h0 _ h1 -> B.modifies (region_of ll) h0 h1 /\ invariant h1 ll /\ v h1 ll == M.upd (v h0 ll) k (Some x))
let add #_ #_ ll k x = LL2.push ll (k, x)
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 20, "end_line": 108, "start_col": 0, "start_line": 107 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2. val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v) let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v)) /// Reflecting a stateful, imperative map as a functional one in a given heap. let v #_ #_ h ll = let l = LL2.v h ll in v_ l let invariant #_ #_ h ll = LL2.invariant h ll // No longer needed in the fsti. val footprint: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Ghost B.loc (requires invariant h ll) (ensures fun _ -> True) let footprint #_ #_ h ll = LL2.footprint h ll let region_of #_ #_ ll = LL2.region_of ll let frame #_ #_ ll _ h0 _ = LL2.footprint_in_r h0 ll val footprint_in_r: #t_k:eqtype -> #t_v:Type0 -> h0:HS.mem -> ll:t t_k t_v -> Lemma (requires invariant h0 ll) (ensures B.(loc_includes (region_of ll) (footprint h0 ll))) [ SMTPat (footprint h0 ll) ] let footprint_in_r #_ #_ h0 ll = LL2.footprint_in_r h0 ll #push-options "--fuel 1" let create_in #_ #_ r = LL2.create_in r #pop-options /// Find /// ---- /// Proper recursion can only be done over the LL1.t type (unpacked representation). val find_ (#t_k: eqtype) (#t_v: Type0) (hd: LL1.t (t_k & t_v)) (l: G.erased (list (t_k & t_v))) (k: t_k): Stack (option t_v) (requires fun h0 -> LL1.well_formed h0 hd l /\ LL1.invariant h0 hd l) (ensures fun h0 x h1 -> let m: map t_k t_v = v_ l in h0 == h1 /\ x == M.sel m k) #push-options "--fuel 1 --ifuel 1" let rec find_ #_ #_ hd l k = if B.is_null hd then None else let cell = !* hd in if fst cell.LL1.data = k then Some (snd cell.LL1.data) else find_ cell.LL1.next (List.Tot.tl l) k #pop-options let find #_ #_ ll k = find_ !*ll.LL2.ptr !*ll.LL2.v k /// Adding elements /// ---------------
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 0, "max_fuel": 1, "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ll: LowStar.Lib.AssocList.t t_k t_v -> k: t_k -> x: t_v -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "Prims.eqtype", "LowStar.Lib.AssocList.t", "LowStar.Lib.LinkedList2.push", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Prims.unit" ]
[]
false
true
false
false
false
let add #_ #_ ll k x =
LL2.push ll (k, x)
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.footprint_in_r
val footprint_in_r: #t_k:eqtype -> #t_v:Type0 -> h0:HS.mem -> ll:t t_k t_v -> Lemma (requires invariant h0 ll) (ensures B.(loc_includes (region_of ll) (footprint h0 ll))) [ SMTPat (footprint h0 ll) ]
val footprint_in_r: #t_k:eqtype -> #t_v:Type0 -> h0:HS.mem -> ll:t t_k t_v -> Lemma (requires invariant h0 ll) (ensures B.(loc_includes (region_of ll) (footprint h0 ll))) [ SMTPat (footprint h0 ll) ]
let footprint_in_r #_ #_ h0 ll = LL2.footprint_in_r h0 ll
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 26, "end_line": 66, "start_col": 0, "start_line": 65 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2. val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v) let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v)) /// Reflecting a stateful, imperative map as a functional one in a given heap. let v #_ #_ h ll = let l = LL2.v h ll in v_ l let invariant #_ #_ h ll = LL2.invariant h ll // No longer needed in the fsti. val footprint: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Ghost B.loc (requires invariant h ll) (ensures fun _ -> True) let footprint #_ #_ h ll = LL2.footprint h ll let region_of #_ #_ ll = LL2.region_of ll let frame #_ #_ ll _ h0 _ = LL2.footprint_in_r h0 ll val footprint_in_r: #t_k:eqtype -> #t_v:Type0 -> h0:HS.mem -> ll:t t_k t_v -> Lemma (requires invariant h0 ll) (ensures B.(loc_includes (region_of ll) (footprint h0 ll))) [ SMTPat (footprint h0 ll) ]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h0: FStar.Monotonic.HyperStack.mem -> ll: LowStar.Lib.AssocList.t t_k t_v -> FStar.Pervasives.Lemma (requires LowStar.Lib.AssocList.invariant h0 ll) (ensures LowStar.Monotonic.Buffer.loc_includes (LowStar.Lib.AssocList.region_of ll) (LowStar.Lib.AssocList.footprint h0 ll)) [SMTPat (LowStar.Lib.AssocList.footprint h0 ll)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "FStar.Monotonic.HyperStack.mem", "LowStar.Lib.AssocList.t", "LowStar.Lib.LinkedList2.footprint_in_r", "FStar.Pervasives.Native.tuple2", "Prims.unit" ]
[]
true
false
true
false
false
let footprint_in_r #_ #_ h0 ll =
LL2.footprint_in_r h0 ll
false
Steel.Reference.fsti
Steel.Reference.ghost_ptr_sel
val ghost_ptr_sel (#a: Type0) (r: ghost_ref a) : selector a (ghost_ptr r)
val ghost_ptr_sel (#a: Type0) (r: ghost_ref a) : selector a (ghost_ptr r)
let ghost_ptr_sel (#a:Type0) (r:ghost_ref a) : selector a (ghost_ptr r) = ghost_ptrp_sel r full_perm
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 28, "end_line": 469, "start_col": 0, "start_line": 468 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm /// A selector for references, returning the value of type [a] stored in memory val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p) [@@ __steel_reduce__; __reduce__] unfold let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm /// Some lemmas to interoperate between the two versions of references val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma (requires interp (ptrp r p) m) (ensures interp (pts_to_sl r p (ptrp_sel r p m)) m) let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) = ptrp_sel_interp r full_perm m val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r p v) m) (ensures interp (ptrp r p) m) let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) = intro_ptrp_interp r full_perm v m /// Combining the separation logic predicate and selector into a vprop [@@ __steel_reduce__] let vptr' #a r p : vprop' = {hp = ptrp r p; t = a; sel = ptrp_sel r p} [@@ __steel_reduce__] unfold let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p) [@@ __steel_reduce__; __reduce__] unfold let vptr r = vptrp r full_perm /// A wrapper to access a reference selector more easily. /// Ensuring that the corresponding ptr vprop is in the context is done by /// calling a variant of the framing tactic, as defined in Steel.Effect.Common [@@ __steel_reduce__] let sel (#a:Type) (#p:vprop) (r:ref a) (h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)}) = h (vptr r) /// Moving from indexed pts_to assertions to selector-based vprops and back val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a) : SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v) val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) : SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v) (requires fun _ -> True) (ensures fun h0 v _ -> reveal v == h0 (vptrp r p)) /// Allocates a reference with value [x]. val malloc (#a:Type0) (x:a) : Steel (ref a) emp (fun r -> vptr r) (requires fun _ -> True) (ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r)) /// Frees a reference [r] val free (#a:Type0) (r:ref a) : Steel unit (vptr r) (fun _ -> emp) (requires fun _ -> True) (ensures fun _ _ _ -> True) /// Reads the current value of reference [r] val readp (#a:Type0) (r:ref a) (p: perm) : Steel a (vptrp r p) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p)) let read (#a:Type0) (r:ref a) : Steel a (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1) = readp r full_perm /// Writes value [x] in reference [r] val write (#a:Type0) (r:ref a) (x:a) : Steel unit (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun _ _ h1 -> x == sel r h1) val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a) : SteelGhost unit uses (vptrp r p) (fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> True) (fun h _ h' -> h' (vptrp r (half_perm p)) == h (vptrp r p) ) val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm) : SteelGhost perm uses (vptrp r p0 `star` vptrp r p1) (fun res -> vptrp r res) (fun _ -> True) (fun h res h' -> res == sum_perm p0 p1 /\ h' (vptrp r res) == h (vptrp r p0) /\ h' (vptrp r res) == h (vptrp r p1) ) val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a) : SteelGhost unit uses (vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> vptrp r p) (fun _ -> True) (fun h _ h' -> h' (vptrp r p) == h (vptrp r (half_perm p)) ) /// A stateful lemma variant of the pts_to_not_null lemma above. /// This stateful function is computationally irrelevant and does not modify memory val vptrp_not_null (#opened: _) (#a: Type) (r: ref a) (p: perm) : SteelGhost unit opened (vptrp r p) (fun _ -> vptrp r p) (fun _ -> True) (fun h0 _ h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ is_null r == false ) let vptr_not_null (#opened: _) (#a: Type) (r: ref a) : SteelGhost unit opened (vptr r) (fun _ -> vptr r) (fun _ -> True) (fun h0 _ h1 -> sel r h0 == sel r h1 /\ is_null r == false ) = vptrp_not_null r full_perm (*** Ghost references ***) /// We also define a ghost variant of references, useful to do proofs relying on a ghost state /// Ghost references are marked as erasable, ensuring that they are computationally irrelevant, /// and only used in computationally irrelevant contexts. /// The functions below are variants of the reference functions defined above, /// but operating on ghost references, and with the computationally irrelevant SteelGhost effect [@@ erasable] val ghost_ref (a:Type u#0) : Type u#0 val dummy_ghost_ref (a: Type) : Tot (ghost_ref a) (* Textbook separation logic version of ghost references *) val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1 [@@ __steel_reduce__] let ghost_pts_to (#a:Type0) (r:ghost_ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) : vprop = to_vprop (ghost_pts_to_sl r p v) val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm) : Lemma (is_witness_invariant (ghost_pts_to_sl r p)) val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a) : SteelGhostT (ghost_ref a) u emp (fun r -> ghost_pts_to r full_perm x) val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a) : SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp) val ghost_share_gen_pt (#a:Type) (#u:_) (#p:perm) (#x:erased a) (r:ghost_ref a) (p1 p2: perm) : SteelGhost unit u (ghost_pts_to r p x) (fun _ -> ghost_pts_to r p1 x `star` ghost_pts_to r p2 x) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val ghost_share_pt (#a:Type) (#u:_) (#p:perm) (#x:erased a) (r:ghost_ref a) : SteelGhostT unit u (ghost_pts_to r p x) (fun _ -> ghost_pts_to r (half_perm p) x `star` ghost_pts_to r (half_perm p) x) val ghost_gather_pt (#a:Type) (#u:_) (#p0 #p1:perm) (#x0 #x1:erased a) (r:ghost_ref a) : SteelGhost unit u (ghost_pts_to r p0 x0 `star` ghost_pts_to r p1 x1) (fun _ -> ghost_pts_to r (sum_perm p0 p1) x0) (requires fun _ -> true) (ensures fun _ _ _ -> x0 == x1) val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a) : SteelGhost unit u (ghost_pts_to r p v0 `star` ghost_pts_to r q v1) (fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a) : SteelGhost unit u (ghost_pts_to r p v) (fun _ -> ghost_pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a) : SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == v) val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a) : SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> ghost_pts_to r full_perm x) (* Selector version of ghost references *) val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1 = ghost_ptrp r full_perm val ghost_ptrp_sel (#a:Type0) (r:ghost_ref a) (p: perm) : selector a (ghost_ptrp r p)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ghost_ref a -> Steel.Effect.Common.selector a (Steel.Reference.ghost_ptr r)
Prims.Tot
[ "total" ]
[]
[ "Steel.Reference.ghost_ref", "Steel.Reference.ghost_ptrp_sel", "Steel.FractionalPermission.full_perm", "Steel.Effect.Common.selector", "Steel.Reference.ghost_ptr" ]
[]
false
false
false
false
false
let ghost_ptr_sel (#a: Type0) (r: ghost_ref a) : selector a (ghost_ptr r) =
ghost_ptrp_sel r full_perm
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.find_
val find_ (#t_k: eqtype) (#t_v: Type0) (hd: LL1.t (t_k & t_v)) (l: G.erased (list (t_k & t_v))) (k: t_k): Stack (option t_v) (requires fun h0 -> LL1.well_formed h0 hd l /\ LL1.invariant h0 hd l) (ensures fun h0 x h1 -> let m: map t_k t_v = v_ l in h0 == h1 /\ x == M.sel m k)
val find_ (#t_k: eqtype) (#t_v: Type0) (hd: LL1.t (t_k & t_v)) (l: G.erased (list (t_k & t_v))) (k: t_k): Stack (option t_v) (requires fun h0 -> LL1.well_formed h0 hd l /\ LL1.invariant h0 hd l) (ensures fun h0 x h1 -> let m: map t_k t_v = v_ l in h0 == h1 /\ x == M.sel m k)
let rec find_ #_ #_ hd l k = if B.is_null hd then None else let cell = !* hd in if fst cell.LL1.data = k then Some (snd cell.LL1.data) else find_ cell.LL1.next (List.Tot.tl l) k
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 43, "end_line": 96, "start_col": 0, "start_line": 88 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2. val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v) let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v)) /// Reflecting a stateful, imperative map as a functional one in a given heap. let v #_ #_ h ll = let l = LL2.v h ll in v_ l let invariant #_ #_ h ll = LL2.invariant h ll // No longer needed in the fsti. val footprint: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Ghost B.loc (requires invariant h ll) (ensures fun _ -> True) let footprint #_ #_ h ll = LL2.footprint h ll let region_of #_ #_ ll = LL2.region_of ll let frame #_ #_ ll _ h0 _ = LL2.footprint_in_r h0 ll val footprint_in_r: #t_k:eqtype -> #t_v:Type0 -> h0:HS.mem -> ll:t t_k t_v -> Lemma (requires invariant h0 ll) (ensures B.(loc_includes (region_of ll) (footprint h0 ll))) [ SMTPat (footprint h0 ll) ] let footprint_in_r #_ #_ h0 ll = LL2.footprint_in_r h0 ll #push-options "--fuel 1" let create_in #_ #_ r = LL2.create_in r #pop-options /// Find /// ---- /// Proper recursion can only be done over the LL1.t type (unpacked representation). val find_ (#t_k: eqtype) (#t_v: Type0) (hd: LL1.t (t_k & t_v)) (l: G.erased (list (t_k & t_v))) (k: t_k): Stack (option t_v) (requires fun h0 -> LL1.well_formed h0 hd l /\ LL1.invariant h0 hd l) (ensures fun h0 x h1 -> let m: map t_k t_v = v_ l in h0 == h1 /\ x == M.sel m k)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
hd: LowStar.Lib.LinkedList.t (t_k * t_v) -> l: FStar.Ghost.erased (Prims.list (t_k * t_v)) -> k: t_k -> FStar.HyperStack.ST.Stack (FStar.Pervasives.Native.option t_v)
FStar.HyperStack.ST.Stack
[]
[]
[ "Prims.eqtype", "LowStar.Lib.LinkedList.t", "FStar.Pervasives.Native.tuple2", "FStar.Ghost.erased", "Prims.list", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "Prims.bool", "Prims.op_Equality", "FStar.Pervasives.Native.fst", "LowStar.Lib.LinkedList.__proj__Mkcell__item__data", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.snd", "LowStar.Lib.AssocList.find_", "LowStar.Lib.LinkedList.__proj__Mkcell__item__next", "FStar.Ghost.hide", "FStar.List.Tot.Base.tl", "FStar.Ghost.reveal", "LowStar.Lib.LinkedList.cell", "LowStar.BufferOps.op_Bang_Star", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.is_null" ]
[ "recursion" ]
false
true
false
false
false
let rec find_ #_ #_ hd l k =
if B.is_null hd then None else let cell = !*hd in if fst cell.LL1.data = k then Some (snd cell.LL1.data) else find_ cell.LL1.next (List.Tot.tl l) k
false
Steel.Reference.fsti
Steel.Reference.ghost_ptr
val ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1
val ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1
let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1 = ghost_ptrp r full_perm
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 24, "end_line": 463, "start_col": 0, "start_line": 462 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm /// A selector for references, returning the value of type [a] stored in memory val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p) [@@ __steel_reduce__; __reduce__] unfold let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm /// Some lemmas to interoperate between the two versions of references val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma (requires interp (ptrp r p) m) (ensures interp (pts_to_sl r p (ptrp_sel r p m)) m) let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) = ptrp_sel_interp r full_perm m val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r p v) m) (ensures interp (ptrp r p) m) let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) = intro_ptrp_interp r full_perm v m /// Combining the separation logic predicate and selector into a vprop [@@ __steel_reduce__] let vptr' #a r p : vprop' = {hp = ptrp r p; t = a; sel = ptrp_sel r p} [@@ __steel_reduce__] unfold let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p) [@@ __steel_reduce__; __reduce__] unfold let vptr r = vptrp r full_perm /// A wrapper to access a reference selector more easily. /// Ensuring that the corresponding ptr vprop is in the context is done by /// calling a variant of the framing tactic, as defined in Steel.Effect.Common [@@ __steel_reduce__] let sel (#a:Type) (#p:vprop) (r:ref a) (h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)}) = h (vptr r) /// Moving from indexed pts_to assertions to selector-based vprops and back val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a) : SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v) val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) : SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v) (requires fun _ -> True) (ensures fun h0 v _ -> reveal v == h0 (vptrp r p)) /// Allocates a reference with value [x]. val malloc (#a:Type0) (x:a) : Steel (ref a) emp (fun r -> vptr r) (requires fun _ -> True) (ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r)) /// Frees a reference [r] val free (#a:Type0) (r:ref a) : Steel unit (vptr r) (fun _ -> emp) (requires fun _ -> True) (ensures fun _ _ _ -> True) /// Reads the current value of reference [r] val readp (#a:Type0) (r:ref a) (p: perm) : Steel a (vptrp r p) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p)) let read (#a:Type0) (r:ref a) : Steel a (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1) = readp r full_perm /// Writes value [x] in reference [r] val write (#a:Type0) (r:ref a) (x:a) : Steel unit (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun _ _ h1 -> x == sel r h1) val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a) : SteelGhost unit uses (vptrp r p) (fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> True) (fun h _ h' -> h' (vptrp r (half_perm p)) == h (vptrp r p) ) val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm) : SteelGhost perm uses (vptrp r p0 `star` vptrp r p1) (fun res -> vptrp r res) (fun _ -> True) (fun h res h' -> res == sum_perm p0 p1 /\ h' (vptrp r res) == h (vptrp r p0) /\ h' (vptrp r res) == h (vptrp r p1) ) val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a) : SteelGhost unit uses (vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> vptrp r p) (fun _ -> True) (fun h _ h' -> h' (vptrp r p) == h (vptrp r (half_perm p)) ) /// A stateful lemma variant of the pts_to_not_null lemma above. /// This stateful function is computationally irrelevant and does not modify memory val vptrp_not_null (#opened: _) (#a: Type) (r: ref a) (p: perm) : SteelGhost unit opened (vptrp r p) (fun _ -> vptrp r p) (fun _ -> True) (fun h0 _ h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ is_null r == false ) let vptr_not_null (#opened: _) (#a: Type) (r: ref a) : SteelGhost unit opened (vptr r) (fun _ -> vptr r) (fun _ -> True) (fun h0 _ h1 -> sel r h0 == sel r h1 /\ is_null r == false ) = vptrp_not_null r full_perm (*** Ghost references ***) /// We also define a ghost variant of references, useful to do proofs relying on a ghost state /// Ghost references are marked as erasable, ensuring that they are computationally irrelevant, /// and only used in computationally irrelevant contexts. /// The functions below are variants of the reference functions defined above, /// but operating on ghost references, and with the computationally irrelevant SteelGhost effect [@@ erasable] val ghost_ref (a:Type u#0) : Type u#0 val dummy_ghost_ref (a: Type) : Tot (ghost_ref a) (* Textbook separation logic version of ghost references *) val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1 [@@ __steel_reduce__] let ghost_pts_to (#a:Type0) (r:ghost_ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) : vprop = to_vprop (ghost_pts_to_sl r p v) val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm) : Lemma (is_witness_invariant (ghost_pts_to_sl r p)) val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a) : SteelGhostT (ghost_ref a) u emp (fun r -> ghost_pts_to r full_perm x) val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a) : SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp) val ghost_share_gen_pt (#a:Type) (#u:_) (#p:perm) (#x:erased a) (r:ghost_ref a) (p1 p2: perm) : SteelGhost unit u (ghost_pts_to r p x) (fun _ -> ghost_pts_to r p1 x `star` ghost_pts_to r p2 x) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val ghost_share_pt (#a:Type) (#u:_) (#p:perm) (#x:erased a) (r:ghost_ref a) : SteelGhostT unit u (ghost_pts_to r p x) (fun _ -> ghost_pts_to r (half_perm p) x `star` ghost_pts_to r (half_perm p) x) val ghost_gather_pt (#a:Type) (#u:_) (#p0 #p1:perm) (#x0 #x1:erased a) (r:ghost_ref a) : SteelGhost unit u (ghost_pts_to r p0 x0 `star` ghost_pts_to r p1 x1) (fun _ -> ghost_pts_to r (sum_perm p0 p1) x0) (requires fun _ -> true) (ensures fun _ _ _ -> x0 == x1) val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a) : SteelGhost unit u (ghost_pts_to r p v0 `star` ghost_pts_to r q v1) (fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a) : SteelGhost unit u (ghost_pts_to r p v) (fun _ -> ghost_pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a) : SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == v) val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a) : SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> ghost_pts_to r full_perm x) (* Selector version of ghost references *) val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__]
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ghost_ref a -> Steel.Memory.slprop
Prims.Tot
[ "total" ]
[]
[ "Steel.Reference.ghost_ref", "Steel.Reference.ghost_ptrp", "Steel.FractionalPermission.full_perm", "Steel.Memory.slprop" ]
[]
false
false
false
true
false
let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1 =
ghost_ptrp r full_perm
false
Steel.Reference.fsti
Steel.Reference.ghost_vptrp
val ghost_vptrp : r: Steel.Reference.ghost_ref a -> p: Steel.FractionalPermission.perm -> Steel.Effect.Common.vprop
let ghost_vptrp (#a: Type) (r: ghost_ref a) ([@@@smt_fallback] p: perm) = VUnit (ghost_vptr' r p)
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 97, "end_line": 488, "start_col": 0, "start_line": 488 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm /// A selector for references, returning the value of type [a] stored in memory val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p) [@@ __steel_reduce__; __reduce__] unfold let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm /// Some lemmas to interoperate between the two versions of references val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma (requires interp (ptrp r p) m) (ensures interp (pts_to_sl r p (ptrp_sel r p m)) m) let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) = ptrp_sel_interp r full_perm m val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r p v) m) (ensures interp (ptrp r p) m) let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) = intro_ptrp_interp r full_perm v m /// Combining the separation logic predicate and selector into a vprop [@@ __steel_reduce__] let vptr' #a r p : vprop' = {hp = ptrp r p; t = a; sel = ptrp_sel r p} [@@ __steel_reduce__] unfold let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p) [@@ __steel_reduce__; __reduce__] unfold let vptr r = vptrp r full_perm /// A wrapper to access a reference selector more easily. /// Ensuring that the corresponding ptr vprop is in the context is done by /// calling a variant of the framing tactic, as defined in Steel.Effect.Common [@@ __steel_reduce__] let sel (#a:Type) (#p:vprop) (r:ref a) (h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)}) = h (vptr r) /// Moving from indexed pts_to assertions to selector-based vprops and back val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a) : SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v) val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) : SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v) (requires fun _ -> True) (ensures fun h0 v _ -> reveal v == h0 (vptrp r p)) /// Allocates a reference with value [x]. val malloc (#a:Type0) (x:a) : Steel (ref a) emp (fun r -> vptr r) (requires fun _ -> True) (ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r)) /// Frees a reference [r] val free (#a:Type0) (r:ref a) : Steel unit (vptr r) (fun _ -> emp) (requires fun _ -> True) (ensures fun _ _ _ -> True) /// Reads the current value of reference [r] val readp (#a:Type0) (r:ref a) (p: perm) : Steel a (vptrp r p) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p)) let read (#a:Type0) (r:ref a) : Steel a (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1) = readp r full_perm /// Writes value [x] in reference [r] val write (#a:Type0) (r:ref a) (x:a) : Steel unit (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun _ _ h1 -> x == sel r h1) val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a) : SteelGhost unit uses (vptrp r p) (fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> True) (fun h _ h' -> h' (vptrp r (half_perm p)) == h (vptrp r p) ) val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm) : SteelGhost perm uses (vptrp r p0 `star` vptrp r p1) (fun res -> vptrp r res) (fun _ -> True) (fun h res h' -> res == sum_perm p0 p1 /\ h' (vptrp r res) == h (vptrp r p0) /\ h' (vptrp r res) == h (vptrp r p1) ) val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a) : SteelGhost unit uses (vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> vptrp r p) (fun _ -> True) (fun h _ h' -> h' (vptrp r p) == h (vptrp r (half_perm p)) ) /// A stateful lemma variant of the pts_to_not_null lemma above. /// This stateful function is computationally irrelevant and does not modify memory val vptrp_not_null (#opened: _) (#a: Type) (r: ref a) (p: perm) : SteelGhost unit opened (vptrp r p) (fun _ -> vptrp r p) (fun _ -> True) (fun h0 _ h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ is_null r == false ) let vptr_not_null (#opened: _) (#a: Type) (r: ref a) : SteelGhost unit opened (vptr r) (fun _ -> vptr r) (fun _ -> True) (fun h0 _ h1 -> sel r h0 == sel r h1 /\ is_null r == false ) = vptrp_not_null r full_perm (*** Ghost references ***) /// We also define a ghost variant of references, useful to do proofs relying on a ghost state /// Ghost references are marked as erasable, ensuring that they are computationally irrelevant, /// and only used in computationally irrelevant contexts. /// The functions below are variants of the reference functions defined above, /// but operating on ghost references, and with the computationally irrelevant SteelGhost effect [@@ erasable] val ghost_ref (a:Type u#0) : Type u#0 val dummy_ghost_ref (a: Type) : Tot (ghost_ref a) (* Textbook separation logic version of ghost references *) val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1 [@@ __steel_reduce__] let ghost_pts_to (#a:Type0) (r:ghost_ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) : vprop = to_vprop (ghost_pts_to_sl r p v) val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm) : Lemma (is_witness_invariant (ghost_pts_to_sl r p)) val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a) : SteelGhostT (ghost_ref a) u emp (fun r -> ghost_pts_to r full_perm x) val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a) : SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp) val ghost_share_gen_pt (#a:Type) (#u:_) (#p:perm) (#x:erased a) (r:ghost_ref a) (p1 p2: perm) : SteelGhost unit u (ghost_pts_to r p x) (fun _ -> ghost_pts_to r p1 x `star` ghost_pts_to r p2 x) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val ghost_share_pt (#a:Type) (#u:_) (#p:perm) (#x:erased a) (r:ghost_ref a) : SteelGhostT unit u (ghost_pts_to r p x) (fun _ -> ghost_pts_to r (half_perm p) x `star` ghost_pts_to r (half_perm p) x) val ghost_gather_pt (#a:Type) (#u:_) (#p0 #p1:perm) (#x0 #x1:erased a) (r:ghost_ref a) : SteelGhost unit u (ghost_pts_to r p0 x0 `star` ghost_pts_to r p1 x1) (fun _ -> ghost_pts_to r (sum_perm p0 p1) x0) (requires fun _ -> true) (ensures fun _ _ _ -> x0 == x1) val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a) : SteelGhost unit u (ghost_pts_to r p v0 `star` ghost_pts_to r q v1) (fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a) : SteelGhost unit u (ghost_pts_to r p v) (fun _ -> ghost_pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a) : SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == v) val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a) : SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> ghost_pts_to r full_perm x) (* Selector version of ghost references *) val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1 = ghost_ptrp r full_perm val ghost_ptrp_sel (#a:Type0) (r:ghost_ref a) (p: perm) : selector a (ghost_ptrp r p) [@@ __steel_reduce__; __reduce__] let ghost_ptr_sel (#a:Type0) (r:ghost_ref a) : selector a (ghost_ptr r) = ghost_ptrp_sel r full_perm val ghost_ptrp_sel_interp (#a:Type0) (r:ghost_ref a) (p: perm) (m:mem) : Lemma (requires interp (ghost_ptrp r p) m) (ensures interp (ghost_pts_to_sl r p (ghost_ptrp_sel r p m)) m) let ghost_ptr_sel_interp (#a:Type0) (r:ghost_ref a) (m:mem) : Lemma (requires interp (ghost_ptr r) m) (ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m) = ghost_ptrp_sel_interp r full_perm m [@@ __steel_reduce__] let ghost_vptr' #a r p : vprop' = {hp = ghost_ptrp r p; t = a; sel = ghost_ptrp_sel r p} [@@ __steel_reduce__]
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ghost_ref a -> p: Steel.FractionalPermission.perm -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.Reference.ghost_ref", "Steel.FractionalPermission.perm", "Steel.Effect.Common.VUnit", "Steel.Reference.ghost_vptr'", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let ghost_vptrp (#a: Type) (r: ghost_ref a) ([@@@ smt_fallback]p: perm) =
VUnit (ghost_vptr' r p)
false
Steel.Reference.fsti
Steel.Reference.ghost_pts_to
val ghost_pts_to (#a: Type0) (r: ghost_ref a) ([@@@ smt_fallback]p: perm) ([@@@ smt_fallback]v: a) : vprop
val ghost_pts_to (#a: Type0) (r: ghost_ref a) ([@@@ smt_fallback]p: perm) ([@@@ smt_fallback]v: a) : vprop
let ghost_pts_to (#a:Type0) (r:ghost_ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) : vprop = to_vprop (ghost_pts_to_sl r p v)
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 36, "end_line": 386, "start_col": 0, "start_line": 381 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm /// A selector for references, returning the value of type [a] stored in memory val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p) [@@ __steel_reduce__; __reduce__] unfold let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm /// Some lemmas to interoperate between the two versions of references val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma (requires interp (ptrp r p) m) (ensures interp (pts_to_sl r p (ptrp_sel r p m)) m) let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) = ptrp_sel_interp r full_perm m val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r p v) m) (ensures interp (ptrp r p) m) let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) = intro_ptrp_interp r full_perm v m /// Combining the separation logic predicate and selector into a vprop [@@ __steel_reduce__] let vptr' #a r p : vprop' = {hp = ptrp r p; t = a; sel = ptrp_sel r p} [@@ __steel_reduce__] unfold let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p) [@@ __steel_reduce__; __reduce__] unfold let vptr r = vptrp r full_perm /// A wrapper to access a reference selector more easily. /// Ensuring that the corresponding ptr vprop is in the context is done by /// calling a variant of the framing tactic, as defined in Steel.Effect.Common [@@ __steel_reduce__] let sel (#a:Type) (#p:vprop) (r:ref a) (h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)}) = h (vptr r) /// Moving from indexed pts_to assertions to selector-based vprops and back val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a) : SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v) val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) : SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v) (requires fun _ -> True) (ensures fun h0 v _ -> reveal v == h0 (vptrp r p)) /// Allocates a reference with value [x]. val malloc (#a:Type0) (x:a) : Steel (ref a) emp (fun r -> vptr r) (requires fun _ -> True) (ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r)) /// Frees a reference [r] val free (#a:Type0) (r:ref a) : Steel unit (vptr r) (fun _ -> emp) (requires fun _ -> True) (ensures fun _ _ _ -> True) /// Reads the current value of reference [r] val readp (#a:Type0) (r:ref a) (p: perm) : Steel a (vptrp r p) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p)) let read (#a:Type0) (r:ref a) : Steel a (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1) = readp r full_perm /// Writes value [x] in reference [r] val write (#a:Type0) (r:ref a) (x:a) : Steel unit (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun _ _ h1 -> x == sel r h1) val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a) : SteelGhost unit uses (vptrp r p) (fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> True) (fun h _ h' -> h' (vptrp r (half_perm p)) == h (vptrp r p) ) val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm) : SteelGhost perm uses (vptrp r p0 `star` vptrp r p1) (fun res -> vptrp r res) (fun _ -> True) (fun h res h' -> res == sum_perm p0 p1 /\ h' (vptrp r res) == h (vptrp r p0) /\ h' (vptrp r res) == h (vptrp r p1) ) val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a) : SteelGhost unit uses (vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> vptrp r p) (fun _ -> True) (fun h _ h' -> h' (vptrp r p) == h (vptrp r (half_perm p)) ) /// A stateful lemma variant of the pts_to_not_null lemma above. /// This stateful function is computationally irrelevant and does not modify memory val vptrp_not_null (#opened: _) (#a: Type) (r: ref a) (p: perm) : SteelGhost unit opened (vptrp r p) (fun _ -> vptrp r p) (fun _ -> True) (fun h0 _ h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ is_null r == false ) let vptr_not_null (#opened: _) (#a: Type) (r: ref a) : SteelGhost unit opened (vptr r) (fun _ -> vptr r) (fun _ -> True) (fun h0 _ h1 -> sel r h0 == sel r h1 /\ is_null r == false ) = vptrp_not_null r full_perm (*** Ghost references ***) /// We also define a ghost variant of references, useful to do proofs relying on a ghost state /// Ghost references are marked as erasable, ensuring that they are computationally irrelevant, /// and only used in computationally irrelevant contexts. /// The functions below are variants of the reference functions defined above, /// but operating on ghost references, and with the computationally irrelevant SteelGhost effect [@@ erasable] val ghost_ref (a:Type u#0) : Type u#0 val dummy_ghost_ref (a: Type) : Tot (ghost_ref a) (* Textbook separation logic version of ghost references *) val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ghost_ref a -> p: Steel.FractionalPermission.perm -> v: a -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.Reference.ghost_ref", "Steel.FractionalPermission.perm", "Steel.Effect.Common.to_vprop", "Steel.Reference.ghost_pts_to_sl", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let ghost_pts_to (#a: Type0) (r: ghost_ref a) ([@@@ smt_fallback]p: perm) ([@@@ smt_fallback]v: a) : vprop =
to_vprop (ghost_pts_to_sl r p v)
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.clear
val clear (#t_k: eqtype) (#t_v: Type0) (ll: t t_k t_v): ST unit (requires fun h0 -> invariant h0 ll) (ensures fun h0 _ h1 -> B.modifies (region_of ll) h0 h1 /\ invariant h1 ll /\ v h1 ll == M.const None)
val clear (#t_k: eqtype) (#t_v: Type0) (ll: t t_k t_v): ST unit (requires fun h0 -> invariant h0 ll) (ensures fun h0 _ h1 -> B.modifies (region_of ll) h0 h1 /\ invariant h1 ll /\ v h1 ll == M.const None)
let clear #_ #_ ll = LL2.clear ll
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 14, "end_line": 195, "start_col": 0, "start_line": 194 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2. val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v) let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v)) /// Reflecting a stateful, imperative map as a functional one in a given heap. let v #_ #_ h ll = let l = LL2.v h ll in v_ l let invariant #_ #_ h ll = LL2.invariant h ll // No longer needed in the fsti. val footprint: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Ghost B.loc (requires invariant h ll) (ensures fun _ -> True) let footprint #_ #_ h ll = LL2.footprint h ll let region_of #_ #_ ll = LL2.region_of ll let frame #_ #_ ll _ h0 _ = LL2.footprint_in_r h0 ll val footprint_in_r: #t_k:eqtype -> #t_v:Type0 -> h0:HS.mem -> ll:t t_k t_v -> Lemma (requires invariant h0 ll) (ensures B.(loc_includes (region_of ll) (footprint h0 ll))) [ SMTPat (footprint h0 ll) ] let footprint_in_r #_ #_ h0 ll = LL2.footprint_in_r h0 ll #push-options "--fuel 1" let create_in #_ #_ r = LL2.create_in r #pop-options /// Find /// ---- /// Proper recursion can only be done over the LL1.t type (unpacked representation). val find_ (#t_k: eqtype) (#t_v: Type0) (hd: LL1.t (t_k & t_v)) (l: G.erased (list (t_k & t_v))) (k: t_k): Stack (option t_v) (requires fun h0 -> LL1.well_formed h0 hd l /\ LL1.invariant h0 hd l) (ensures fun h0 x h1 -> let m: map t_k t_v = v_ l in h0 == h1 /\ x == M.sel m k) #push-options "--fuel 1 --ifuel 1" let rec find_ #_ #_ hd l k = if B.is_null hd then None else let cell = !* hd in if fst cell.LL1.data = k then Some (snd cell.LL1.data) else find_ cell.LL1.next (List.Tot.tl l) k #pop-options let find #_ #_ ll k = find_ !*ll.LL2.ptr !*ll.LL2.v k /// Adding elements /// --------------- #push-options "--fuel 1" let add #_ #_ ll k x = LL2.push ll (k, x) #pop-options /// Removing elements /// ----------------- /// This one is tricky to state so temporarily disabled. I'm trying to offer a /// shadowing API that allows revealing the previous binding (if any) when the /// most recent one is remoed. However, as it stands, the precondition is not /// strong enough to conclude that just popping the first occurrence of key /// ``k`` in the list yields ``m``. /// /// I'm unsure on how to do that cleanly and abstractly without revealing to the /// client the underlying associative-list nature of the map abstraction, so /// disabling for now. /// (*val remove_one (#t_k: eqtype) (#t_v: Type0) (ll: t t_k t_v) (k: t_k) (x: G.erased t_v) (m: G.erased (map t_k t_v)): ST unit (requires fun h0 -> invariant h0 ll /\ // TODO: file bug to figure why auto-reveal doesn't work (also in post-condition) v h0 ll == M.upd m k (Some (G.reveal x))) (ensures fun h0 _ h1 -> B.modifies (footprint h0 ll) h0 h1 /\ v h1 ll == G.reveal m)*) val remove_all_ (#t_k: eqtype) (#t_v: Type0) (hd: LL1.t (t_k & t_v)) (l: G.erased (list (t_k & t_v))) (k: t_k): ST (LL1.t (t_k & t_v) & G.erased (list (t_k & t_v))) (requires fun h0 -> LL1.well_formed h0 hd l /\ LL1.invariant h0 hd l) (ensures fun h0 (hd', l') h1 -> LL1.well_formed h1 hd' l' /\ LL1.invariant h1 hd' l' /\ B.(loc_includes (LL1.footprint h0 hd l) (LL1.footprint h1 hd' l')) /\ B.modifies (LL1.footprint h0 hd l) h0 h1 /\ v_ l' == M.upd (v_ l) k None) #push-options "--fuel 1 --ifuel 1 --z3rlimit 50" let rec remove_all_ #t_k #t_v hd l k = let h0 = ST.get () in if B.is_null hd then begin M.lemma_equal_intro (v_ l) (M.upd (v_ l) k None); hd, l end else begin let cell = !*hd in let { LL1.data; LL1.next } = cell in let k', v = data in if k = k' then begin B.free hd; let h1 = ST.get () in LL1.frame next (List.Tot.tail l) (B.loc_addr_of_buffer hd) h0 h1; let hd', l' = remove_all_ next (List.Tot.tail l) k in M.lemma_equal_intro (v_ l') (M.upd (v_ l) k None); hd', l' end else begin let hd', l' = remove_all_ next (List.Tot.tail l) k in let h1 = ST.get () in hd *= { LL1.data; LL1.next = hd' }; let h2 = ST.get () in LL1.frame hd' l' (B.loc_addr_of_buffer hd) h1 h2; M.lemma_equal_intro (v_ ((k', v) :: l')) (M.upd (v_ l) k None); assert B.(loc_disjoint (loc_buffer hd) (LL1.footprint h2 hd' l')); assert (B.live h2 hd /\ B.length hd == 1); assert (LL1.well_formed h2 hd' l'); assert (LL1.invariant h2 hd (data :: l')); hd, G.hide ((k', v) :: l') end end #pop-options let remove_all #_ #_ ll k = let open LL2 in let hd, v = remove_all_ !*ll.ptr !*ll.v k in ll.ptr *= hd; ll.v *= v /// Clearing (resetting) /// --------------------
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 0, "max_fuel": 1, "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ll: LowStar.Lib.AssocList.t t_k t_v -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "Prims.eqtype", "LowStar.Lib.AssocList.t", "LowStar.Lib.LinkedList2.clear", "FStar.Pervasives.Native.tuple2", "Prims.unit" ]
[]
false
true
false
false
false
let clear #_ #_ ll =
LL2.clear ll
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.free
val free (#t_k: eqtype) (#t_v: Type0) (ll: t t_k t_v): ST unit (requires fun h0 -> invariant h0 ll) (ensures fun h0 _ h1 -> B.modifies (region_of ll) h0 h1)
val free (#t_k: eqtype) (#t_v: Type0) (ll: t t_k t_v): ST unit (requires fun h0 -> invariant h0 ll) (ensures fun h0 _ h1 -> B.modifies (region_of ll) h0 h1)
let free #_ #_ ll = LL2.free ll
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 13, "end_line": 202, "start_col": 0, "start_line": 201 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2. val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v) let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v)) /// Reflecting a stateful, imperative map as a functional one in a given heap. let v #_ #_ h ll = let l = LL2.v h ll in v_ l let invariant #_ #_ h ll = LL2.invariant h ll // No longer needed in the fsti. val footprint: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Ghost B.loc (requires invariant h ll) (ensures fun _ -> True) let footprint #_ #_ h ll = LL2.footprint h ll let region_of #_ #_ ll = LL2.region_of ll let frame #_ #_ ll _ h0 _ = LL2.footprint_in_r h0 ll val footprint_in_r: #t_k:eqtype -> #t_v:Type0 -> h0:HS.mem -> ll:t t_k t_v -> Lemma (requires invariant h0 ll) (ensures B.(loc_includes (region_of ll) (footprint h0 ll))) [ SMTPat (footprint h0 ll) ] let footprint_in_r #_ #_ h0 ll = LL2.footprint_in_r h0 ll #push-options "--fuel 1" let create_in #_ #_ r = LL2.create_in r #pop-options /// Find /// ---- /// Proper recursion can only be done over the LL1.t type (unpacked representation). val find_ (#t_k: eqtype) (#t_v: Type0) (hd: LL1.t (t_k & t_v)) (l: G.erased (list (t_k & t_v))) (k: t_k): Stack (option t_v) (requires fun h0 -> LL1.well_formed h0 hd l /\ LL1.invariant h0 hd l) (ensures fun h0 x h1 -> let m: map t_k t_v = v_ l in h0 == h1 /\ x == M.sel m k) #push-options "--fuel 1 --ifuel 1" let rec find_ #_ #_ hd l k = if B.is_null hd then None else let cell = !* hd in if fst cell.LL1.data = k then Some (snd cell.LL1.data) else find_ cell.LL1.next (List.Tot.tl l) k #pop-options let find #_ #_ ll k = find_ !*ll.LL2.ptr !*ll.LL2.v k /// Adding elements /// --------------- #push-options "--fuel 1" let add #_ #_ ll k x = LL2.push ll (k, x) #pop-options /// Removing elements /// ----------------- /// This one is tricky to state so temporarily disabled. I'm trying to offer a /// shadowing API that allows revealing the previous binding (if any) when the /// most recent one is remoed. However, as it stands, the precondition is not /// strong enough to conclude that just popping the first occurrence of key /// ``k`` in the list yields ``m``. /// /// I'm unsure on how to do that cleanly and abstractly without revealing to the /// client the underlying associative-list nature of the map abstraction, so /// disabling for now. /// (*val remove_one (#t_k: eqtype) (#t_v: Type0) (ll: t t_k t_v) (k: t_k) (x: G.erased t_v) (m: G.erased (map t_k t_v)): ST unit (requires fun h0 -> invariant h0 ll /\ // TODO: file bug to figure why auto-reveal doesn't work (also in post-condition) v h0 ll == M.upd m k (Some (G.reveal x))) (ensures fun h0 _ h1 -> B.modifies (footprint h0 ll) h0 h1 /\ v h1 ll == G.reveal m)*) val remove_all_ (#t_k: eqtype) (#t_v: Type0) (hd: LL1.t (t_k & t_v)) (l: G.erased (list (t_k & t_v))) (k: t_k): ST (LL1.t (t_k & t_v) & G.erased (list (t_k & t_v))) (requires fun h0 -> LL1.well_formed h0 hd l /\ LL1.invariant h0 hd l) (ensures fun h0 (hd', l') h1 -> LL1.well_formed h1 hd' l' /\ LL1.invariant h1 hd' l' /\ B.(loc_includes (LL1.footprint h0 hd l) (LL1.footprint h1 hd' l')) /\ B.modifies (LL1.footprint h0 hd l) h0 h1 /\ v_ l' == M.upd (v_ l) k None) #push-options "--fuel 1 --ifuel 1 --z3rlimit 50" let rec remove_all_ #t_k #t_v hd l k = let h0 = ST.get () in if B.is_null hd then begin M.lemma_equal_intro (v_ l) (M.upd (v_ l) k None); hd, l end else begin let cell = !*hd in let { LL1.data; LL1.next } = cell in let k', v = data in if k = k' then begin B.free hd; let h1 = ST.get () in LL1.frame next (List.Tot.tail l) (B.loc_addr_of_buffer hd) h0 h1; let hd', l' = remove_all_ next (List.Tot.tail l) k in M.lemma_equal_intro (v_ l') (M.upd (v_ l) k None); hd', l' end else begin let hd', l' = remove_all_ next (List.Tot.tail l) k in let h1 = ST.get () in hd *= { LL1.data; LL1.next = hd' }; let h2 = ST.get () in LL1.frame hd' l' (B.loc_addr_of_buffer hd) h1 h2; M.lemma_equal_intro (v_ ((k', v) :: l')) (M.upd (v_ l) k None); assert B.(loc_disjoint (loc_buffer hd) (LL1.footprint h2 hd' l')); assert (B.live h2 hd /\ B.length hd == 1); assert (LL1.well_formed h2 hd' l'); assert (LL1.invariant h2 hd (data :: l')); hd, G.hide ((k', v) :: l') end end #pop-options let remove_all #_ #_ ll k = let open LL2 in let hd, v = remove_all_ !*ll.ptr !*ll.v k in ll.ptr *= hd; ll.v *= v /// Clearing (resetting) /// -------------------- #push-options "--fuel 1" let clear #_ #_ ll = LL2.clear ll #pop-options /// Freeing the resource /// --------------------
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ll: LowStar.Lib.AssocList.t t_k t_v -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "Prims.eqtype", "LowStar.Lib.AssocList.t", "LowStar.Lib.LinkedList2.free", "FStar.Pervasives.Native.tuple2", "Prims.unit" ]
[]
false
true
false
false
false
let free #_ #_ ll =
LL2.free ll
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.create_in
val create_in: #t_k:eqtype -> #t_v:Type -> r:HS.rid -> ST (t t_k t_v) (requires fun h0 -> ST.is_eternal_region r) (ensures fun h0 ll h1 -> invariant h1 ll /\ B.(modifies loc_none h0 h1) /\ v h1 ll == M.const None /\ region_of ll == B.(loc_all_regions_from false r))
val create_in: #t_k:eqtype -> #t_v:Type -> r:HS.rid -> ST (t t_k t_v) (requires fun h0 -> ST.is_eternal_region r) (ensures fun h0 ll h1 -> invariant h1 ll /\ B.(modifies loc_none h0 h1) /\ v h1 ll == M.const None /\ region_of ll == B.(loc_all_regions_from false r))
let create_in #_ #_ r = LL2.create_in r
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 17, "end_line": 70, "start_col": 0, "start_line": 69 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2. val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v) let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v)) /// Reflecting a stateful, imperative map as a functional one in a given heap. let v #_ #_ h ll = let l = LL2.v h ll in v_ l let invariant #_ #_ h ll = LL2.invariant h ll // No longer needed in the fsti. val footprint: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Ghost B.loc (requires invariant h ll) (ensures fun _ -> True) let footprint #_ #_ h ll = LL2.footprint h ll let region_of #_ #_ ll = LL2.region_of ll let frame #_ #_ ll _ h0 _ = LL2.footprint_in_r h0 ll val footprint_in_r: #t_k:eqtype -> #t_v:Type0 -> h0:HS.mem -> ll:t t_k t_v -> Lemma (requires invariant h0 ll) (ensures B.(loc_includes (region_of ll) (footprint h0 ll))) [ SMTPat (footprint h0 ll) ] let footprint_in_r #_ #_ h0 ll = LL2.footprint_in_r h0 ll
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 0, "max_fuel": 1, "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Monotonic.HyperHeap.rid -> FStar.HyperStack.ST.ST (LowStar.Lib.AssocList.t t_k t_v)
FStar.HyperStack.ST.ST
[]
[]
[ "Prims.eqtype", "FStar.Monotonic.HyperHeap.rid", "LowStar.Lib.LinkedList2.create_in", "FStar.Pervasives.Native.tuple2", "LowStar.Lib.LinkedList2.t", "LowStar.Lib.AssocList.t" ]
[]
false
true
false
false
false
let create_in #_ #_ r =
LL2.create_in r
false
Hacl.Spec.K256.GLV.Lemmas.fst
Hacl.Spec.K256.GLV.Lemmas.lemma_scalar_split_lambda_eval
val lemma_scalar_split_lambda_eval (k:S.qelem) : Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda))
val lemma_scalar_split_lambda_eval (k:S.qelem) : Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda))
let lemma_scalar_split_lambda_eval k = assert_norm ((minus_lambda + lambda) % S.q = 0); let r1, r2 = scalar_split_lambda k in assert (r1 = S.(k +^ r2 *^ minus_lambda)); calc (==) { (r1 + (r2 * lambda % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } (r1 + r2 * lambda) % S.q; (==) { } ((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q } ((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q } (k + r2 * minus_lambda + r2 * lambda) % S.q; (==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda } (k + r2 * (minus_lambda + lambda)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q } (k + (r2 * (minus_lambda + lambda) % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q } (k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q; (==) { } k % S.q; (==) { Math.Lemmas.small_mod k S.q } k; }
{ "file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 75, "start_col": 0, "start_line": 50 }
module Hacl.Spec.K256.GLV.Lemmas open FStar.Mul module M = Lib.NatMod module LE = Lib.Exponentiation module SE = Spec.Exponentiation module S = Spec.K256 module LS = Spec.K256.Lemmas module SM = Hacl.Spec.K256.ECSM.Lemmas open Hacl.Spec.K256.GLV #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" // [lambda](px, py) = (beta * px, py) assume val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p) val lemma_glv : p:S.proj_point -> Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p)) let lemma_glv p = let (pX, pY, pZ) = p in let (px, py) = S.to_aff_point p in assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ)); let (qx, qy) = aff_point_mul lambda (px, py) in lemma_glv_aff (px, py); assert (qx = S.(beta *% px) /\ qy = py); assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ)); let (rX, rY, rZ) = point_mul_lambda p in assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ); let (rx, ry) = S.to_aff_point (rX, rY, rZ) in assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ)); assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ)); assert (qy = ry); // S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ)) assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ)); assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ))); M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ); assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ))) //-------------------------------------------- val lemma_scalar_split_lambda_eval (k:S.qelem) : Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda))
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.K256.ECSM.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.GLV.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.K256.ECSM.Lemmas", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": 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
k: Spec.K256.PointOps.qelem -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.K256.GLV.scalar_split_lambda k in (let FStar.Pervasives.Native.Mktuple2 #_ #_ r1 r2 = _ in k == r1 +^ r2 *^ Hacl.Spec.K256.GLV.lambda) <: Type0))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.K256.PointOps.qelem", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Modulus", "Prims.op_Addition", "FStar.Mul.op_Star", "Hacl.Spec.K256.GLV.lambda", "Spec.K256.PointOps.q", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Hacl.Spec.K256.GLV.minus_lambda", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.lemma_mod_plus_distr_r", "Prims.squash", "FStar.Math.Lemmas.lemma_mod_plus_distr_l", "FStar.Math.Lemmas.distributivity_add_right", "FStar.Math.Lemmas.lemma_mod_mul_distr_r", "FStar.Math.Lemmas.small_mod", "Prims._assert", "Prims.b2t", "Prims.op_Equality", "Spec.K256.PointOps.op_Plus_Hat", "Spec.K256.PointOps.op_Star_Hat", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.K256.GLV.scalar_split_lambda", "FStar.Pervasives.assert_norm" ]
[]
false
false
true
false
false
let lemma_scalar_split_lambda_eval k =
assert_norm ((minus_lambda + lambda) % S.q = 0); let r1, r2 = scalar_split_lambda k in assert (r1 = S.(k +^ r2 *^ minus_lambda)); calc ( == ) { (r1 + (r2 * lambda % S.q)) % S.q; ( == ) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } (r1 + r2 * lambda) % S.q; ( == ) { () } ((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q; ( == ) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q } ((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q; ( == ) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q } (k + r2 * minus_lambda + r2 * lambda) % S.q; ( == ) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda } (k + r2 * (minus_lambda + lambda)) % S.q; ( == ) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q } (k + (r2 * (minus_lambda + lambda) % S.q)) % S.q; ( == ) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q } (k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q; ( == ) { () } k % S.q; ( == ) { Math.Lemmas.small_mod k S.q } k; }
false
Steel.Reference.fsti
Steel.Reference.ghost_vptr
val ghost_vptr : r: Steel.Reference.ghost_ref _ -> Steel.Effect.Common.vprop
let ghost_vptr r = ghost_vptrp r full_perm
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 42, "end_line": 492, "start_col": 0, "start_line": 492 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm /// A selector for references, returning the value of type [a] stored in memory val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p) [@@ __steel_reduce__; __reduce__] unfold let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm /// Some lemmas to interoperate between the two versions of references val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma (requires interp (ptrp r p) m) (ensures interp (pts_to_sl r p (ptrp_sel r p m)) m) let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) = ptrp_sel_interp r full_perm m val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r p v) m) (ensures interp (ptrp r p) m) let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) = intro_ptrp_interp r full_perm v m /// Combining the separation logic predicate and selector into a vprop [@@ __steel_reduce__] let vptr' #a r p : vprop' = {hp = ptrp r p; t = a; sel = ptrp_sel r p} [@@ __steel_reduce__] unfold let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p) [@@ __steel_reduce__; __reduce__] unfold let vptr r = vptrp r full_perm /// A wrapper to access a reference selector more easily. /// Ensuring that the corresponding ptr vprop is in the context is done by /// calling a variant of the framing tactic, as defined in Steel.Effect.Common [@@ __steel_reduce__] let sel (#a:Type) (#p:vprop) (r:ref a) (h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)}) = h (vptr r) /// Moving from indexed pts_to assertions to selector-based vprops and back val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a) : SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v) val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) : SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v) (requires fun _ -> True) (ensures fun h0 v _ -> reveal v == h0 (vptrp r p)) /// Allocates a reference with value [x]. val malloc (#a:Type0) (x:a) : Steel (ref a) emp (fun r -> vptr r) (requires fun _ -> True) (ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r)) /// Frees a reference [r] val free (#a:Type0) (r:ref a) : Steel unit (vptr r) (fun _ -> emp) (requires fun _ -> True) (ensures fun _ _ _ -> True) /// Reads the current value of reference [r] val readp (#a:Type0) (r:ref a) (p: perm) : Steel a (vptrp r p) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p)) let read (#a:Type0) (r:ref a) : Steel a (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1) = readp r full_perm /// Writes value [x] in reference [r] val write (#a:Type0) (r:ref a) (x:a) : Steel unit (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun _ _ h1 -> x == sel r h1) val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a) : SteelGhost unit uses (vptrp r p) (fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> True) (fun h _ h' -> h' (vptrp r (half_perm p)) == h (vptrp r p) ) val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm) : SteelGhost perm uses (vptrp r p0 `star` vptrp r p1) (fun res -> vptrp r res) (fun _ -> True) (fun h res h' -> res == sum_perm p0 p1 /\ h' (vptrp r res) == h (vptrp r p0) /\ h' (vptrp r res) == h (vptrp r p1) ) val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a) : SteelGhost unit uses (vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> vptrp r p) (fun _ -> True) (fun h _ h' -> h' (vptrp r p) == h (vptrp r (half_perm p)) ) /// A stateful lemma variant of the pts_to_not_null lemma above. /// This stateful function is computationally irrelevant and does not modify memory val vptrp_not_null (#opened: _) (#a: Type) (r: ref a) (p: perm) : SteelGhost unit opened (vptrp r p) (fun _ -> vptrp r p) (fun _ -> True) (fun h0 _ h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ is_null r == false ) let vptr_not_null (#opened: _) (#a: Type) (r: ref a) : SteelGhost unit opened (vptr r) (fun _ -> vptr r) (fun _ -> True) (fun h0 _ h1 -> sel r h0 == sel r h1 /\ is_null r == false ) = vptrp_not_null r full_perm (*** Ghost references ***) /// We also define a ghost variant of references, useful to do proofs relying on a ghost state /// Ghost references are marked as erasable, ensuring that they are computationally irrelevant, /// and only used in computationally irrelevant contexts. /// The functions below are variants of the reference functions defined above, /// but operating on ghost references, and with the computationally irrelevant SteelGhost effect [@@ erasable] val ghost_ref (a:Type u#0) : Type u#0 val dummy_ghost_ref (a: Type) : Tot (ghost_ref a) (* Textbook separation logic version of ghost references *) val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1 [@@ __steel_reduce__] let ghost_pts_to (#a:Type0) (r:ghost_ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) : vprop = to_vprop (ghost_pts_to_sl r p v) val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm) : Lemma (is_witness_invariant (ghost_pts_to_sl r p)) val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a) : SteelGhostT (ghost_ref a) u emp (fun r -> ghost_pts_to r full_perm x) val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a) : SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp) val ghost_share_gen_pt (#a:Type) (#u:_) (#p:perm) (#x:erased a) (r:ghost_ref a) (p1 p2: perm) : SteelGhost unit u (ghost_pts_to r p x) (fun _ -> ghost_pts_to r p1 x `star` ghost_pts_to r p2 x) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val ghost_share_pt (#a:Type) (#u:_) (#p:perm) (#x:erased a) (r:ghost_ref a) : SteelGhostT unit u (ghost_pts_to r p x) (fun _ -> ghost_pts_to r (half_perm p) x `star` ghost_pts_to r (half_perm p) x) val ghost_gather_pt (#a:Type) (#u:_) (#p0 #p1:perm) (#x0 #x1:erased a) (r:ghost_ref a) : SteelGhost unit u (ghost_pts_to r p0 x0 `star` ghost_pts_to r p1 x1) (fun _ -> ghost_pts_to r (sum_perm p0 p1) x0) (requires fun _ -> true) (ensures fun _ _ _ -> x0 == x1) val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a) : SteelGhost unit u (ghost_pts_to r p v0 `star` ghost_pts_to r q v1) (fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a) : SteelGhost unit u (ghost_pts_to r p v) (fun _ -> ghost_pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a) : SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == v) val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a) : SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> ghost_pts_to r full_perm x) (* Selector version of ghost references *) val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1 = ghost_ptrp r full_perm val ghost_ptrp_sel (#a:Type0) (r:ghost_ref a) (p: perm) : selector a (ghost_ptrp r p) [@@ __steel_reduce__; __reduce__] let ghost_ptr_sel (#a:Type0) (r:ghost_ref a) : selector a (ghost_ptr r) = ghost_ptrp_sel r full_perm val ghost_ptrp_sel_interp (#a:Type0) (r:ghost_ref a) (p: perm) (m:mem) : Lemma (requires interp (ghost_ptrp r p) m) (ensures interp (ghost_pts_to_sl r p (ghost_ptrp_sel r p m)) m) let ghost_ptr_sel_interp (#a:Type0) (r:ghost_ref a) (m:mem) : Lemma (requires interp (ghost_ptr r) m) (ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m) = ghost_ptrp_sel_interp r full_perm m [@@ __steel_reduce__] let ghost_vptr' #a r p : vprop' = {hp = ghost_ptrp r p; t = a; sel = ghost_ptrp_sel r p} [@@ __steel_reduce__] unfold let ghost_vptrp (#a: Type) (r: ghost_ref a) ([@@@smt_fallback] p: perm) = VUnit (ghost_vptr' r p) [@@ __steel_reduce__; __reduce__]
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ghost_ref _ -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.Reference.ghost_ref", "Steel.Reference.ghost_vptrp", "Steel.FractionalPermission.full_perm", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let ghost_vptr r =
ghost_vptrp r full_perm
false
LowStar.Lib.AssocList.fst
LowStar.Lib.AssocList.remove_all
val remove_all (#t_k: eqtype) (#t_v: Type0) (ll: t t_k t_v) (k: t_k): ST unit (requires fun h0 -> invariant h0 ll) (ensures fun h0 _ h1 -> B.modifies (region_of ll) h0 h1 /\ invariant h1 ll /\ v h1 ll == M.upd (v h0 ll) k None)
val remove_all (#t_k: eqtype) (#t_v: Type0) (ll: t t_k t_v) (k: t_k): ST unit (requires fun h0 -> invariant h0 ll) (ensures fun h0 _ h1 -> B.modifies (region_of ll) h0 h1 /\ invariant h1 ll /\ v h1 ll == M.upd (v h0 ll) k None)
let remove_all #_ #_ ll k = let open LL2 in let hd, v = remove_all_ !*ll.ptr !*ll.v k in ll.ptr *= hd; ll.v *= v
{ "file_name": "krmllib/LowStar.Lib.AssocList.fst", "git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
{ "end_col": 11, "end_line": 188, "start_col": 0, "start_line": 184 }
module LowStar.Lib.AssocList /// A Low*, stateful associative list that exposes a map-like interface. module B = LowStar.Buffer module HS = FStar.HyperStack module G = FStar.Ghost module L = FStar.List.Tot module U32 = FStar.UInt32 module ST = FStar.HyperStack.ST module M = FStar.Map module LL2 = LowStar.Lib.LinkedList2 module LL1 = LowStar.Lib.LinkedList open FStar.HyperStack.ST open LowStar.BufferOps #set-options "--fuel 0 --ifuel 0" /// Types, invariants, footprint /// ---------------------------- /// We prefer the packed representation that is in general easier to use and will /// look at the underlying predicate-based representation from LL1 only when /// strictly needed. let t k v = LL2.t (k & v) /// Functions suffixed with an underscore operate on either LL1 or raw lists /// while those without operate on LL2. val v_: #t_k:eqtype -> #t_v:Type0 -> l:list (t_k & t_v) -> Tot (map t_k t_v) let v_ #_ #t_v l = List.Tot.fold_right (fun (k, v) m -> M.upd m k (Some v)) l (M.const (None #t_v)) /// Reflecting a stateful, imperative map as a functional one in a given heap. let v #_ #_ h ll = let l = LL2.v h ll in v_ l let invariant #_ #_ h ll = LL2.invariant h ll // No longer needed in the fsti. val footprint: #t_k:eqtype -> #t_v:Type0 -> h:HS.mem -> ll:t t_k t_v -> Ghost B.loc (requires invariant h ll) (ensures fun _ -> True) let footprint #_ #_ h ll = LL2.footprint h ll let region_of #_ #_ ll = LL2.region_of ll let frame #_ #_ ll _ h0 _ = LL2.footprint_in_r h0 ll val footprint_in_r: #t_k:eqtype -> #t_v:Type0 -> h0:HS.mem -> ll:t t_k t_v -> Lemma (requires invariant h0 ll) (ensures B.(loc_includes (region_of ll) (footprint h0 ll))) [ SMTPat (footprint h0 ll) ] let footprint_in_r #_ #_ h0 ll = LL2.footprint_in_r h0 ll #push-options "--fuel 1" let create_in #_ #_ r = LL2.create_in r #pop-options /// Find /// ---- /// Proper recursion can only be done over the LL1.t type (unpacked representation). val find_ (#t_k: eqtype) (#t_v: Type0) (hd: LL1.t (t_k & t_v)) (l: G.erased (list (t_k & t_v))) (k: t_k): Stack (option t_v) (requires fun h0 -> LL1.well_formed h0 hd l /\ LL1.invariant h0 hd l) (ensures fun h0 x h1 -> let m: map t_k t_v = v_ l in h0 == h1 /\ x == M.sel m k) #push-options "--fuel 1 --ifuel 1" let rec find_ #_ #_ hd l k = if B.is_null hd then None else let cell = !* hd in if fst cell.LL1.data = k then Some (snd cell.LL1.data) else find_ cell.LL1.next (List.Tot.tl l) k #pop-options let find #_ #_ ll k = find_ !*ll.LL2.ptr !*ll.LL2.v k /// Adding elements /// --------------- #push-options "--fuel 1" let add #_ #_ ll k x = LL2.push ll (k, x) #pop-options /// Removing elements /// ----------------- /// This one is tricky to state so temporarily disabled. I'm trying to offer a /// shadowing API that allows revealing the previous binding (if any) when the /// most recent one is remoed. However, as it stands, the precondition is not /// strong enough to conclude that just popping the first occurrence of key /// ``k`` in the list yields ``m``. /// /// I'm unsure on how to do that cleanly and abstractly without revealing to the /// client the underlying associative-list nature of the map abstraction, so /// disabling for now. /// (*val remove_one (#t_k: eqtype) (#t_v: Type0) (ll: t t_k t_v) (k: t_k) (x: G.erased t_v) (m: G.erased (map t_k t_v)): ST unit (requires fun h0 -> invariant h0 ll /\ // TODO: file bug to figure why auto-reveal doesn't work (also in post-condition) v h0 ll == M.upd m k (Some (G.reveal x))) (ensures fun h0 _ h1 -> B.modifies (footprint h0 ll) h0 h1 /\ v h1 ll == G.reveal m)*) val remove_all_ (#t_k: eqtype) (#t_v: Type0) (hd: LL1.t (t_k & t_v)) (l: G.erased (list (t_k & t_v))) (k: t_k): ST (LL1.t (t_k & t_v) & G.erased (list (t_k & t_v))) (requires fun h0 -> LL1.well_formed h0 hd l /\ LL1.invariant h0 hd l) (ensures fun h0 (hd', l') h1 -> LL1.well_formed h1 hd' l' /\ LL1.invariant h1 hd' l' /\ B.(loc_includes (LL1.footprint h0 hd l) (LL1.footprint h1 hd' l')) /\ B.modifies (LL1.footprint h0 hd l) h0 h1 /\ v_ l' == M.upd (v_ l) k None) #push-options "--fuel 1 --ifuel 1 --z3rlimit 50" let rec remove_all_ #t_k #t_v hd l k = let h0 = ST.get () in if B.is_null hd then begin M.lemma_equal_intro (v_ l) (M.upd (v_ l) k None); hd, l end else begin let cell = !*hd in let { LL1.data; LL1.next } = cell in let k', v = data in if k = k' then begin B.free hd; let h1 = ST.get () in LL1.frame next (List.Tot.tail l) (B.loc_addr_of_buffer hd) h0 h1; let hd', l' = remove_all_ next (List.Tot.tail l) k in M.lemma_equal_intro (v_ l') (M.upd (v_ l) k None); hd', l' end else begin let hd', l' = remove_all_ next (List.Tot.tail l) k in let h1 = ST.get () in hd *= { LL1.data; LL1.next = hd' }; let h2 = ST.get () in LL1.frame hd' l' (B.loc_addr_of_buffer hd) h1 h2; M.lemma_equal_intro (v_ ((k', v) :: l')) (M.upd (v_ l) k None); assert B.(loc_disjoint (loc_buffer hd) (LL1.footprint h2 hd' l')); assert (B.live h2 hd /\ B.length hd == 1); assert (LL1.well_formed h2 hd' l'); assert (LL1.invariant h2 hd (data :: l')); hd, G.hide ((k', v) :: l') end end #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Lib.LinkedList2.fst.checked", "LowStar.Lib.LinkedList.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "LowStar.Lib.AssocList.fst" }
[ { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList", "short_module": "LL1" }, { "abbrev": true, "full_module": "LowStar.Lib.LinkedList2", "short_module": "LL2" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ll: LowStar.Lib.AssocList.t t_k t_v -> k: t_k -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "Prims.eqtype", "LowStar.Lib.AssocList.t", "LowStar.Lib.LinkedList.t", "FStar.Pervasives.Native.tuple2", "FStar.Ghost.erased", "Prims.list", "LowStar.BufferOps.op_Star_Equals", "LowStar.Buffer.trivial_preorder", "LowStar.Lib.LinkedList2.__proj__Mkt__item__v", "Prims.unit", "LowStar.Lib.LinkedList2.__proj__Mkt__item__ptr", "LowStar.Lib.AssocList.remove_all_", "LowStar.BufferOps.op_Bang_Star" ]
[]
false
true
false
false
false
let remove_all #_ #_ ll k =
let open LL2 in let hd, v = remove_all_ !*ll.ptr !*ll.v k in ll.ptr *= hd; ll.v *= v
false
Spec.SHA3.Incremental.fst
Spec.SHA3.Incremental.sha3_is_incremental2
val sha3_is_incremental2 (a: keccak_alg) (input: bytes) (out_length: output_length a) : Lemma ((hash' a input out_length) `S.equal` (let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last rateInBytes input in let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length))
val sha3_is_incremental2 (a: keccak_alg) (input: bytes) (out_length: output_length a) : Lemma ((hash' a input out_length) `S.equal` (let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last rateInBytes input in let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length))
let sha3_is_incremental2 (a: keccak_alg) (input: bytes) (out_length: output_length a): Lemma (hash' a input out_length `S.equal` ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last rateInBytes input in let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length)) = let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let nb = S.length input / block_length a in let s = Lib.Sequence.create 25 (u64 0) in let bs, l = UpdateMulti.split_at_last rateInBytes input in assert (S.length bs / block_length a == nb); let f = Spec.SHA3.absorb_inner rateInBytes in calc (==) { hash' a input out_length; (==) { } ( let s = Spec.SHA3.absorb s rateInBytes (S.length input) input delimitedSuffix in Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length) ); (==) { Lib.Sequence.lemma_repeat_blocks (block_length a) input f (Spec.SHA3.absorb_last delimitedSuffix rateInBytes) s } ( let s = Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) input f nb) s in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length)); (==) { Lib.Sequence.Lemmas.repeati_extensionality #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) input f nb) (Lib.Sequence.repeat_blocks_f (block_length a) bs f nb) s } ( let s = Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) bs f nb) s in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length)); (==) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) (block_length a) bs f s } ( let s = Lib.Sequence.repeat_blocks_multi #_ #(words_state a) (block_length a) bs f s in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length)); }
{ "file_name": "specs/lemmas/Spec.SHA3.Incremental.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 213, "start_col": 0, "start_line": 173 }
module Spec.SHA3.Incremental module S = FStar.Seq open Spec.Agile.Hash open Spec.Hash.Definitions open Spec.Hash.Incremental.Definitions open Spec.Hash.Lemmas friend Spec.Agile.Hash open FStar.Mul module Loops = Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti open Lib.IntTypes #set-options "--fuel 0 --ifuel 0 --z3rlimit 200" let update_is_update_multi (a:keccak_alg) (inp:bytes{S.length inp == block_length a}) (s:words_state a) : Lemma (Spec.SHA3.absorb_inner (rate a/8) inp s == update_multi a s () inp) = let rateInBytes = rate a/8 in let f = Spec.SHA3.absorb_inner rateInBytes in let bs = block_length a in let f' = Lib.Sequence.repeat_blocks_f bs inp f 1 in assert (bs == rateInBytes); calc (==) { update_multi a s () inp; (==) { } Lib.Sequence.repeat_blocks_multi #_ #(words_state a) rateInBytes inp f s; (==) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) bs inp f s } (let len = S.length inp in let nb = len / bs in Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f bs inp f nb) s); (==) { Loops.unfold_repeati 1 f' s 0; Loops.eq_repeati0 1 f' s } f' 0 s; (==) { assert (Seq.slice inp (0 * bs) (0 * bs + bs) `S.equal` inp) } f inp s; } let suffix (a: keccak_alg) = if is_shake a then byte 0x1f else byte 0x06 val sha3_is_incremental1 (a: keccak_alg) (input: bytes) (out_length: output_length a): Lemma (hash_incremental a input out_length `S.equal` ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last rateInBytes input in let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length)) let sha3_is_incremental1 a input out_length = calc (==) { hash_incremental a input out_length; (==) { } (let s = init a in let bs, l = split_blocks a input in let s = update_multi a s () bs in let s = update_last a s () l in finish a s out_length); (==) { } (let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a/8 in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in let s = update_multi a s () bs in let s = update_last a s () l in finish a s out_length); (==) { } ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in if S.length l = rateInBytes then let s = update_multi a s () bs in let s = Spec.SHA3.absorb_inner rateInBytes l s in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in finish a s out_length else let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length ); (==) { ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in if S.length l = rateInBytes then let s = update_multi a s () bs in update_is_update_multi a l s else () ) } ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in if S.length l = rateInBytes then let s = update_multi a s () bs in let s = update_multi a s () l in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in finish a s out_length else let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length ); (==) { ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in if S.length l = rateInBytes then Lib.Sequence.Lemmas.repeat_blocks_multi_split (block_length a) (S.length bs) (bs `S.append` l) (Spec.SHA3.absorb_inner rateInBytes) s else () ) } ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in if S.length l = rateInBytes then let s = update_multi a s () (bs `S.append` l) in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in finish a s out_length else let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length ); }; calc (S.equal) { ( let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in if S.length l = rateInBytes then let s = update_multi a s () (bs `S.append` l) in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s in finish a s out_length else let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length ); (S.equal) { let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let bs, l = UpdateMulti.split_at_last_lazy rateInBytes input in let s = update_multi a s () bs in if S.length l = rateInBytes then begin let bs', l' = UpdateMulti.split_at_last rateInBytes input in // TODO: strengthen this... NL arith! assert (bs' `S.equal` (bs `S.append` l)); assert (l' `S.equal` S.empty) end else () } ( let s = Lib.Sequence.create 25 (u64 0) in // Also the block size let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last rateInBytes input in let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length ); }
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Hash.Lemmas.fsti.checked", "Spec.Hash.Incremental.Definitions.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fst.checked", "Spec.Agile.Hash.fst.checked", "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Spec.SHA3.Incremental.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Incremental.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "Spec.Hash.Incremental.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": 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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.keccak_alg -> input: Spec.Hash.Definitions.bytes -> out_length: Spec.Hash.Definitions.output_length a -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.equal (Spec.Agile.Hash.hash' a input out_length) (let s = Lib.Sequence.create 25 (Lib.IntTypes.u64 0) in let rateInBytes = Spec.Hash.Definitions.rate a / 8 in let delimitedSuffix = Spec.SHA3.Incremental.suffix a in let _ = Lib.UpdateMulti.split_at_last rateInBytes input in (let FStar.Pervasives.Native.Mktuple2 #_ #_ bs l = _ in let s = Spec.Agile.Hash.update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (FStar.Seq.Base.length l) l s in Spec.Agile.Hash.finish a s out_length) <: FStar.Seq.Base.seq (Lib.IntTypes.uint_t Lib.IntTypes.U8 Lib.IntTypes.SEC)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.Hash.Definitions.keccak_alg", "Spec.Hash.Definitions.bytes", "Spec.Hash.Definitions.output_length", "FStar.Seq.Base.seq", "Lib.UpdateMulti.uint8", "FStar.Calc.calc_finish", "Lib.ByteSequence.lbytes", "Spec.Hash.Definitions.hash_length'", "Prims.eq2", "Spec.Agile.Hash.hash'", "Spec.SHA3.squeeze", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Spec.SHA3.absorb_last", "FStar.Seq.Base.length", "Spec.Hash.Definitions.words_state", "Lib.Sequence.repeat_blocks_multi", "Spec.Hash.Definitions.block_length", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Lib.LoopCombinators.repeati", "Lib.Sequence.repeat_blocks_f", "Spec.SHA3.state", "Lib.IntTypes.uint8", "Spec.SHA3.absorb", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Lib.Sequence.lemma_repeat_blocks", "Lib.Sequence.Lemmas.repeati_extensionality", "Lib.Sequence.lemma_repeat_blocks_multi", "Lib.IntTypes.U8", "Spec.SHA3.absorb_inner", "Prims._assert", "Prims.int", "Prims.op_Division", "FStar.Pervasives.Native.tuple2", "Lib.UpdateMulti.split_at_last", "Spec.Hash.Definitions.word", "Prims.l_and", "Lib.Sequence.to_seq", "FStar.Seq.Base.create", "Lib.IntTypes.mk_int", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.index", "Lib.Sequence.create", "Lib.IntTypes.u64", "Lib.IntTypes.PUB", "Prims.l_or", "Lib.IntTypes.range", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.v", "Spec.SHA3.Incremental.suffix", "Spec.Hash.Definitions.rate", "Prims.l_True", "FStar.Seq.Base.equal", "Lib.IntTypes.uint_t", "Spec.Agile.Hash.finish", "Spec.Agile.Hash.update_multi", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let sha3_is_incremental2 (a: keccak_alg) (input: bytes) (out_length: output_length a) : Lemma ((hash' a input out_length) `S.equal` (let s = Lib.Sequence.create 25 (u64 0) in let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let bs, l = UpdateMulti.split_at_last rateInBytes input in let s = update_multi a s () bs in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in finish a s out_length)) =
let rateInBytes = rate a / 8 in let delimitedSuffix = suffix a in let nb = S.length input / block_length a in let s = Lib.Sequence.create 25 (u64 0) in let bs, l = UpdateMulti.split_at_last rateInBytes input in assert (S.length bs / block_length a == nb); let f = Spec.SHA3.absorb_inner rateInBytes in calc ( == ) { hash' a input out_length; ( == ) { () } (let s = Spec.SHA3.absorb s rateInBytes (S.length input) input delimitedSuffix in Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length)); ( == ) { Lib.Sequence.lemma_repeat_blocks (block_length a) input f (Spec.SHA3.absorb_last delimitedSuffix rateInBytes) s } (let s = Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) input f nb) s in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length)); ( == ) { Lib.Sequence.Lemmas.repeati_extensionality #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) input f nb) (Lib.Sequence.repeat_blocks_f (block_length a) bs f nb) s } (let s = Loops.repeati #(words_state a) nb (Lib.Sequence.repeat_blocks_f (block_length a) bs f nb) s in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length)); ( == ) { Lib.Sequence.lemma_repeat_blocks_multi #_ #(words_state a) (block_length a) bs f s } (let s = Lib.Sequence.repeat_blocks_multi #_ #(words_state a) (block_length a) bs f s in let s = Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length l) l s in Spec.SHA3.squeeze s rateInBytes (hash_length' a out_length)); }
false
Steel.Reference.fsti
Steel.Reference.ptr_sel_interp
val ptr_sel_interp (#a: Type0) (r: ref a) (m: mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
val ptr_sel_interp (#a: Type0) (r: ref a) (m: mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m)
let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) = ptrp_sel_interp r full_perm m
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 31, "end_line": 230, "start_col": 0, "start_line": 227 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm /// A selector for references, returning the value of type [a] stored in memory val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p) [@@ __steel_reduce__; __reduce__] unfold let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm /// Some lemmas to interoperate between the two versions of references val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma (requires interp (ptrp r p) m) (ensures interp (pts_to_sl r p (ptrp_sel r p m)) m)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ref a -> m: Steel.Memory.mem -> FStar.Pervasives.Lemma (requires Steel.Memory.interp (Steel.Reference.ptr r) m) (ensures Steel.Memory.interp (Steel.Reference.pts_to_sl r Steel.FractionalPermission.full_perm (Steel.Reference.ptr_sel r m)) m)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Steel.Reference.ref", "Steel.Memory.mem", "Steel.Reference.ptrp_sel_interp", "Steel.FractionalPermission.full_perm", "Prims.unit", "Steel.Memory.interp", "Steel.Reference.ptr", "Prims.squash", "Steel.Reference.pts_to_sl", "Steel.Reference.ptr_sel", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let ptr_sel_interp (#a: Type0) (r: ref a) (m: mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) =
ptrp_sel_interp r full_perm m
false
Steel.Reference.fsti
Steel.Reference.sel
val sel : r: Steel.Reference.ref a -> h: Steel.Effect.Common.rmem p { FStar.Tactics.Effect.with_tactic Steel.Effect.Common.selector_tactic (Steel.Effect.Common.can_be_split p (Steel.Reference.vptr r) /\ Prims.l_True) } -> Prims.GTot (Steel.Effect.Common.normal (Steel.Effect.Common.t_of (Steel.Reference.vptr r)))
let sel (#a:Type) (#p:vprop) (r:ref a) (h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)}) = h (vptr r)
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 262, "start_col": 0, "start_line": 260 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm /// A selector for references, returning the value of type [a] stored in memory val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p) [@@ __steel_reduce__; __reduce__] unfold let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm /// Some lemmas to interoperate between the two versions of references val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma (requires interp (ptrp r p) m) (ensures interp (pts_to_sl r p (ptrp_sel r p m)) m) let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) = ptrp_sel_interp r full_perm m val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r p v) m) (ensures interp (ptrp r p) m) let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) = intro_ptrp_interp r full_perm v m /// Combining the separation logic predicate and selector into a vprop [@@ __steel_reduce__] let vptr' #a r p : vprop' = {hp = ptrp r p; t = a; sel = ptrp_sel r p} [@@ __steel_reduce__] unfold let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p) [@@ __steel_reduce__; __reduce__] unfold let vptr r = vptrp r full_perm /// A wrapper to access a reference selector more easily. /// Ensuring that the corresponding ptr vprop is in the context is done by /// calling a variant of the framing tactic, as defined in Steel.Effect.Common
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ref a -> h: Steel.Effect.Common.rmem p { FStar.Tactics.Effect.with_tactic Steel.Effect.Common.selector_tactic (Steel.Effect.Common.can_be_split p (Steel.Reference.vptr r) /\ Prims.l_True) } -> Prims.GTot (Steel.Effect.Common.normal (Steel.Effect.Common.t_of (Steel.Reference.vptr r)))
Prims.GTot
[ "sometrivial" ]
[]
[ "Steel.Effect.Common.vprop", "Steel.Reference.ref", "Steel.Effect.Common.rmem", "FStar.Tactics.Effect.with_tactic", "Steel.Effect.Common.selector_tactic", "Prims.l_and", "Steel.Effect.Common.can_be_split", "Steel.Reference.vptr", "Prims.l_True", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of" ]
[]
false
false
false
false
false
let sel (#a: Type) (#p: vprop) (r: ref a) (h: rmem p {FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)}) =
h (vptr r)
false
Steel.Reference.fsti
Steel.Reference.ghost_sel
val ghost_sel : r: Steel.Reference.ghost_ref a -> h: Steel.Effect.Common.rmem p { FStar.Tactics.Effect.with_tactic Steel.Effect.Common.selector_tactic (Steel.Effect.Common.can_be_split p (Steel.Reference.ghost_vptr r) /\ Prims.l_True) } -> Prims.GTot (Steel.Effect.Common.normal (Steel.Effect.Common.t_of (Steel.Reference.ghost_vptr r)))
let ghost_sel (#a:Type) (#p:vprop) (r:ghost_ref a) (h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (ghost_vptr r) /\ True)}) = h (ghost_vptr r)
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 20, "end_line": 497, "start_col": 0, "start_line": 495 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm /// A selector for references, returning the value of type [a] stored in memory val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p) [@@ __steel_reduce__; __reduce__] unfold let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm /// Some lemmas to interoperate between the two versions of references val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma (requires interp (ptrp r p) m) (ensures interp (pts_to_sl r p (ptrp_sel r p m)) m) let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) = ptrp_sel_interp r full_perm m val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r p v) m) (ensures interp (ptrp r p) m) let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) = intro_ptrp_interp r full_perm v m /// Combining the separation logic predicate and selector into a vprop [@@ __steel_reduce__] let vptr' #a r p : vprop' = {hp = ptrp r p; t = a; sel = ptrp_sel r p} [@@ __steel_reduce__] unfold let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p) [@@ __steel_reduce__; __reduce__] unfold let vptr r = vptrp r full_perm /// A wrapper to access a reference selector more easily. /// Ensuring that the corresponding ptr vprop is in the context is done by /// calling a variant of the framing tactic, as defined in Steel.Effect.Common [@@ __steel_reduce__] let sel (#a:Type) (#p:vprop) (r:ref a) (h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)}) = h (vptr r) /// Moving from indexed pts_to assertions to selector-based vprops and back val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a) : SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v) val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) : SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v) (requires fun _ -> True) (ensures fun h0 v _ -> reveal v == h0 (vptrp r p)) /// Allocates a reference with value [x]. val malloc (#a:Type0) (x:a) : Steel (ref a) emp (fun r -> vptr r) (requires fun _ -> True) (ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r)) /// Frees a reference [r] val free (#a:Type0) (r:ref a) : Steel unit (vptr r) (fun _ -> emp) (requires fun _ -> True) (ensures fun _ _ _ -> True) /// Reads the current value of reference [r] val readp (#a:Type0) (r:ref a) (p: perm) : Steel a (vptrp r p) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p)) let read (#a:Type0) (r:ref a) : Steel a (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1) = readp r full_perm /// Writes value [x] in reference [r] val write (#a:Type0) (r:ref a) (x:a) : Steel unit (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun _ _ h1 -> x == sel r h1) val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a) : SteelGhost unit uses (vptrp r p) (fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> True) (fun h _ h' -> h' (vptrp r (half_perm p)) == h (vptrp r p) ) val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm) : SteelGhost perm uses (vptrp r p0 `star` vptrp r p1) (fun res -> vptrp r res) (fun _ -> True) (fun h res h' -> res == sum_perm p0 p1 /\ h' (vptrp r res) == h (vptrp r p0) /\ h' (vptrp r res) == h (vptrp r p1) ) val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a) : SteelGhost unit uses (vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> vptrp r p) (fun _ -> True) (fun h _ h' -> h' (vptrp r p) == h (vptrp r (half_perm p)) ) /// A stateful lemma variant of the pts_to_not_null lemma above. /// This stateful function is computationally irrelevant and does not modify memory val vptrp_not_null (#opened: _) (#a: Type) (r: ref a) (p: perm) : SteelGhost unit opened (vptrp r p) (fun _ -> vptrp r p) (fun _ -> True) (fun h0 _ h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ is_null r == false ) let vptr_not_null (#opened: _) (#a: Type) (r: ref a) : SteelGhost unit opened (vptr r) (fun _ -> vptr r) (fun _ -> True) (fun h0 _ h1 -> sel r h0 == sel r h1 /\ is_null r == false ) = vptrp_not_null r full_perm (*** Ghost references ***) /// We also define a ghost variant of references, useful to do proofs relying on a ghost state /// Ghost references are marked as erasable, ensuring that they are computationally irrelevant, /// and only used in computationally irrelevant contexts. /// The functions below are variants of the reference functions defined above, /// but operating on ghost references, and with the computationally irrelevant SteelGhost effect [@@ erasable] val ghost_ref (a:Type u#0) : Type u#0 val dummy_ghost_ref (a: Type) : Tot (ghost_ref a) (* Textbook separation logic version of ghost references *) val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1 [@@ __steel_reduce__] let ghost_pts_to (#a:Type0) (r:ghost_ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) : vprop = to_vprop (ghost_pts_to_sl r p v) val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm) : Lemma (is_witness_invariant (ghost_pts_to_sl r p)) val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a) : SteelGhostT (ghost_ref a) u emp (fun r -> ghost_pts_to r full_perm x) val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a) : SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp) val ghost_share_gen_pt (#a:Type) (#u:_) (#p:perm) (#x:erased a) (r:ghost_ref a) (p1 p2: perm) : SteelGhost unit u (ghost_pts_to r p x) (fun _ -> ghost_pts_to r p1 x `star` ghost_pts_to r p2 x) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val ghost_share_pt (#a:Type) (#u:_) (#p:perm) (#x:erased a) (r:ghost_ref a) : SteelGhostT unit u (ghost_pts_to r p x) (fun _ -> ghost_pts_to r (half_perm p) x `star` ghost_pts_to r (half_perm p) x) val ghost_gather_pt (#a:Type) (#u:_) (#p0 #p1:perm) (#x0 #x1:erased a) (r:ghost_ref a) : SteelGhost unit u (ghost_pts_to r p0 x0 `star` ghost_pts_to r p1 x1) (fun _ -> ghost_pts_to r (sum_perm p0 p1) x0) (requires fun _ -> true) (ensures fun _ _ _ -> x0 == x1) val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a) : SteelGhost unit u (ghost_pts_to r p v0 `star` ghost_pts_to r q v1) (fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a) : SteelGhost unit u (ghost_pts_to r p v) (fun _ -> ghost_pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a) : SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == v) val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a) : SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> ghost_pts_to r full_perm x) (* Selector version of ghost references *) val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1 = ghost_ptrp r full_perm val ghost_ptrp_sel (#a:Type0) (r:ghost_ref a) (p: perm) : selector a (ghost_ptrp r p) [@@ __steel_reduce__; __reduce__] let ghost_ptr_sel (#a:Type0) (r:ghost_ref a) : selector a (ghost_ptr r) = ghost_ptrp_sel r full_perm val ghost_ptrp_sel_interp (#a:Type0) (r:ghost_ref a) (p: perm) (m:mem) : Lemma (requires interp (ghost_ptrp r p) m) (ensures interp (ghost_pts_to_sl r p (ghost_ptrp_sel r p m)) m) let ghost_ptr_sel_interp (#a:Type0) (r:ghost_ref a) (m:mem) : Lemma (requires interp (ghost_ptr r) m) (ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m) = ghost_ptrp_sel_interp r full_perm m [@@ __steel_reduce__] let ghost_vptr' #a r p : vprop' = {hp = ghost_ptrp r p; t = a; sel = ghost_ptrp_sel r p} [@@ __steel_reduce__] unfold let ghost_vptrp (#a: Type) (r: ghost_ref a) ([@@@smt_fallback] p: perm) = VUnit (ghost_vptr' r p) [@@ __steel_reduce__; __reduce__] unfold let ghost_vptr r = ghost_vptrp r full_perm
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ghost_ref a -> h: Steel.Effect.Common.rmem p { FStar.Tactics.Effect.with_tactic Steel.Effect.Common.selector_tactic (Steel.Effect.Common.can_be_split p (Steel.Reference.ghost_vptr r) /\ Prims.l_True) } -> Prims.GTot (Steel.Effect.Common.normal (Steel.Effect.Common.t_of (Steel.Reference.ghost_vptr r)))
Prims.GTot
[ "sometrivial" ]
[]
[ "Steel.Effect.Common.vprop", "Steel.Reference.ghost_ref", "Steel.Effect.Common.rmem", "FStar.Tactics.Effect.with_tactic", "Steel.Effect.Common.selector_tactic", "Prims.l_and", "Steel.Effect.Common.can_be_split", "Steel.Reference.ghost_vptr", "Prims.l_True", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of" ]
[]
false
false
false
false
false
let ghost_sel (#a: Type) (#p: vprop) (r: ghost_ref a) (h: rmem p {FStar.Tactics.with_tactic selector_tactic (can_be_split p (ghost_vptr r) /\ True)} ) =
h (ghost_vptr r)
false
Steel.Reference.fsti
Steel.Reference.ghost_ptr_sel_interp
val ghost_ptr_sel_interp (#a: Type0) (r: ghost_ref a) (m: mem) : Lemma (requires interp (ghost_ptr r) m) (ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m)
val ghost_ptr_sel_interp (#a: Type0) (r: ghost_ref a) (m: mem) : Lemma (requires interp (ghost_ptr r) m) (ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m)
let ghost_ptr_sel_interp (#a:Type0) (r:ghost_ref a) (m:mem) : Lemma (requires interp (ghost_ptr r) m) (ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m) = ghost_ptrp_sel_interp r full_perm m
{ "file_name": "lib/steel/Steel.Reference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 37, "end_line": 478, "start_col": 0, "start_line": 475 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Reference open FStar.Ghost open Steel.FractionalPermission open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module U32 = FStar.UInt32 module Mem = Steel.Memory /// The main user-facing Steel library. /// This library provides functions to operate on references to values in universe 0, such as uints. /// This library provides two versions, which can interoperate with each other. /// The first one uses the standard separation logic pts_to predicate, and has a non-informative selector /// The second one has a selector which returns the contents of the reference in memory, enabling /// to better separate reasoning about memory safety and functional correctness when handling references. /// An abstract datatype for references val ref ([@@@unused] a:Type0) : Type0 /// The null pointer [@@ noextract_to "krml"] val null (#a:Type0) : ref a /// Checking whether a pointer is null can be done in a decidable way [@@ noextract_to "krml"] val is_null (#a:Type0) (r:ref a) : (b:bool{b <==> r == null}) (** First version of references: Non-informative selector and standard pts_to predicate. All functions names here are postfixed with _pt (for points_to)**) /// The standard points to separation logic assertion, expressing that /// reference [r] is valid in memory, stores value [v], and that we have /// permission [p] on it. val pts_to_sl (#a:Type0) (r:ref a) (p:perm) (v:a) : slprop u#1 /// Lifting the standard points to predicate to vprop, with a non-informative selector. /// The permission [p] and the value [v] are annotated with the smt_fallback attribute, /// enabling SMT rewriting on them during frame inference [@@ __steel_reduce__] let pts_to (#a:Type0) (r:ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) = to_vprop (pts_to_sl r p v) /// If two pts_to predicates on the same reference [r] are valid in the memory [m], /// then the two values [v0] and [v1] are identical val pts_to_ref_injective (#a: Type u#0) (r: ref a) (p0 p1:perm) (v0 v1:a) (m:mem) : Lemma (requires interp (pts_to_sl r p0 v0 `Mem.star` pts_to_sl r p1 v1) m) (ensures v0 == v1) /// A valid pts_to predicate implies that the pointer is not the null pointer val pts_to_not_null (#a:Type u#0) (x:ref a) (p:perm) (v:a) (m:mem) : Lemma (requires interp (pts_to_sl x p v) m) (ensures x =!= null) /// Exposing the is_witness_invariant from Steel.Memory for references with fractional permissions val pts_to_witinv (#a:Type) (r:ref a) (p:perm) : Lemma (is_witness_invariant (pts_to_sl r p)) /// A stateful version of the pts_to_ref_injective lemma above val pts_to_injective_eq (#a: Type) (#opened:inames) (#p0 #p1:perm) (#v0 #v1: erased a) (r: ref a) : SteelGhost unit opened (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r p0 v0 `star` pts_to r p1 v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ref a) : SteelGhost unit u (pts_to r p v) (fun _ -> pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) /// Allocates a reference with value [x]. We have full permission on the newly /// allocated reference. val alloc_pt (#a:Type) (x:a) : Steel (ref a) emp (fun r -> pts_to r full_perm x) (requires fun _ -> True) (ensures fun _ r _ -> not (is_null r)) /// Reads the value in reference [r], as long as it initially is valid val read_pt (#a:Type) (#p:perm) (#v:erased a) (r:ref a) : Steel a (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) /// A variant of read, useful when an existentially quantified predicate /// depends on the value stored in the reference val read_refine_pt (#a:Type0) (#p:perm) (q:a -> vprop) (r:ref a) : SteelT a (h_exists (fun (v:a) -> pts_to r p v `star` q v)) (fun v -> pts_to r p v `star` q v) /// Writes value [x] in the reference [r], as long as we have full ownership of [r] val write_pt (#a:Type0) (#v:erased a) (r:ref a) (x:a) : SteelT unit (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) /// Frees reference [r], as long as we have full ownership of [r] val free_pt (#a:Type0) (#v:erased a) (r:ref a) : SteelT unit (pts_to r full_perm v) (fun _ -> emp) /// Splits the permission on reference [r] into two. /// This function is computationally irrelevant (it has effect SteelGhost) val share_gen_pt (#a:Type0) (#uses:_) (#p:perm) (#v: a) (r:ref a) (p1 p2: perm) : SteelGhost unit uses (pts_to r p v) (fun _ -> pts_to r p1 v `star` pts_to r p2 v) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val share_pt (#a:Type0) (#uses:_) (#p:perm) (#v:erased a) (r:ref a) : SteelGhostT unit uses (pts_to r p v) (fun _ -> pts_to r (half_perm p) v `star` pts_to r (half_perm p) v) /// Combines permissions on reference [r]. /// This function is computationally irrelevant (it has effect SteelGhost) val gather_pt (#a:Type0) (#uses:_) (#p0:perm) (#p1:perm) (#v0 #v1:erased a) (r:ref a) : SteelGhostT (_:unit{v0 == v1}) uses (pts_to r p0 v0 `star` pts_to r p1 v1) (fun _ -> pts_to r (sum_perm p0 p1) v0) /// Atomic operations, read, write, and cas /// /// These are not polymorphic and are allowed only for small types (e.g. word-sized) /// For now, exporting only for U32 val atomic_read_pt_u32 (#opened:_) (#p:perm) (#v:erased U32.t) (r:ref U32.t) : SteelAtomic U32.t opened (pts_to r p v) (fun x -> pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == Ghost.reveal v) val atomic_write_pt_u32 (#opened:_) (#v:erased U32.t) (r:ref U32.t) (x:U32.t) : SteelAtomicT unit opened (pts_to r full_perm v) (fun _ -> pts_to r full_perm x) val cas_pt_u32 (#uses:inames) (r:ref U32.t) (v:Ghost.erased U32.t) (v_old:U32.t) (v_new:U32.t) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) val cas_pt_bool (#uses:inames) (r:ref bool) (v:Ghost.erased bool) (v_old:bool) (v_new:bool) : SteelAtomicT (b:bool{b <==> (Ghost.reveal v == v_old)}) uses (pts_to r full_perm v) (fun b -> if b then pts_to r full_perm v_new else pts_to r full_perm v) (** Second version of references: The memory contents are available inside the selector, instead of as an index of the predicate **) /// An abstract separation logic predicate stating that reference [r] is valid in memory. val ptrp (#a:Type0) (r:ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ptr (#a:Type0) (r:ref a) : slprop u#1 = ptrp r full_perm /// A selector for references, returning the value of type [a] stored in memory val ptrp_sel (#a:Type0) (r:ref a) (p: perm) : selector a (ptrp r p) [@@ __steel_reduce__; __reduce__] unfold let ptr_sel (#a:Type0) (r:ref a) : selector a (ptr r) = ptrp_sel r full_perm /// Some lemmas to interoperate between the two versions of references val ptrp_sel_interp (#a:Type0) (r:ref a) (p: perm) (m:mem) : Lemma (requires interp (ptrp r p) m) (ensures interp (pts_to_sl r p (ptrp_sel r p m)) m) let ptr_sel_interp (#a:Type0) (r:ref a) (m:mem) : Lemma (requires interp (ptr r) m) (ensures interp (pts_to_sl r full_perm (ptr_sel r m)) m) = ptrp_sel_interp r full_perm m val intro_ptrp_interp (#a:Type0) (r:ref a) (p: perm) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r p v) m) (ensures interp (ptrp r p) m) let intro_ptr_interp (#a:Type0) (r:ref a) (v:erased a) (m:mem) : Lemma (requires interp (pts_to_sl r full_perm v) m) (ensures interp (ptr r) m) = intro_ptrp_interp r full_perm v m /// Combining the separation logic predicate and selector into a vprop [@@ __steel_reduce__] let vptr' #a r p : vprop' = {hp = ptrp r p; t = a; sel = ptrp_sel r p} [@@ __steel_reduce__] unfold let vptrp (#a: Type) (r: ref a) ([@@@smt_fallback] p: perm) = VUnit (vptr' r p) [@@ __steel_reduce__; __reduce__] unfold let vptr r = vptrp r full_perm /// A wrapper to access a reference selector more easily. /// Ensuring that the corresponding ptr vprop is in the context is done by /// calling a variant of the framing tactic, as defined in Steel.Effect.Common [@@ __steel_reduce__] let sel (#a:Type) (#p:vprop) (r:ref a) (h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (vptr r) /\ True)}) = h (vptr r) /// Moving from indexed pts_to assertions to selector-based vprops and back val intro_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) (v:erased a) : SteelGhost unit opened (pts_to r p v) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun _ _ h1 -> h1 (vptrp r p) == reveal v) val elim_vptr (#a:Type) (#opened:inames) (r:ref a) (p: perm) : SteelGhost (erased a) opened (vptrp r p) (fun v -> pts_to r p v) (requires fun _ -> True) (ensures fun h0 v _ -> reveal v == h0 (vptrp r p)) /// Allocates a reference with value [x]. val malloc (#a:Type0) (x:a) : Steel (ref a) emp (fun r -> vptr r) (requires fun _ -> True) (ensures fun _ r h1 -> sel r h1 == x /\ not (is_null r)) /// Frees a reference [r] val free (#a:Type0) (r:ref a) : Steel unit (vptr r) (fun _ -> emp) (requires fun _ -> True) (ensures fun _ _ _ -> True) /// Reads the current value of reference [r] val readp (#a:Type0) (r:ref a) (p: perm) : Steel a (vptrp r p) (fun _ -> vptrp r p) (requires fun _ -> True) (ensures fun h0 x h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ x == h1 (vptrp r p)) let read (#a:Type0) (r:ref a) : Steel a (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun h0 x h1 -> sel r h0 == sel r h1 /\ x == sel r h1) = readp r full_perm /// Writes value [x] in reference [r] val write (#a:Type0) (r:ref a) (x:a) : Steel unit (vptr r) (fun _ -> vptr r) (requires fun _ -> True) (ensures fun _ _ h1 -> x == sel r h1) val share (#a:Type0) (#uses:_) (#p: perm) (r:ref a) : SteelGhost unit uses (vptrp r p) (fun _ -> vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> True) (fun h _ h' -> h' (vptrp r (half_perm p)) == h (vptrp r p) ) val gather_gen (#a:Type0) (#uses:_) (r:ref a) (p0:perm) (p1:perm) : SteelGhost perm uses (vptrp r p0 `star` vptrp r p1) (fun res -> vptrp r res) (fun _ -> True) (fun h res h' -> res == sum_perm p0 p1 /\ h' (vptrp r res) == h (vptrp r p0) /\ h' (vptrp r res) == h (vptrp r p1) ) val gather (#a: Type0) (#uses: _) (#p: perm) (r: ref a) : SteelGhost unit uses (vptrp r (half_perm p) `star` vptrp r (half_perm p)) (fun _ -> vptrp r p) (fun _ -> True) (fun h _ h' -> h' (vptrp r p) == h (vptrp r (half_perm p)) ) /// A stateful lemma variant of the pts_to_not_null lemma above. /// This stateful function is computationally irrelevant and does not modify memory val vptrp_not_null (#opened: _) (#a: Type) (r: ref a) (p: perm) : SteelGhost unit opened (vptrp r p) (fun _ -> vptrp r p) (fun _ -> True) (fun h0 _ h1 -> h0 (vptrp r p) == h1 (vptrp r p) /\ is_null r == false ) let vptr_not_null (#opened: _) (#a: Type) (r: ref a) : SteelGhost unit opened (vptr r) (fun _ -> vptr r) (fun _ -> True) (fun h0 _ h1 -> sel r h0 == sel r h1 /\ is_null r == false ) = vptrp_not_null r full_perm (*** Ghost references ***) /// We also define a ghost variant of references, useful to do proofs relying on a ghost state /// Ghost references are marked as erasable, ensuring that they are computationally irrelevant, /// and only used in computationally irrelevant contexts. /// The functions below are variants of the reference functions defined above, /// but operating on ghost references, and with the computationally irrelevant SteelGhost effect [@@ erasable] val ghost_ref (a:Type u#0) : Type u#0 val dummy_ghost_ref (a: Type) : Tot (ghost_ref a) (* Textbook separation logic version of ghost references *) val ghost_pts_to_sl (#a:_) (r:ghost_ref a) (p:perm) (v:a) : slprop u#1 [@@ __steel_reduce__] let ghost_pts_to (#a:Type0) (r:ghost_ref a) ([@@@smt_fallback] p:perm) ([@@@ smt_fallback] v:a) : vprop = to_vprop (ghost_pts_to_sl r p v) val ghost_pts_to_witinv (#a:Type) (r:ghost_ref a) (p:perm) : Lemma (is_witness_invariant (ghost_pts_to_sl r p)) val ghost_alloc_pt (#a:Type) (#u:_) (x:erased a) : SteelGhostT (ghost_ref a) u emp (fun r -> ghost_pts_to r full_perm x) val ghost_free_pt (#a:Type0) (#u:_) (#v:erased a) (r:ghost_ref a) : SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> emp) val ghost_share_gen_pt (#a:Type) (#u:_) (#p:perm) (#x:erased a) (r:ghost_ref a) (p1 p2: perm) : SteelGhost unit u (ghost_pts_to r p x) (fun _ -> ghost_pts_to r p1 x `star` ghost_pts_to r p2 x) (fun _ -> p == p1 `sum_perm` p2) (fun _ _ _ -> True) val ghost_share_pt (#a:Type) (#u:_) (#p:perm) (#x:erased a) (r:ghost_ref a) : SteelGhostT unit u (ghost_pts_to r p x) (fun _ -> ghost_pts_to r (half_perm p) x `star` ghost_pts_to r (half_perm p) x) val ghost_gather_pt (#a:Type) (#u:_) (#p0 #p1:perm) (#x0 #x1:erased a) (r:ghost_ref a) : SteelGhost unit u (ghost_pts_to r p0 x0 `star` ghost_pts_to r p1 x1) (fun _ -> ghost_pts_to r (sum_perm p0 p1) x0) (requires fun _ -> true) (ensures fun _ _ _ -> x0 == x1) val ghost_pts_to_injective_eq (#a:_) (#u:_) (#p #q:_) (r:ghost_ref a) (v0 v1:Ghost.erased a) : SteelGhost unit u (ghost_pts_to r p v0 `star` ghost_pts_to r q v1) (fun _ -> ghost_pts_to r p v0 `star` ghost_pts_to r q v0) (requires fun _ -> True) (ensures fun _ _ _ -> v0 == v1) /// A permission is always no greater than one val ghost_pts_to_perm (#a: _) (#u: _) (#p: _) (#v: _) (r: ghost_ref a) : SteelGhost unit u (ghost_pts_to r p v) (fun _ -> ghost_pts_to r p v) (fun _ -> True) (fun _ _ _ -> p `lesser_equal_perm` full_perm) val ghost_read_pt (#a:Type) (#u:_) (#p:perm) (#v:erased a) (r:ghost_ref a) : SteelGhost (erased a) u (ghost_pts_to r p v) (fun x -> ghost_pts_to r p x) (requires fun _ -> True) (ensures fun _ x _ -> x == v) val ghost_write_pt (#a:Type) (#u:_) (#v:erased a) (r:ghost_ref a) (x:erased a) : SteelGhostT unit u (ghost_pts_to r full_perm v) (fun _ -> ghost_pts_to r full_perm x) (* Selector version of ghost references *) val ghost_ptrp (#a: Type0) (r: ghost_ref a) ([@@@smt_fallback] p: perm) : slprop u#1 [@@ __steel_reduce__; __reduce__] unfold let ghost_ptr (#a: Type0) (r: ghost_ref a) : slprop u#1 = ghost_ptrp r full_perm val ghost_ptrp_sel (#a:Type0) (r:ghost_ref a) (p: perm) : selector a (ghost_ptrp r p) [@@ __steel_reduce__; __reduce__] let ghost_ptr_sel (#a:Type0) (r:ghost_ref a) : selector a (ghost_ptr r) = ghost_ptrp_sel r full_perm val ghost_ptrp_sel_interp (#a:Type0) (r:ghost_ref a) (p: perm) (m:mem) : Lemma (requires interp (ghost_ptrp r p) m) (ensures interp (ghost_pts_to_sl r p (ghost_ptrp_sel r p m)) m)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.Reference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Steel.Reference.ghost_ref a -> m: Steel.Memory.mem -> FStar.Pervasives.Lemma (requires Steel.Memory.interp (Steel.Reference.ghost_ptr r) m) (ensures Steel.Memory.interp (Steel.Reference.ghost_pts_to_sl r Steel.FractionalPermission.full_perm (Steel.Reference.ghost_ptr_sel r m)) m)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Steel.Reference.ghost_ref", "Steel.Memory.mem", "Steel.Reference.ghost_ptrp_sel_interp", "Steel.FractionalPermission.full_perm", "Prims.unit", "Steel.Memory.interp", "Steel.Reference.ghost_ptr", "Prims.squash", "Steel.Reference.ghost_pts_to_sl", "Steel.Reference.ghost_ptr_sel", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let ghost_ptr_sel_interp (#a: Type0) (r: ghost_ref a) (m: mem) : Lemma (requires interp (ghost_ptr r) m) (ensures interp (ghost_pts_to_sl r full_perm (ghost_ptr_sel r m)) m) =
ghost_ptrp_sel_interp r full_perm m
false
Benton2004.Aux.fst
Benton2004.Aux.holds
val holds (#t: Type0) (p: rel t) (s s' : t) : GTot Type0
val holds (#t: Type0) (p: rel t) (s s' : t) : GTot Type0
let holds (#t: Type0) (p: rel t) (s s' : t) : GTot Type0 = p s s'
{ "file_name": "examples/rel/Benton2004.Aux.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 8, "end_line": 19, "start_col": 0, "start_line": 18 }
(* Copyright 2008-2018 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 Benton2004.Aux
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Benton2004.Aux.fst" }
[ { "abbrev": false, "full_module": "Benton2004", "short_module": null }, { "abbrev": false, "full_module": "Benton2004", "short_module": null }, { "abbrev": 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
p: Benton2004.Aux.rel t -> s: t -> s': t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Benton2004.Aux.rel" ]
[]
false
false
false
false
true
let holds (#t: Type0) (p: rel t) (s s': t) : GTot Type0 =
p s s'
false