val ticketContents_clens'_ticket12:LL.clens ticketContents ticketContents12
val ticketContents_clens'_ticket12:LL.clens ticketContents ticketContents12
let ticketContents_clens'_ticket12 : LL.clens ticketContents ticketContents12 = LL.clens_sum_payload ticketContents_sum (ticketVersion_as_enum_key Ticket12)
module MiTLS.Parsers.TicketContents

(* 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 LS = LowParse.SLow
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 MiTLS.Parsers.TicketVersion

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

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

inline_for_extraction let key_of_ticketContents (x:ticketContents) : LP.enum_key ticketVersion_enum =
  match x with
  | T_ticket12 _ -> ticketVersion_as_enum_key Ticket12
  | T_ticket13 _ -> ticketVersion_as_enum_key Ticket13

inline_for_extraction let ticketContents_case_of_ticketVersion (x:ticketVersion) : Type0 =
  match x with
  | Ticket12 -> ticketContents12
  | Ticket13 -> ticketContents13

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

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

inline_for_extraction let synth_ticketContents_cases (x:LP.enum_key ticketVersion_enum) (y:ticketContents_case_of_ticketVersion x)
  : LP.refine_with_tag key_of_ticketContents x =
  match x with
  | Ticket12 -> ticketContents_refine x (T_ticket12 (to_ticketContents_case_of_ticketVersion Ticket12 y))
  | Ticket13 -> ticketContents_refine x (T_ticket13 (to_ticketContents_case_of_ticketVersion Ticket13 y))

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

let synth_ticketContents_cases_recip_pre (k:LP.enum_key ticketVersion_enum)
  (x:LP.refine_with_tag key_of_ticketContents k) : GTot bool =
  match k with
  | Ticket12 -> T_ticket12? x
  | Ticket13 -> T_ticket13? x

let synth_ticketContents_cases_recip_pre_intro (k:LP.enum_key ticketVersion_enum) (x:LP.refine_with_tag key_of_ticketContents k)
  : Lemma (synth_ticketContents_cases_recip_pre k x == true) =
  norm_spec [delta; iota] (synth_ticketContents_cases_recip_pre k x)

inline_for_extraction let synth_ticketContents_cases_recip (k:LP.enum_key ticketVersion_enum)
  (x:LP.refine_with_tag key_of_ticketContents k) : (ticketContents_case_of_ticketVersion k) =
  match k with
  | Ticket12 -> [@inline_let] let _ = synth_ticketContents_cases_recip_pre_intro Ticket12 x in
    (match x with T_ticket12 y -> (from_ticketContents_case_of_ticketVersion Ticket12 y))
  | Ticket13 -> [@inline_let] let _ = synth_ticketContents_cases_recip_pre_intro Ticket13 x in
    (match x with T_ticket13 y -> (from_ticketContents_case_of_ticketVersion Ticket13 y))

inline_for_extraction let ticketContents_sum = LP.make_sum' ticketVersion_enum key_of_ticketContents
  ticketContents_case_of_ticketVersion synth_ticketContents_cases synth_ticketContents_cases_recip
  (_ by (LP.make_sum_synth_case_recip_synth_case_tac ()))
  (_ by (LP.synth_case_synth_case_recip_tac ()))

noextract let parse_ticketContents_cases (x:LP.sum_key ticketContents_sum)
  : k:LP.parser_kind & LP.parser k (ticketContents_case_of_ticketVersion x) =
  match x with
  | Ticket12 -> [@inline_let] let u : (k: LP.parser_kind & LP.parser k (ticketContents_case_of_ticketVersion Ticket12)) = (| _, ticketContents12_parser |) in u
  | Ticket13 -> [@inline_let] let u : (k: LP.parser_kind & LP.parser k (ticketContents_case_of_ticketVersion Ticket13)) = (| _, ticketContents13_parser |) in u
  | _ -> (| _, LP.parse_false |)

noextract let serialize_ticketContents_cases (x:LP.sum_key ticketContents_sum)
  : LP.serializer (dsnd (parse_ticketContents_cases x)) =
  match x with
  | Ticket12 -> [@inline_let] let u : LP.serializer (dsnd (parse_ticketContents_cases Ticket12)) = ticketContents12_serializer in u
  | Ticket13 -> [@inline_let] let u : LP.serializer (dsnd (parse_ticketContents_cases Ticket13)) = ticketContents13_serializer in u
  | _ -> LP.serialize_false

inline_for_extraction noextract let parse32_ticketContents_cases (x:LP.sum_key ticketContents_sum)
  : LS.parser32 (dsnd (parse_ticketContents_cases x)) =
  match x with
  | Ticket12 -> [@inline_let] let u : LS.parser32 (dsnd (parse_ticketContents_cases Ticket12)) = ticketContents12_parser32 in u
  | Ticket13 -> [@inline_let] let u : LS.parser32 (dsnd (parse_ticketContents_cases Ticket13)) = ticketContents13_parser32 in u
  | _ -> LS.parse32_false

inline_for_extraction noextract let serialize32_ticketContents_cases (x:LP.sum_key ticketContents_sum)
  : LS.serializer32 (serialize_ticketContents_cases x) =
  match x with
  | Ticket12 -> [@inline_let] let u : LS.serializer32 (serialize_ticketContents_cases Ticket12) = ticketContents12_serializer32 in u
  | Ticket13 -> [@inline_let] let u : LS.serializer32 (serialize_ticketContents_cases Ticket13) = ticketContents13_serializer32 in u
  | _ -> LS.serialize32_false

inline_for_extraction noextract let size32_ticketContents_cases (x:LP.sum_key ticketContents_sum)
  : LSZ.size32 (serialize_ticketContents_cases x) =
  match x with
  | Ticket12 -> [@inline_let] let u : LSZ.size32 (serialize_ticketContents_cases Ticket12) = ticketContents12_size32 in u
  | Ticket13 -> [@inline_let] let u : LSZ.size32 (serialize_ticketContents_cases Ticket13) = ticketContents13_size32 in u
  | _ -> LSZ.size32_false

inline_for_extraction noextract let validate_ticketContents_cases (x:LP.sum_key ticketContents_sum)
  : LL.validator (dsnd (parse_ticketContents_cases x)) =
  match x with
  | Ticket12 -> [@inline_let] let u : LL.validator (dsnd (parse_ticketContents_cases Ticket12)) = ticketContents12_validator in u
  | Ticket13 -> [@inline_let] let u : LL.validator (dsnd (parse_ticketContents_cases Ticket13)) = ticketContents13_validator in u
  | _ -> LL.validate_false ()

inline_for_extraction noextract let jump_ticketContents_cases (x:LP.sum_key ticketContents_sum)
  : LL.jumper (dsnd (parse_ticketContents_cases x)) =
  match x with
  | Ticket12 -> [@inline_let] let u : LL.jumper (dsnd (parse_ticketContents_cases Ticket12)) = ticketContents12_jumper in u
  | Ticket13 -> [@inline_let] let u : LL.jumper (dsnd (parse_ticketContents_cases Ticket13)) = ticketContents13_jumper in u
  | _ -> LL.jump_false

let ticketContents_parser =
  assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);
  LP.parse_sum ticketContents_sum ticketVersion_repr_parser parse_ticketContents_cases

