val protocolVersion_bytesize_eqn (x: protocolVersion) : Lemma (protocolVersion_bytesize x == 2) [SMTPat (protocolVersion_bytesize x)]
val protocolVersion_bytesize_eqn (x: protocolVersion) : Lemma (protocolVersion_bytesize x == 2) [SMTPat (protocolVersion_bytesize x)]
let protocolVersion_bytesize_eqn x = protocolVersion_bytesize_eq x; assert (FStar.Seq.length (LP.serialize protocolVersion_serializer x) <= 2); assert (2 <= FStar.Seq.length (LP.serialize protocolVersion_serializer x))
module MiTLS.Parsers.ProtocolVersion

(* 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"

[@LT.Norm] inline_for_extraction let protocolVersion_enum : LP.enum protocolVersion U16.t =
  [@inline_let] let e = [
    SSL_3p0, 768us;
    TLS_1p0, 769us;
    TLS_1p1, 770us;
    TLS_1p2, 771us;
    TLS_1p3, 772us;
  ] in
  [@inline_let] let _ =
    assert_norm (L.noRepeats (LP.list_map fst e))
  in
  [@inline_let] let _ = 
    assert_norm (L.noRepeats (LP.list_map snd e))
  in e

noextract let protocolVersion_repr_parser = LPI.parse_u16

noextract let protocolVersion_repr_serializer = LPI.serialize_u16

inline_for_extraction noextract let protocolVersion_repr_parser32 = LS.parse32_u16

inline_for_extraction noextract let protocolVersion_repr_serializer32 = LS.serialize32_u16

inline_for_extraction noextract let protocolVersion_repr_size32 = LSZ.size32_u16

inline_for_extraction noextract let protocolVersion_repr_validator = (LL.validate_u16 ())

inline_for_extraction noextract let protocolVersion_repr_jumper = LL.jump_u16

inline_for_extraction noextract let protocolVersion_repr_reader = LL.read_u16

inline_for_extraction noextract let protocolVersion_repr_writer = LL.write_u16

inline_for_extraction let synth_protocolVersion (x:LP.maybe_enum_key protocolVersion_enum) : protocolVersion = 
  match x with
  | LP.Known k -> k
  | LP.Unknown y ->
    [@inline_let] let v : U16.t = y in
    [@inline_let] let _ = assert_norm (LP.list_mem v (LP.list_map snd protocolVersion_enum) == known_protocolVersion_repr v) in
    Unknown_protocolVersion v

inline_for_extraction let synth_protocolVersion_inv (x:protocolVersion) : LP.maybe_enum_key protocolVersion_enum = 
  match x with
  | Unknown_protocolVersion y ->
    [@inline_let] let v : U16.t = y in
    [@inline_let] let _ = assert_norm (LP.list_mem v (LP.list_map snd protocolVersion_enum) == known_protocolVersion_repr v) in
    LP.Unknown v
  | x ->
    [@inline_let] let x1 : protocolVersion = x in
    [@inline_let] let _ : squash(not (Unknown_protocolVersion? x1) ==> LP.list_mem x1 (LP.list_map fst protocolVersion_enum)) =
      _ by (LP.synth_maybe_enum_key_inv_unknown_tac x1)
    in
    LP.Known (x1 <: LP.enum_key protocolVersion_enum)

let lemma_synth_protocolVersion_inv' () : Lemma
  (LP.synth_inverse synth_protocolVersion_inv synth_protocolVersion)
= LP.forall_maybe_enum_key protocolVersion_enum (fun x -> synth_protocolVersion_inv (synth_protocolVersion x) == x)
    (_ by (LP.forall_maybe_enum_key_known_tac ()))
    (_ by (LP.forall_maybe_enum_key_unknown_tac ()))

let lemma_synth_protocolVersion_inj () : Lemma
  (LP.synth_injective synth_protocolVersion) = 
  lemma_synth_protocolVersion_inv' ();
  LP.synth_inverse_synth_injective synth_protocolVersion synth_protocolVersion_inv

#push-options "--max_ifuel 0 --initial_ifuel 0 --max_fuel 0 --max_ifuel 0"
let lemma_synth_protocolVersion_inv () : Lemma
  (LP.synth_inverse synth_protocolVersion synth_protocolVersion_inv) = allow_inversion protocolVersion; ()

#pop-options
noextract let parse_maybe_protocolVersion_key : LP.parser _ (LP.maybe_enum_key protocolVersion_enum) =
  LP.parse_maybe_enum_key protocolVersion_repr_parser protocolVersion_enum

noextract let serialize_maybe_protocolVersion_key : LP.serializer parse_maybe_protocolVersion_key =
  LP.serialize_maybe_enum_key protocolVersion_repr_parser protocolVersion_repr_serializer protocolVersion_enum

noextract let protocolVersion_parser : LP.parser _ protocolVersion =
  lemma_synth_protocolVersion_inj ();
  parse_maybe_protocolVersion_key `LP.parse_synth` synth_protocolVersion

noextract let protocolVersion_serializer : LP.serializer protocolVersion_parser =
  lemma_synth_protocolVersion_inj ();
  lemma_synth_protocolVersion_inv ();
  LP.serialize_synth _ synth_protocolVersion serialize_maybe_protocolVersion_key synth_protocolVersion_inv ()

let protocolVersion_bytesize (x:protocolVersion) : GTot nat = Seq.length (protocolVersion_serializer x)

let protocolVersion_bytesize_eq x = ()

let parse32_maybe_protocolVersion_key : LS.parser32 parse_maybe_protocolVersion_key =
  FStar.Tactics.synth_by_tactic (LS.parse32_maybe_enum_key_tac protocolVersion_repr_parser32 protocolVersion_enum)

let protocolVersion_parser32 : LS.parser32 protocolVersion_parser =
  lemma_synth_protocolVersion_inj ();
  LS.parse32_synth _ synth_protocolVersion (fun x->synth_protocolVersion x) parse32_maybe_protocolVersion_key ()

let serialize32_maybe_protocolVersion_key : LS.serializer32 serialize_maybe_protocolVersion_key =
  FStar.Tactics.synth_by_tactic (LS.serialize32_maybe_enum_key_tac
    protocolVersion_repr_serializer32 protocolVersion_enum)

let protocolVersion_serializer32 : LS.serializer32 protocolVersion_serializer =
  lemma_synth_protocolVersion_inj ();
  lemma_synth_protocolVersion_inv ();
  LS.serialize32_synth _ synth_protocolVersion _ serialize32_maybe_protocolVersion_key synth_protocolVersion_inv (fun x->synth_protocolVersion_inv x) ()

let protocolVersion_size32 =
  [@inline_let] let _ = assert_norm (LSZ.size32_constant_precond protocolVersion_serializer 2ul) in
  LSZ.size32_constant protocolVersion_serializer 2ul ()

[@@ (LT.postprocess_with LT.pp_norm_tac) ]
inline_for_extraction let read_maybe_protocolVersion_key : LL.leaf_reader parse_maybe_protocolVersion_key =
    LL.mk_read_maybe_enum_key protocolVersion_repr_reader protocolVersion_enum

let protocolVersion_reader =
 [@inline_let] let _ = lemma_synth_protocolVersion_inj () in
 LL.read_synth' parse_maybe_protocolVersion_key synth_protocolVersion read_maybe_protocolVersion_key ()

inline_for_extraction let write_maybe_protocolVersion_key : LL.leaf_writer_strong serialize_maybe_protocolVersion_key =
  LL.write_maybe_enum_key protocolVersion_repr_writer protocolVersion_enum (_ by (LP.enum_repr_of_key_tac protocolVersion_enum))

inline_for_extraction let lserialize_maybe_protocolVersion_key : LL.serializer32 serialize_maybe_protocolVersion_key =
  LL.serializer32_of_leaf_writer_strong_constant_size write_maybe_protocolVersion_key 2ul ()

let protocolVersion_writer =
  [@inline_let] let _ = lemma_synth_protocolVersion_inj (); lemma_synth_protocolVersion_inv () in
  LL.write_synth write_maybe_protocolVersion_key synth_protocolVersion synth_protocolVersion_inv (fun x -> synth_protocolVersion_inv x) ()

let protocolVersion_lserializer = LL.serializer32_of_leaf_writer_strong_constant_size protocolVersion_writer 2ul ()
/
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.Tactics.fst.checked FStar.Seq.fst.checked FStar.Pervasives.Native.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.ProtocolVersion.fst
x: MiTLS.Parsers.ProtocolVersion.protocolVersion
  -> FStar.Pervasives.Lemma (ensures MiTLS.Parsers.ProtocolVersion.protocolVersion_bytesize x == 2)
      [SMTPat (MiTLS.Parsers.ProtocolVersion.protocolVersion_bytesize x)]
MiTLS.Parsers.ProtocolVersion.protocolVersion Prims._assert Prims.b2t Prims.op_LessThanOrEqual FStar.Seq.Base.length LowParse.Bytes.byte LowParse.Spec.Base.serialize MiTLS.Parsers.ProtocolVersion.protocolVersion_parser_kind MiTLS.Parsers.ProtocolVersion.protocolVersion_parser MiTLS.Parsers.ProtocolVersion.protocolVersion_serializer Prims.unit MiTLS.Parsers.ProtocolVersion.protocolVersion_bytesize_eq
let protocolVersion_bytesize_eqn x =
  
protocolVersion_bytesize_eq x;
assert (FStar.Seq.length (LP.serialize protocolVersion_serializer x) <= 2);
assert (2 <= FStar.Seq.length (LP.serialize protocolVersion_serializer x))