val log_entry_hdr_serializer: LP.serializer log_entry_hdr_parser
val log_entry_hdr_serializer: LP.serializer log_entry_hdr_parser
let log_entry_hdr_serializer =
  assert_norm (LP.parse_sum_kind (LP.get_parser_kind log_entry_kind_repr_parser) log_entry_hdr_sum parse_log_entry_hdr_cases == log_entry_hdr_parser_kind);
  LP.serialize_sum log_entry_hdr_sum log_entry_kind_repr_serializer serialize_log_entry_hdr_cases
module Zeta.Formats.Aux.Log_entry_hdr

(* This file has been automatically generated by EverParse. *)
open FStar.Bytes
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module LP = LowParse.Spec
module LT = LowParse.TacLib
module LSZ = LowParse.SLow
module LPI = LowParse.Spec.AllIntegers
module LL = LowParse.Low
module L = FStar.List.Tot
module B = LowStar.Buffer
module BY = FStar.Bytes
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST

#reset-options "--using_facts_from '* -FStar.Tactics -FStar.Reflection' --z3rlimit 16 --z3cliopt smt.arith.nl=false --max_fuel 2 --max_ifuel 2"

friend Zeta.Formats.Aux.Log_entry_kind

// Need high Z3 limits for large sum types
#set-options "--z3rlimit 480"

inline_for_extraction unfold let log_entry_kind_as_enum_key (x:log_entry_kind) : Pure (LP.enum_key log_entry_kind_enum)
  (requires norm [delta; zeta; iota; primops] (LP.list_mem x (LP.list_map fst log_entry_kind_enum)) == true) (ensures fun _ -> True) =
  [@inline_let] let _ = norm_spec [delta; zeta; iota; primops] (LP.list_mem x (LP.list_map fst log_entry_kind_enum)) in x

inline_for_extraction let key_of_log_entry_hdr (x:log_entry_hdr) : LP.enum_key log_entry_kind_enum =
  match x with
  | Le_payload_AddM _ -> log_entry_kind_as_enum_key AddM
  | Le_payload_AddB _ -> log_entry_kind_as_enum_key AddB
  | Le_payload_EvictM _ -> log_entry_kind_as_enum_key EvictM
  | Le_payload_EvictB _ -> log_entry_kind_as_enum_key EvictB
  | Le_payload_EvictBM _ -> log_entry_kind_as_enum_key EvictBM
  | Le_payload_NextEpoch _ -> log_entry_kind_as_enum_key NextEpoch
  | Le_payload_VerifyEpoch _ -> log_entry_kind_as_enum_key VerifyEpoch
  | Le_payload_RunApp _ -> log_entry_kind_as_enum_key RunApp

inline_for_extraction let log_entry_hdr_case_of_log_entry_kind (x:log_entry_kind) : Type0 =
  match x with
  | AddM -> addm_payload
  | AddB -> addb_payload
  | EvictM -> evictm_payload
  | EvictB -> evictb_payload
  | EvictBM -> evictbm_payload
  | NextEpoch -> unit
  | VerifyEpoch -> unit
  | RunApp -> runapp_payload_hdr