let ticketContents_serializer =
  assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);
  LP.serialize_sum ticketContents_sum ticketVersion_repr_serializer serialize_ticketContents_cases

let ticketContents_bytesize (x:ticketContents) : GTot nat = Seq.length (ticketContents_serializer x)

let ticketContents_bytesize_eq x = ()

let ticketContents_parser32 =
  assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);
  LS.parse32_sum2 ticketContents_sum ticketVersion_repr_parser ticketVersion_repr_parser32 parse_ticketContents_cases parse32_ticketContents_cases (_ by (LP.enum_destr_tac ticketVersion_enum)) (_ by (LP.maybe_enum_key_of_repr_tac ticketVersion_enum))

let ticketContents_serializer32 =
  assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);
  assert_norm (LS.serializer32_sum_gen_precond (LP.get_parser_kind ticketVersion_repr_parser) (LP.weaken_parse_cases_kind ticketContents_sum parse_ticketContents_cases));
  LS.serialize32_sum2 ticketContents_sum ticketVersion_repr_serializer ticketVersion_repr_serializer32 serialize_ticketContents_cases serialize32_ticketContents_cases (_ by (LP.dep_enum_destr_tac ())) (_ by (LP.enum_repr_of_key_tac ticketVersion_enum)) ()

let ticketContents_size32 =
  assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);
  assert_norm (LSZ.size32_sum_gen_precond (LP.get_parser_kind ticketVersion_repr_parser) (LP.weaken_parse_cases_kind ticketContents_sum parse_ticketContents_cases));
  LSZ.size32_sum2 ticketContents_sum ticketVersion_repr_serializer ticketVersion_repr_size32 serialize_ticketContents_cases size32_ticketContents_cases (_ by (LP.dep_enum_destr_tac ())) (_ by (LP.enum_repr_of_key_tac ticketVersion_enum)) ()

