val certificateStatus_bytesize_eqn_ocsp  (x: oCSPResponse) : Lemma (certificateStatus_bytesize (Cs_ocsp  x) == 1 + (oCSPResponse_bytesize (x))) [SMTPat (certificateStatus_bytesize (Cs_ocsp  x))]
val certificateStatus_bytesize_eqn_ocsp  (x: oCSPResponse) : Lemma (certificateStatus_bytesize (Cs_ocsp  x) == 1 + (oCSPResponse_bytesize (x))) [SMTPat (certificateStatus_bytesize (Cs_ocsp  x))]
let certificateStatus_bytesize_eqn_ocsp  x =
    assert_norm (LP.parse_dsum_kind (LP.get_parser_kind certificateStatusType_repr_parser) certificateStatus_sum parse_certificateStatus_cases (LP.get_parser_kind LP.parse_false) == certificateStatus_parser_kind);

  LP.serialize_dsum_eq certificateStatus_sum certificateStatusType_repr_serializer parse_certificateStatus_cases serialize_certificateStatus_cases LP.parse_false LP.serialize_false (Cs_ocsp  x) ;
  let tg = LP.dsum_tag_of_data certificateStatus_sum (Cs_ocsp  x) in
  assert_norm (tg == LP.Known (known_certificateStatusType_as_enum_key Ocsp));
  (let ln = FStar.Seq.length (LP.serialize (LP.serialize_maybe_enum_key _ certificateStatusType_repr_serializer (LP.dsum_enum certificateStatus_sum)) tg) in assert (1 <= ln /\ ln <= 1));
  (oCSPResponse_bytesize_eq (x))
module MiTLS.Parsers.CertificateStatus

