val ticketContents_gaccessor'_ticket13:LL.gaccessor ticketContents_parser
  ticketContents13_parser
  ticketContents_clens'_ticket13
let ticketContents_gaccessor'_ticket13 : LL.gaccessor ticketContents_parser ticketContents13_parser ticketContents_clens'_ticket13 =
[@inline_let] let _ =   assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);
 () in
  LL.gaccessor_clens_sum_payload
    ticketContents_sum
    ticketVersion_repr_parser
    parse_ticketContents_cases
    (ticketVersion_as_enum_key Ticket13)
val ticketContents_gaccessor'_ticket13:LL.gaccessor ticketContents_parser
  ticketContents13_parser
  ticketContents_clens'_ticket13
let ticketContents_gaccessor'_ticket13:LL.gaccessor ticketContents_parser
  ticketContents13_parser
  ticketContents_clens'_ticket13 =
[@@ inline_let ]let _ =
  assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser)
        ticketContents_sum
        parse_ticketContents_cases ==
      ticketContents_parser_kind);
  ()
in
LL.gaccessor_clens_sum_payload ticketContents_sum
  ticketVersion_repr_parser
  parse_ticketContents_cases
  (ticketVersion_as_enum_key Ticket13)
Parsers.TicketContents.fst.checked
prims.fst.checked 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
Parsers.TicketContents.fst
LowParse.Low.Sum.gaccessor_clens_sum_payload Parsers.TicketContents.ticketContents_sum LowParse.Spec.Int.parse_u8_kind Parsers.TicketVersion.ticketVersion_repr_parser Parsers.TicketContents.parse_ticketContents_cases Parsers.TicketContents.ticketVersion_as_enum_key Parsers.TicketVersion.Ticket13 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 Parsers.TicketContents.ticketContents_parser_kind
module 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 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))

noextract let ticketContents_clens'_ticket12 : LL.clens ticketContents ticketContents12 = LL.clens_sum_payload ticketContents_sum (ticketVersion_as_enum_key Ticket12)

let ticketContents_gaccessor'_ticket12 : LL.gaccessor ticketContents_parser ticketContents12_parser ticketContents_clens'_ticket12 =
[@inline_let] let _ =   assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);
 () in
  LL.gaccessor_clens_sum_payload
    ticketContents_sum
    ticketVersion_repr_parser
    parse_ticketContents_cases
    (ticketVersion_as_enum_key Ticket12)

inline_for_extraction
let ticketContents_accessor'_ticket12 : LL.accessor ticketContents_gaccessor'_ticket12 =
[@inline_let] let _ =   assert_norm (LP.parse_sum_kind (LP.get_parser_kind ticketVersion_repr_parser) ticketContents_sum parse_ticketContents_cases == ticketContents_parser_kind);
 () in
  LL.accessor_clens_sum_payload
    ticketContents_sum
    ticketVersion_repr_jumper
    parse_ticketContents_cases
    (ticketVersion_as_enum_key Ticket12)

let ticketContents_clens_eq_ticket12 : squash (LL.clens_eq ticketContents_clens'_ticket12 ticketContents_clens_ticket12) =
    (_ by (LL.sum_accessor_ext (`ticketContents)))

let ticketContents_gaccessor_ticket12 =
  LL.gaccessor_ext
    ticketContents_gaccessor'_ticket12
    ticketContents_clens_ticket12
    ticketContents_clens_eq_ticket12

let ticketContents_accessor_ticket12 =
  LL.accessor_ext
    ticketContents_accessor'_ticket12
    ticketContents_clens_ticket12
    ticketContents_clens_eq_ticket12

noextract let ticketContents_clens'_ticket13 : LL.clens ticketContents ticketContents13 = LL.clens_sum_payload ticketContents_sum (ticketVersion_as_enum_key Ticket13)
val ticketContents_gaccessor'_ticket13:LL.gaccessor ticketContents_parser
  ticketContents13_parser
  ticketContents_clens'_ticket13
LowParse.Low.Base.Spec.gaccessor Parsers.TicketContents.ticketContents_parser
  Parsers.TicketContents13.ticketContents13_parser
  Parsers.TicketContents.ticketContents_clens'_ticket13