let ticketContents_validator =
  assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);
  LL.validate_sum ticketContents_sum ticketVersion_repr_validator ticketVersion_repr_reader parse_ticketContents_cases validate_ticketContents_cases (_ by (LP.dep_maybe_enum_destr_t_tac ()))

let ticketContents_jumper =
  assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);
  LL.jump_sum ticketContents_sum ticketVersion_repr_jumper ticketVersion_repr_reader parse_ticketContents_cases jump_ticketContents_cases (_ by (LP.dep_maybe_enum_destr_t_tac ()))

let lemma_valid_ticketContents_valid_ticketVersion #_ #_ s pos h =
  assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);
  LL.valid_sum_elim_tag h ticketContents_sum ticketVersion_repr_parser parse_ticketContents_cases s pos;
  lemma_synth_ticketVersion_inj ();
  LL.valid_synth h parse_ticketVersion_key synth_ticketVersion s pos

let ticketContents_gaccessor_tag =
  assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);
  lemma_synth_ticketVersion_inj ();
  lemma_synth_ticketVersion_inv ();
  LL.gaccessor_ext
    (LL.gaccessor_compose
      (LL.gaccessor_sum_tag ticketContents_sum ticketVersion_repr_parser parse_ticketContents_cases)
      (LL.gaccessor_synth_inv parse_ticketVersion_key synth_ticketVersion synth_ticketVersion_inv ())
    )
    ticketContents_clens_tag
    ()

let ticketContents_accessor_tag =
  assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);
  lemma_synth_ticketVersion_inj ();
  lemma_synth_ticketVersion_inv ();
  LL.accessor_ext
    (LL.accessor_compose
      (LL.accessor_sum_tag ticketContents_sum ticketVersion_repr_parser parse_ticketContents_cases)
      (LL.accessor_synth_inv parse_ticketVersion_key synth_ticketVersion synth_ticketVersion_inv ())
      ()
    )
    ticketContents_clens_tag
    ()

let ticketContents_bytesize_eqn_ticket12 x =
    assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);

  LP.serialize_sum_eq ticketContents_sum ticketVersion_repr_serializer serialize_ticketContents_cases (T_ticket12 x);
  (let ln = FStar.Seq.length (LP.serialize (LP.serialize_enum_key _ ticketVersion_repr_serializer (LP.sum_enum ticketContents_sum)) (key_of_ticketContents (T_ticket12 x))) in assert (1 <= ln /\ ln <= 1));
  (ticketContents12_bytesize_eq (x))

let ticketContents_bytesize_eqn_ticket13 x =
    assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);

  LP.serialize_sum_eq ticketContents_sum ticketVersion_repr_serializer serialize_ticketContents_cases (T_ticket13 x);
  (let ln = FStar.Seq.length (LP.serialize (LP.serialize_enum_key _ ticketVersion_repr_serializer (LP.sum_enum ticketContents_sum)) (key_of_ticketContents (T_ticket13 x))) in assert (1 <= ln /\ ln <= 1));
  (ticketContents13_bytesize_eq (x))
/
prims.fst.checked MiTLS.Parsers.TicketVersion.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
MiTLS.Parsers.TicketContents.fst
LowParse.Low.Base.Spec.clens MiTLS.Parsers.TicketContents.ticketContents
  MiTLS.Parsers.TicketContents12.ticketContents12
LowParse.Low.Sum.clens_sum_payload MiTLS.Parsers.TicketContents.ticketContents_sum MiTLS.Parsers.TicketContents.ticketVersion_as_enum_key MiTLS.Parsers.TicketVersion.Ticket12
let ticketContents_clens'_ticket12:LL.clens ticketContents ticketContents12 =
  
LL.clens_sum_payload ticketContents_sum (ticketVersion_as_enum_key Ticket12)