unfold inline_for_extraction let to_log_entry_hdr_case_of_log_entry_kind (x:log_entry_kind) (#x':log_entry_kind) (y:log_entry_hdr_case_of_log_entry_kind x')  : Pure (norm [delta_only [(`%log_entry_hdr_case_of_log_entry_kind)]; iota] (log_entry_hdr_case_of_log_entry_kind x))
  (requires (x == x')) (ensures (fun y' -> y' == y)) =
  [@inline_let] let _ = norm_spec [delta_only [(`%log_entry_hdr_case_of_log_entry_kind)] ; iota] (log_entry_hdr_case_of_log_entry_kind x) in y

unfold inline_for_extraction let log_entry_hdr_refine (k:LP.enum_key log_entry_kind_enum) (x:log_entry_hdr)
  : Pure (LP.refine_with_tag key_of_log_entry_hdr k)  (requires norm [delta; iota; zeta] (key_of_log_entry_hdr x) == k) (ensures (fun y -> y == x)) =
  [@inline_let] let _ = norm_spec [delta; iota; zeta] (key_of_log_entry_hdr x) in x

inline_for_extraction let synth_log_entry_hdr_cases (x:LP.enum_key log_entry_kind_enum) (y:log_entry_hdr_case_of_log_entry_kind x)
  : LP.refine_with_tag key_of_log_entry_hdr x =
  match x with
  | AddM -> log_entry_hdr_refine x (Le_payload_AddM (to_log_entry_hdr_case_of_log_entry_kind AddM y))
  | AddB -> log_entry_hdr_refine x (Le_payload_AddB (to_log_entry_hdr_case_of_log_entry_kind AddB y))
  | EvictM -> log_entry_hdr_refine x (Le_payload_EvictM (to_log_entry_hdr_case_of_log_entry_kind EvictM y))
  | EvictB -> log_entry_hdr_refine x (Le_payload_EvictB (to_log_entry_hdr_case_of_log_entry_kind EvictB y))
  | EvictBM -> log_entry_hdr_refine x (Le_payload_EvictBM (to_log_entry_hdr_case_of_log_entry_kind EvictBM y))
  | NextEpoch -> log_entry_hdr_refine x (Le_payload_NextEpoch (to_log_entry_hdr_case_of_log_entry_kind NextEpoch y))
  | VerifyEpoch -> log_entry_hdr_refine x (Le_payload_VerifyEpoch (to_log_entry_hdr_case_of_log_entry_kind VerifyEpoch y))
  | RunApp -> log_entry_hdr_refine x (Le_payload_RunApp (to_log_entry_hdr_case_of_log_entry_kind RunApp y))

unfold inline_for_extraction let from_log_entry_hdr_case_of_log_entry_kind (#x':log_entry_kind) (x:log_entry_kind)
  (y: norm [delta_only [(`%log_entry_hdr_case_of_log_entry_kind)]; iota] (log_entry_hdr_case_of_log_entry_kind x))
  : Pure (log_entry_hdr_case_of_log_entry_kind x') (requires (x == x')) (ensures (fun y' -> y' == y)) =
  [@inline_let] let _ = norm_spec [delta_only [(`%log_entry_hdr_case_of_log_entry_kind)] ; iota] (log_entry_hdr_case_of_log_entry_kind x) in y

let synth_log_entry_hdr_cases_recip_pre (k:LP.enum_key log_entry_kind_enum)
  (x:LP.refine_with_tag key_of_log_entry_hdr k) : GTot bool =
  match k with
  | AddM -> Le_payload_AddM? x
  | AddB -> Le_payload_AddB? x
  | EvictM -> Le_payload_EvictM? x
  | EvictB -> Le_payload_EvictB? x
  | EvictBM -> Le_payload_EvictBM? x
  | NextEpoch -> Le_payload_NextEpoch? x
  | VerifyEpoch -> Le_payload_VerifyEpoch? x
  | RunApp -> Le_payload_RunApp? x

let synth_log_entry_hdr_cases_recip_pre_intro (k:LP.enum_key log_entry_kind_enum) (x:LP.refine_with_tag key_of_log_entry_hdr k)
  : Lemma (synth_log_entry_hdr_cases_recip_pre k x == true) =
  norm_spec [delta; iota] (synth_log_entry_hdr_cases_recip_pre k x)

inline_for_extraction let synth_log_entry_hdr_cases_recip (k:LP.enum_key log_entry_kind_enum)
  (x:LP.refine_with_tag key_of_log_entry_hdr k) : (log_entry_hdr_case_of_log_entry_kind k) =
  match k with
  | AddM -> [@inline_let] let _ = synth_log_entry_hdr_cases_recip_pre_intro AddM x in
    (match x with Le_payload_AddM y -> (from_log_entry_hdr_case_of_log_entry_kind AddM y))
  | AddB -> [@inline_let] let _ = synth_log_entry_hdr_cases_recip_pre_intro AddB x in
    (match x with Le_payload_AddB y -> (from_log_entry_hdr_case_of_log_entry_kind AddB y))
  | EvictM -> [@inline_let] let _ = synth_log_entry_hdr_cases_recip_pre_intro EvictM x in
    (match x with Le_payload_EvictM y -> (from_log_entry_hdr_case_of_log_entry_kind EvictM y))
  | EvictB -> [@inline_let] let _ = synth_log_entry_hdr_cases_recip_pre_intro EvictB x in
    (match x with Le_payload_EvictB y -> (from_log_entry_hdr_case_of_log_entry_kind EvictB y))
  | EvictBM -> [@inline_let] let _ = synth_log_entry_hdr_cases_recip_pre_intro EvictBM x in
    (match x with Le_payload_EvictBM y -> (from_log_entry_hdr_case_of_log_entry_kind EvictBM y))
  | NextEpoch -> [@inline_let] let _ = synth_log_entry_hdr_cases_recip_pre_intro NextEpoch x in
    (match x with Le_payload_NextEpoch y -> (from_log_entry_hdr_case_of_log_entry_kind NextEpoch y))
  | VerifyEpoch -> [@inline_let] let _ = synth_log_entry_hdr_cases_recip_pre_intro VerifyEpoch x in
    (match x with Le_payload_VerifyEpoch y -> (from_log_entry_hdr_case_of_log_entry_kind VerifyEpoch y))
  | RunApp -> [@inline_let] let _ = synth_log_entry_hdr_cases_recip_pre_intro RunApp x in
    (match x with Le_payload_RunApp y -> (from_log_entry_hdr_case_of_log_entry_kind RunApp y))

inline_for_extraction let log_entry_hdr_sum = LP.make_sum' log_entry_kind_enum key_of_log_entry_hdr
  log_entry_hdr_case_of_log_entry_kind synth_log_entry_hdr_cases synth_log_entry_hdr_cases_recip
  (_ by (LP.make_sum_synth_case_recip_synth_case_tac ()))
  (_ by (LP.synth_case_synth_case_recip_tac ()))

noextract let parse_log_entry_hdr_cases (x:LP.sum_key log_entry_hdr_sum)
  : k:LP.parser_kind & LP.parser k (log_entry_hdr_case_of_log_entry_kind x) =
  match x with
  | AddM -> [@inline_let] let u : (k: LP.parser_kind & LP.parser k (log_entry_hdr_case_of_log_entry_kind AddM)) = (| _, addm_payload_parser |) in u
  | AddB -> [@inline_let] let u : (k: LP.parser_kind & LP.parser k (log_entry_hdr_case_of_log_entry_kind AddB)) = (| _, addb_payload_parser |) in u
  | EvictM -> [@inline_let] let u : (k: LP.parser_kind & LP.parser k (log_entry_hdr_case_of_log_entry_kind EvictM)) = (| _, evictm_payload_parser |) in u
  | EvictB -> [@inline_let] let u : (k: LP.parser_kind & LP.parser k (log_entry_hdr_case_of_log_entry_kind EvictB)) = (| _, evictb_payload_parser |) in u
  | EvictBM -> [@inline_let] let u : (k: LP.parser_kind & LP.parser k (log_entry_hdr_case_of_log_entry_kind EvictBM)) = (| _, evictbm_payload_parser |) in u
  | NextEpoch -> [@inline_let] let u : (k: LP.parser_kind & LP.parser k (log_entry_hdr_case_of_log_entry_kind NextEpoch)) = (| _, LP.parse_empty |) in u
  | VerifyEpoch -> [@inline_let] let u : (k: LP.parser_kind & LP.parser k (log_entry_hdr_case_of_log_entry_kind VerifyEpoch)) = (| _, LP.parse_empty |) in u
  | RunApp -> [@inline_let] let u : (k: LP.parser_kind & LP.parser k (log_entry_hdr_case_of_log_entry_kind RunApp)) = (| _, runapp_payload_hdr_parser |) in u
  | _ -> (| _, LP.parse_false |)

noextract let serialize_log_entry_hdr_cases (x:LP.sum_key log_entry_hdr_sum)
  : LP.serializer (dsnd (parse_log_entry_hdr_cases x)) =
  match x with
  | AddM -> [@inline_let] let u : LP.serializer (dsnd (parse_log_entry_hdr_cases AddM)) = addm_payload_serializer in u
  | AddB -> [@inline_let] let u : LP.serializer (dsnd (parse_log_entry_hdr_cases AddB)) = addb_payload_serializer in u
  | EvictM -> [@inline_let] let u : LP.serializer (dsnd (parse_log_entry_hdr_cases EvictM)) = evictm_payload_serializer in u
  | EvictB -> [@inline_let] let u : LP.serializer (dsnd (parse_log_entry_hdr_cases EvictB)) = evictb_payload_serializer in u
  | EvictBM -> [@inline_let] let u : LP.serializer (dsnd (parse_log_entry_hdr_cases EvictBM)) = evictbm_payload_serializer in u
  | NextEpoch -> [@inline_let] let u : LP.serializer (dsnd (parse_log_entry_hdr_cases NextEpoch)) = LP.serialize_empty in u
  | VerifyEpoch -> [@inline_let] let u : LP.serializer (dsnd (parse_log_entry_hdr_cases VerifyEpoch)) = LP.serialize_empty in u
  | RunApp -> [@inline_let] let u : LP.serializer (dsnd (parse_log_entry_hdr_cases RunApp)) = runapp_payload_hdr_serializer in u
  | _ -> LP.serialize_false

inline_for_extraction noextract let size32_log_entry_hdr_cases (x:LP.sum_key log_entry_hdr_sum)
  : LSZ.size32 (serialize_log_entry_hdr_cases x) =
  match x with
  | AddM -> [@inline_let] let u : LSZ.size32 (serialize_log_entry_hdr_cases AddM) = addm_payload_size32 in u
  | AddB -> [@inline_let] let u : LSZ.size32 (serialize_log_entry_hdr_cases AddB) = addb_payload_size32 in u
  | EvictM -> [@inline_let] let u : LSZ.size32 (serialize_log_entry_hdr_cases EvictM) = evictm_payload_size32 in u
  | EvictB -> [@inline_let] let u : LSZ.size32 (serialize_log_entry_hdr_cases EvictB) = evictb_payload_size32 in u
  | EvictBM -> [@inline_let] let u : LSZ.size32 (serialize_log_entry_hdr_cases EvictBM) = evictbm_payload_size32 in u
  | NextEpoch -> [@inline_let] let u : LSZ.size32 (serialize_log_entry_hdr_cases NextEpoch) = LSZ.size32_empty in u
  | VerifyEpoch -> [@inline_let] let u : LSZ.size32 (serialize_log_entry_hdr_cases VerifyEpoch) = LSZ.size32_empty in u
  | RunApp -> [@inline_let] let u : LSZ.size32 (serialize_log_entry_hdr_cases RunApp) = runapp_payload_hdr_size32 in u
  | _ -> LSZ.size32_false

inline_for_extraction noextract let validate_log_entry_hdr_cases (x:LP.sum_key log_entry_hdr_sum)
  : LL.validator (dsnd (parse_log_entry_hdr_cases x)) =
  match x with
  | AddM -> [@inline_let] let u : LL.validator (dsnd (parse_log_entry_hdr_cases AddM)) = addm_payload_validator in u
  | AddB -> [@inline_let] let u : LL.validator (dsnd (parse_log_entry_hdr_cases AddB)) = addb_payload_validator in u
  | EvictM -> [@inline_let] let u : LL.validator (dsnd (parse_log_entry_hdr_cases EvictM)) = evictm_payload_validator in u
  | EvictB -> [@inline_let] let u : LL.validator (dsnd (parse_log_entry_hdr_cases EvictB)) = evictb_payload_validator in u
  | EvictBM -> [@inline_let] let u : LL.validator (dsnd (parse_log_entry_hdr_cases EvictBM)) = evictbm_payload_validator in u
  | NextEpoch -> [@inline_let] let u : LL.validator (dsnd (parse_log_entry_hdr_cases NextEpoch)) = (LL.validate_empty ()) in u
  | VerifyEpoch -> [@inline_let] let u : LL.validator (dsnd (parse_log_entry_hdr_cases VerifyEpoch)) = (LL.validate_empty ()) in u
  | RunApp -> [@inline_let] let u : LL.validator (dsnd (parse_log_entry_hdr_cases RunApp)) = runapp_payload_hdr_validator in u
  | _ -> LL.validate_false ()

inline_for_extraction noextract let jump_log_entry_hdr_cases (x:LP.sum_key log_entry_hdr_sum)
  : LL.jumper (dsnd (parse_log_entry_hdr_cases x)) =
  match x with
  | AddM -> [@inline_let] let u : LL.jumper (dsnd (parse_log_entry_hdr_cases AddM)) = addm_payload_jumper in u
  | AddB -> [@inline_let] let u : LL.jumper (dsnd (parse_log_entry_hdr_cases AddB)) = addb_payload_jumper in u
  | EvictM -> [@inline_let] let u : LL.jumper (dsnd (parse_log_entry_hdr_cases EvictM)) = evictm_payload_jumper in u
  | EvictB -> [@inline_let] let u : LL.jumper (dsnd (parse_log_entry_hdr_cases EvictB)) = evictb_payload_jumper in u
  | EvictBM -> [@inline_let] let u : LL.jumper (dsnd (parse_log_entry_hdr_cases EvictBM)) = evictbm_payload_jumper in u
  | NextEpoch -> [@inline_let] let u : LL.jumper (dsnd (parse_log_entry_hdr_cases NextEpoch)) = LL.jump_empty in u
  | VerifyEpoch -> [@inline_let] let u : LL.jumper (dsnd (parse_log_entry_hdr_cases VerifyEpoch)) = LL.jump_empty in u
  | RunApp -> [@inline_let] let u : LL.jumper (dsnd (parse_log_entry_hdr_cases RunApp)) = runapp_payload_hdr_jumper in u
  | _ -> LL.jump_false

inline_for_extraction noextract let read_log_entry_hdr_cases (x:LP.sum_key log_entry_hdr_sum)
  : LL.leaf_reader (dsnd (parse_log_entry_hdr_cases x)) =
  match x with
  | AddM -> [@inline_let] let u : LL.leaf_reader (dsnd (parse_log_entry_hdr_cases AddM)) = addm_payload_reader in u
  | AddB -> [@inline_let] let u : LL.leaf_reader (dsnd (parse_log_entry_hdr_cases AddB)) = addb_payload_reader in u
  | EvictM -> [@inline_let] let u : LL.leaf_reader (dsnd (parse_log_entry_hdr_cases EvictM)) = evictm_payload_reader in u
  | EvictB -> [@inline_let] let u : LL.leaf_reader (dsnd (parse_log_entry_hdr_cases EvictB)) = evictb_payload_reader in u
  | EvictBM -> [@inline_let] let u : LL.leaf_reader (dsnd (parse_log_entry_hdr_cases EvictBM)) = evictbm_payload_reader in u
  | NextEpoch -> [@inline_let] let u : LL.leaf_reader (dsnd (parse_log_entry_hdr_cases NextEpoch)) = LL.read_empty in u
  | VerifyEpoch -> [@inline_let] let u : LL.leaf_reader (dsnd (parse_log_entry_hdr_cases VerifyEpoch)) = LL.read_empty in u
  | RunApp -> [@inline_let] let u : LL.leaf_reader (dsnd (parse_log_entry_hdr_cases RunApp)) = runapp_payload_hdr_reader in u
  | _ -> LL.read_false

inline_for_extraction noextract let lserialize_log_entry_hdr_cases (x:LP.sum_key log_entry_hdr_sum)
  : LL.serializer32 (serialize_log_entry_hdr_cases x) =
  match x with
  | AddM -> [@inline_let] let u : LL.serializer32 (serialize_log_entry_hdr_cases AddM) = addm_payload_lserializer in u
  | AddB -> [@inline_let] let u : LL.serializer32 (serialize_log_entry_hdr_cases AddB) = addb_payload_lserializer in u
  | EvictM -> [@inline_let] let u : LL.serializer32 (serialize_log_entry_hdr_cases EvictM) = evictm_payload_lserializer in u
  | EvictB -> [@inline_let] let u : LL.serializer32 (serialize_log_entry_hdr_cases EvictB) = evictb_payload_lserializer in u
  | EvictBM -> [@inline_let] let u : LL.serializer32 (serialize_log_entry_hdr_cases EvictBM) = evictbm_payload_lserializer in u
  | NextEpoch -> [@inline_let] let u : LL.serializer32 (serialize_log_entry_hdr_cases NextEpoch) = LL.serialize32_empty in u
  | VerifyEpoch -> [@inline_let] let u : LL.serializer32 (serialize_log_entry_hdr_cases VerifyEpoch) = LL.serialize32_empty in u
  | RunApp -> [@inline_let] let u : LL.serializer32 (serialize_log_entry_hdr_cases RunApp) = runapp_payload_hdr_lserializer in u
  | _ -> LL.serialize32_false

let log_entry_hdr_parser =
  assert_norm (LP.parse_sum_kind (LP.get_parser_kind log_entry_kind_repr_parser) log_entry_hdr_sum parse_log_entry_hdr_cases == log_entry_hdr_parser_kind);
  LP.parse_sum log_entry_hdr_sum log_entry_kind_repr_parser parse_log_entry_hdr_cases
/
Zeta.Formats.Aux.Log_entry_kind.fst.checked prims.fst.checked LowStar.Buffer.fst.checked LowParse.TacLib.fst.checked LowParse.Spec.AllIntegers.fst.checked LowParse.Spec.fst.checked LowParse.SLow.fst.checked LowParse.Low.fst.checked FStar.UInt8.fsti.checked FStar.UInt64.fsti.checked FStar.UInt32.fsti.checked FStar.UInt16.fsti.checked FStar.Tactics.Effect.fsti.checked FStar.Seq.fst.checked FStar.Pervasives.fsti.checked FStar.List.Tot.fst.checked FStar.HyperStack.ST.fsti.checked FStar.HyperStack.fst.checked FStar.Bytes.fsti.checked
Zeta.Formats.Aux.Log_entry_hdr.fst
LowParse.Spec.Base.serializer Zeta.Formats.Aux.Log_entry_hdr.log_entry_hdr_parser
LowParse.Spec.Sum.serialize_sum LowParse.Spec.Int.parse_u8_kind Zeta.Formats.Aux.Log_entry_hdr.log_entry_hdr_sum LowParse.Spec.Int.parse_u8 Zeta.Formats.Aux.Log_entry_kind.log_entry_kind_repr_serializer Zeta.Formats.Aux.Log_entry_hdr.parse_log_entry_hdr_cases Zeta.Formats.Aux.Log_entry_hdr.serialize_log_entry_hdr_cases Prims.unit FStar.Pervasives.assert_norm Prims.eq2 LowParse.Spec.Base.parser_kind LowParse.Spec.Sum.parse_sum_kind LowParse.Spec.Base.get_parser_kind FStar.UInt8.t Zeta.Formats.Aux.Log_entry_kind.log_entry_kind_repr_parser Zeta.Formats.Aux.Log_entry_hdr.log_entry_hdr_parser_kind
let log_entry_hdr_serializer =
  
assert_norm (LP.parse_sum_kind (LP.get_parser_kind log_entry_kind_repr_parser)
      log_entry_hdr_sum
      parse_log_entry_hdr_cases ==
    log_entry_hdr_parser_kind);
LP.serialize_sum log_entry_hdr_sum log_entry_kind_repr_serializer serialize_log_entry_hdr_cases