(* 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.CertificateStatusType

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

inline_for_extraction unfold let known_certificateStatusType_as_enum_key
  (x: certificateStatusType { norm [delta; zeta; iota; primops] (LP.list_mem x (LP.list_map fst certificateStatusType_enum)) == true })
  : LP.enum_key certificateStatusType_enum =
  [@inline_let] let _ = norm_spec [delta; zeta; iota; primops] (LP.list_mem x (LP.list_map fst certificateStatusType_enum)) in x

inline_for_extraction let unknown_certificateStatusType_as_enum_key (r:certificateStatusType_repr) : Pure (LP.unknown_enum_repr certificateStatusType_enum)
  (requires known_certificateStatusType_repr r == false) (ensures fun _ -> True) =
  [@inline_let] let _ = assert_norm(LP.list_mem r (LP.list_map snd certificateStatusType_enum) == known_certificateStatusType_repr r) in r

inline_for_extraction let unknown_enum_repr_certificateStatusType_as_repr (r:LP.unknown_enum_repr certificateStatusType_enum) : Pure certificateStatusType_repr
  (requires True) (ensures fun r -> known_certificateStatusType_repr r == false) =
  [@inline_let] let _ = assert_norm(LP.list_mem r (LP.list_map snd certificateStatusType_enum) == known_certificateStatusType_repr r) in r

inline_for_extraction let key_of_certificateStatus (x:certificateStatus) : LP.maybe_enum_key certificateStatusType_enum =
  match x with
  | Cs_ocsp _ -> LP.Known (known_certificateStatusType_as_enum_key Ocsp)
  | Cs_Unknown_certificateStatusType v _ -> LP.Unknown (unknown_certificateStatusType_as_enum_key v)

inline_for_extraction let certificateStatus_case_of_certificateStatusType (x:certificateStatusType) : Type0 =
  match x with
  | Ocsp -> oCSPResponse
  | Unknown_certificateStatusType _ -> squash False

unfold inline_for_extraction let certificateStatus_value_type (x:LP.maybe_enum_key certificateStatusType_enum) =
  LP.dsum_type_of_tag' certificateStatusType_enum certificateStatus_case_of_certificateStatusType (squash False) x

unfold inline_for_extraction let certificateStatus_refine (k:LP.maybe_enum_key certificateStatusType_enum) (x:certificateStatus)
  : Pure (LP.refine_with_tag key_of_certificateStatus k)
  (requires key_of_certificateStatus x == k) (ensures fun y -> y == x) =
  [@inline_let] let _ = norm_spec [delta; iota; zeta] (key_of_certificateStatus x) in x

unfold inline_for_extraction let certificateStatus_type_of_known_case (k: LP.enum_key certificateStatusType_enum)
  (x:certificateStatusType) (q: squash ((k <: certificateStatusType) == x))
  (#x' : LP.maybe_enum_key certificateStatusType_enum) (y: certificateStatus_value_type x')
  : Pure (norm [delta_only [(`%certificateStatus_case_of_certificateStatusType)]; iota] (certificateStatus_case_of_certificateStatusType x))
  (requires (LP.Known k == x')) (ensures (fun y' -> y' == y)) =
  [@inline_let] let _ = norm_spec [delta_only [(`%certificateStatus_case_of_certificateStatusType)]; iota] (certificateStatus_case_of_certificateStatusType k) in y

unfold inline_for_extraction let certificateStatus_known_case (k: LP.enum_key certificateStatusType_enum)
  (x: certificateStatusType) (y: norm [delta_only [(`%certificateStatus_case_of_certificateStatusType)]; iota] (certificateStatus_case_of_certificateStatusType x))
  : Pure (certificateStatus_case_of_certificateStatusType k) (requires (k == x)) (ensures (fun y' -> y' == y)) =
  [@inline_let] let _ = norm_spec [delta_only [(`%certificateStatus_case_of_certificateStatusType)] ; iota] (certificateStatus_case_of_certificateStatusType x) in y

inline_for_extraction let synth_known_certificateStatus_cases (k:LP.enum_key certificateStatusType_enum)
  (y:certificateStatus_value_type (LP.Known k)) : LP.refine_with_tag key_of_certificateStatus (LP.Known k) =
  match k with
  | Ocsp ->
    [@inline_let] let x : certificateStatus = Cs_ocsp (certificateStatus_type_of_known_case k Ocsp () y) in
    [@inline_let] let _ = assert_norm (key_of_certificateStatus x == LP.Known Ocsp) in
    certificateStatus_refine (LP.Known Ocsp) x

inline_for_extraction let synth_certificateStatus_cases (x:LP.maybe_enum_key certificateStatusType_enum)
  (y:certificateStatus_value_type x) : LP.refine_with_tag key_of_certificateStatus x =
  match x with
  | LP.Unknown v ->
    [@inline_let] let x : certificateStatus = Cs_Unknown_certificateStatusType (unknown_enum_repr_certificateStatusType_as_repr v) y in
    [@inline_let] let _ = assert_norm (key_of_certificateStatus x == LP.Unknown v) in
    certificateStatus_refine (LP.Unknown v) x
  | LP.Known k -> synth_known_certificateStatus_cases k y

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

let synth_certificateStatus_cases_recip_pre (k:LP.maybe_enum_key certificateStatusType_enum)
  (x:LP.refine_with_tag key_of_certificateStatus k) : GTot bool =
  match k with
  | LP.Known Ocsp -> Cs_ocsp? x
  | LP.Known _ -> false
  | LP.Unknown _ -> Cs_Unknown_certificateStatusType? x

let synth_certificateStatus_cases_recip_pre_intro' (x: certificateStatus)
  : Lemma (synth_certificateStatus_cases_recip_pre (key_of_certificateStatus x) x) = ()

let synth_certificateStatus_cases_recip_pre_intro (k:LP.maybe_enum_key certificateStatusType_enum)
  (x:LP.refine_with_tag key_of_certificateStatus k)
  : Lemma (synth_certificateStatus_cases_recip_pre k x == true) =
  synth_certificateStatus_cases_recip_pre_intro' x

inline_for_extraction let synth_certificateStatus_cases_recip (k:LP.maybe_enum_key certificateStatusType_enum)
  (x:LP.refine_with_tag key_of_certificateStatus k) : (certificateStatus_value_type k) =
  match k with
  | LP.Unknown z ->
    [@inline_let] let _ = synth_certificateStatus_cases_recip_pre_intro (LP.Unknown z) x in
    (match x with Cs_Unknown_certificateStatusType _ y ->  (y <: certificateStatus_value_type k))
  | LP.Known k' ->
    match k' with
    | Ocsp -> [@inline_let] let _ = synth_certificateStatus_cases_recip_pre_intro (LP.Known Ocsp) x in
      (match x with Cs_ocsp y -> certificateStatus_known_case k' Ocsp y)
   | _ -> [@inline_let] let _ = synth_certificateStatus_cases_recip_pre_intro (LP.Known k') in false_elim ()

inline_for_extraction let certificateStatus_sum : LP.dsum = LP.make_dsum' certificateStatusType_enum key_of_certificateStatus
  certificateStatus_case_of_certificateStatusType (squash False) synth_certificateStatus_cases synth_certificateStatus_cases_recip
  (_ by (LP.make_dsum_synth_case_recip_synth_case_known_tac ()))
  (_ by (LP.make_dsum_synth_case_recip_synth_case_unknown_tac ()))
  (_ by (LP.synth_case_synth_case_recip_tac ()))

noextract let parse_certificateStatus_cases (x:LP.dsum_known_key certificateStatus_sum)
  : k:LP.parser_kind & LP.parser k (certificateStatus_case_of_certificateStatusType x) =
  match x with
  | Ocsp -> [@inline_let] let u : (k: LP.parser_kind & LP.parser k (certificateStatus_case_of_certificateStatusType Ocsp)) = (| _, oCSPResponse_parser |) in u
  | _ -> (| _, LP.parse_false |)

noextract let serialize_certificateStatus_cases (x:LP.dsum_known_key certificateStatus_sum)
  : LP.serializer (dsnd (parse_certificateStatus_cases x)) =
  match x with
  | Ocsp -> [@inline_let] let u : LP.serializer (dsnd (parse_certificateStatus_cases Ocsp)) = oCSPResponse_serializer in u
  | _ -> LP.serialize_false

inline_for_extraction noextract let parse32_certificateStatus_cases (x:LP.dsum_known_key certificateStatus_sum)
  : LS.parser32 (dsnd (parse_certificateStatus_cases x)) =
  match x with
  | Ocsp -> [@inline_let] let u : LS.parser32 (dsnd (parse_certificateStatus_cases Ocsp)) = oCSPResponse_parser32 in u
  | _ -> LS.parse32_false

inline_for_extraction noextract let serialize32_certificateStatus_cases (x:LP.dsum_known_key certificateStatus_sum)
  : LS.serializer32 (serialize_certificateStatus_cases x) =
  match x with
  | Ocsp -> [@inline_let] let u : LS.serializer32 (serialize_certificateStatus_cases Ocsp) = oCSPResponse_serializer32 in u
  | _ -> LS.serialize32_false

inline_for_extraction noextract let size32_certificateStatus_cases (x:LP.dsum_known_key certificateStatus_sum)
  : LSZ.size32 (serialize_certificateStatus_cases x) =
  match x with
  | Ocsp -> [@inline_let] let u : LSZ.size32 (serialize_certificateStatus_cases Ocsp) = oCSPResponse_size32 in u
  | _ -> LSZ.size32_false

inline_for_extraction noextract let validate_certificateStatus_cases (x:LP.dsum_known_key certificateStatus_sum)
  : LL.validator (dsnd (parse_certificateStatus_cases x)) =
  match x with
  | Ocsp -> [@inline_let] let u : LL.validator (dsnd (parse_certificateStatus_cases Ocsp)) = oCSPResponse_validator in u
  | _ -> LL.validate_false ()

inline_for_extraction noextract let jump_certificateStatus_cases (x:LP.dsum_known_key certificateStatus_sum)
  : LL.jumper (dsnd (parse_certificateStatus_cases x)) =
  match x with
  | Ocsp -> [@inline_let] let u : LL.jumper (dsnd (parse_certificateStatus_cases Ocsp)) = oCSPResponse_jumper in u
  | _ -> LL.jump_false

let certificateStatus_parser =
  assert_norm (LP.parse_dsum_kind (LP.get_parser_kind certificateStatusType_repr_parser) certificateStatus_sum parse_certificateStatus_cases (LP.get_parser_kind LP.parse_false) == certificateStatus_parser_kind);
  LP.parse_dsum certificateStatus_sum certificateStatusType_repr_parser parse_certificateStatus_cases LP.parse_false

let certificateStatus_serializer =
  assert_norm (LP.parse_dsum_kind (LP.get_parser_kind certificateStatusType_repr_parser) certificateStatus_sum parse_certificateStatus_cases (LP.get_parser_kind LP.parse_false) == certificateStatus_parser_kind);
  LP.serialize_dsum certificateStatus_sum certificateStatusType_repr_serializer _ serialize_certificateStatus_cases _ LP.serialize_false

let certificateStatus_bytesize (x:certificateStatus) : GTot nat = Seq.length (certificateStatus_serializer x)

let certificateStatus_bytesize_eq x = ()

let certificateStatus_parser32 =
  assert_norm (LP.parse_dsum_kind (LP.get_parser_kind certificateStatusType_repr_parser) certificateStatus_sum parse_certificateStatus_cases (LP.get_parser_kind LP.parse_false) == certificateStatus_parser_kind);
  LS.parse32_dsum certificateStatus_sum certificateStatusType_repr_parser32
    _ parse32_certificateStatus_cases LS.parse32_false (_ by (LP.maybe_enum_destr_t_tac ()))

let certificateStatus_serializer32 =
  assert_norm (LP.parse_dsum_kind (LP.get_parser_kind certificateStatusType_repr_parser) certificateStatus_sum parse_certificateStatus_cases (LP.get_parser_kind LP.parse_false) == certificateStatus_parser_kind);
  assert_norm (LS.serializer32_sum_gen_precond (LP.get_parser_kind certificateStatusType_repr_parser) (LP.weaken_parse_dsum_cases_kind certificateStatus_sum parse_certificateStatus_cases certificateStatus_parser_kind));
  LS.serialize32_dsum certificateStatus_sum certificateStatusType_repr_serializer (_ by (LS.serialize32_maybe_enum_key_tac certificateStatusType_repr_serializer32 certificateStatusType_enum ()))    _ _ serialize32_certificateStatus_cases LS.serialize32_false (_ by (LP.dep_enum_destr_tac ())) ()

let certificateStatus_size32 =
  assert_norm (LP.parse_dsum_kind (LP.get_parser_kind certificateStatusType_repr_parser) certificateStatus_sum parse_certificateStatus_cases (LP.get_parser_kind LP.parse_false) == certificateStatus_parser_kind);
  assert_norm (LSZ.size32_sum_gen_precond (LP.get_parser_kind certificateStatusType_repr_parser) (LP.weaken_parse_dsum_cases_kind certificateStatus_sum parse_certificateStatus_cases certificateStatus_parser_kind));
  LSZ.size32_dsum certificateStatus_sum _ (_ by (LSZ.size32_maybe_enum_key_tac certificateStatusType_repr_size32 certificateStatusType_enum ()))
    _ _ size32_certificateStatus_cases LSZ.size32_false (_ by (LP.dep_enum_destr_tac ())) ()

let certificateStatus_validator =
  assert_norm (LP.parse_dsum_kind (LP.get_parser_kind certificateStatusType_repr_parser) certificateStatus_sum parse_certificateStatus_cases (LP.get_parser_kind LP.parse_false) == certificateStatus_parser_kind);
  LL.validate_dsum certificateStatus_sum certificateStatusType_repr_validator certificateStatusType_repr_reader parse_certificateStatus_cases validate_certificateStatus_cases (LL.validate_false ()) (_ by (LP.dep_maybe_enum_destr_t_tac ()))

let certificateStatus_jumper =
  assert_norm (LP.parse_dsum_kind (LP.get_parser_kind certificateStatusType_repr_parser) certificateStatus_sum parse_certificateStatus_cases (LP.get_parser_kind LP.parse_false) == certificateStatus_parser_kind);
  LL.jump_dsum certificateStatus_sum certificateStatusType_repr_jumper certificateStatusType_repr_reader parse_certificateStatus_cases jump_certificateStatus_cases LL.jump_false (_ by (LP.dep_maybe_enum_destr_t_tac ()))

let lemma_valid_certificateStatus_valid_certificateStatusType #_ #_ s pos h =
  assert_norm (LP.parse_dsum_kind (LP.get_parser_kind certificateStatusType_repr_parser) certificateStatus_sum parse_certificateStatus_cases (LP.get_parser_kind LP.parse_false) == certificateStatus_parser_kind);
  LL.valid_dsum_elim_tag h certificateStatus_sum certificateStatusType_repr_parser parse_certificateStatus_cases LP.parse_false s pos;
  lemma_synth_certificateStatusType_inj ();
  LL.valid_synth h parse_maybe_certificateStatusType_key synth_certificateStatusType s pos

let certificateStatus_gaccessor_tag =
  assert_norm (LP.parse_dsum_kind (LP.get_parser_kind certificateStatusType_repr_parser) certificateStatus_sum parse_certificateStatus_cases (LP.get_parser_kind LP.parse_false) == certificateStatus_parser_kind);
  lemma_synth_certificateStatusType_inj ();
  lemma_synth_certificateStatusType_inv ();
  LL.gaccessor_ext
    (LL.gaccessor_compose
      (LL.gaccessor_dsum_tag certificateStatus_sum certificateStatusType_repr_parser parse_certificateStatus_cases LP.parse_false)
      (LL.gaccessor_synth_inv parse_maybe_certificateStatusType_key synth_certificateStatusType synth_certificateStatusType_inv ())
    )
    certificateStatus_clens_tag
    ()

let certificateStatus_accessor_tag =
  assert_norm (LP.parse_dsum_kind (LP.get_parser_kind certificateStatusType_repr_parser) certificateStatus_sum parse_certificateStatus_cases (LP.get_parser_kind LP.parse_false) == certificateStatus_parser_kind);
  lemma_synth_certificateStatusType_inj ();
  lemma_synth_certificateStatusType_inv ();
  LL.accessor_ext
    (LL.accessor_compose
      (LL.accessor_dsum_tag certificateStatus_sum certificateStatusType_repr_parser parse_certificateStatus_cases LP.parse_false)
      (LL.accessor_synth_inv parse_maybe_certificateStatusType_key synth_certificateStatusType synth_certificateStatusType_inv ())
      ()
    )
    certificateStatus_clens_tag
    ()
/
prims.fst.checked MiTLS.Parsers.CertificateStatusType.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.CertificateStatus.fst
x: MiTLS.Parsers.OCSPResponse.oCSPResponse
  -> FStar.Pervasives.Lemma
      (ensures
        MiTLS.Parsers.CertificateStatus.certificateStatus_bytesize (MiTLS.Parsers.CertificateStatus.Cs_ocsp
            x) ==
        1 + MiTLS.Parsers.OCSPResponse.oCSPResponse_bytesize x)
      [
        SMTPat (MiTLS.Parsers.CertificateStatus.certificateStatus_bytesize (MiTLS.Parsers.CertificateStatus.Cs_ocsp
                x))
      ]
MiTLS.Parsers.OCSPResponse.oCSPResponse MiTLS.Parsers.OCSPResponse.oCSPResponse_bytesize_eq Prims.unit Prims._assert Prims.l_and Prims.b2t Prims.op_LessThanOrEqual Prims.nat FStar.Seq.Base.length LowParse.Bytes.byte LowParse.Spec.Base.serialize LowParse.Spec.Int.parse_u8_kind LowParse.Spec.Enum.maybe_enum_key LowParse.Spec.Sum.dsum_key_type MiTLS.Parsers.CertificateStatus.certificateStatus_sum FStar.UInt8.t LowParse.Spec.Sum.dsum_enum LowParse.Spec.Enum.parse_maybe_enum_key LowParse.Spec.Int.parse_u8 LowParse.Spec.Enum.serialize_maybe_enum_key MiTLS.Parsers.CertificateStatusType.certificateStatusType_repr_serializer FStar.Pervasives.assert_norm Prims.eq2 MiTLS.Parsers.CertificateStatusType.certificateStatusType MiTLS.Parsers.CertificateStatusType.certificateStatusType_enum LowParse.Spec.Enum.Known MiTLS.Parsers.CertificateStatus.known_certificateStatusType_as_enum_key MiTLS.Parsers.CertificateStatusType.Ocsp LowParse.Spec.Sum.dsum_key LowParse.Spec.Sum.dsum_tag_of_data MiTLS.Parsers.CertificateStatus.Cs_ocsp LowParse.Spec.Sum.serialize_dsum_eq MiTLS.Parsers.CertificateStatus.parse_certificateStatus_cases MiTLS.Parsers.CertificateStatus.serialize_certificateStatus_cases LowParse.Spec.Combinators.parse_false_kind LowParse.Spec.Combinators.parse_false LowParse.Spec.Combinators.serialize_false LowParse.Spec.Base.parser_kind LowParse.Spec.Sum.parse_dsum_kind LowParse.Spec.Base.get_parser_kind MiTLS.Parsers.CertificateStatusType.certificateStatusType_repr_parser Prims.squash Prims.l_False MiTLS.Parsers.CertificateStatus.certificateStatus_parser_kind
let certificateStatus_bytesize_eqn_ocsp x =
  
assert_norm (LP.parse_dsum_kind (LP.get_parser_kind certificateStatusType_repr_parser)
      certificateStatus_sum
      parse_certificateStatus_cases
      (LP.get_parser_kind LP.parse_false) ==
    certificateStatus_parser_kind);
LP.serialize_dsum_eq certificateStatus_sum
  certificateStatusType_repr_serializer
  parse_certificateStatus_cases
  serialize_certificateStatus_cases
  LP.parse_false
  LP.serialize_false
  (Cs_ocsp x);
let tg = LP.dsum_tag_of_data certificateStatus_sum (Cs_ocsp x) in
assert_norm (tg == LP.Known (known_certificateStatusType_as_enum_key Ocsp));
(let ln =
    FStar.Seq.length (LP.serialize (LP.serialize_maybe_enum_key _
              certificateStatusType_repr_serializer
              (LP.dsum_enum certificateStatus_sum))
          tg)
  in
  assert (1 <= ln /\ ln <= 1));
(oCSPResponse_bytesize_eq (x))