Module docstring
{}
{}
isValidChar
      definition
     (n : UInt32) : Prop
        /-- Determines if the given integer is a valid [Unicode scalar value](https://www.unicode.org/glossary/#unicode_scalar_value).
Note that values in `[0xd800, 0xdfff]` are reserved for [UTF-16 surrogate pairs](https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates).
-/
@[inline, reducible] def isValidChar (n : UInt32) : Prop :=
  n < 0xd800 ∨ (0xdfff < n ∧ n < 0x110000)
        Char.lt
      definition
     (a b : Char) : Prop
        
      Char.le
      definition
     (a b : Char) : Prop
        
      Char.instLT
      instance
     : LT Char
        
      Char.instLE
      instance
     : LE Char
        
      Char.instDecidableLt
      instance
     (a b : Char) : Decidable (a < b)
        instance (a b : Char) :  Decidable (a < b) :=
  UInt32.decLt _ _
        Char.instDecidableLe
      instance
     (a b : Char) : Decidable (a ≤ b)
        instance (a b : Char) : Decidable (a ≤ b) :=
  UInt32.decLe _ _
        Char.isValidCharNat
      abbrev
     (n : Nat) : Prop
        /--
True for natural numbers that are valid [Unicode scalar
values](https://www.unicode.org/glossary/#unicode_scalar_value).
-/
abbrev isValidCharNat (n : Nat) : Prop :=
  n < 0xd800 ∨ (0xdfff < n ∧ n < 0x110000)
        Char.isValidUInt32
      theorem
     (n : Nat) (h : isValidCharNat n) : n < UInt32.size
        theorem isValidUInt32 (n : Nat) (h : isValidCharNat n) : n < UInt32.size := by
  match h with
  | Or.inl h        =>
    apply Nat.lt_trans h
    decide
  | Or.inr ⟨_,  h₂⟩ =>
    apply Nat.lt_trans h₂
    decide
        Char.isValidChar_of_isValidCharNat
      theorem
     (n : Nat) (h : isValidCharNat n) : isValidChar (UInt32.ofNatLT n (isValidUInt32 n h))
        theorem isValidChar_of_isValidCharNat (n : Nat) (h : isValidCharNat n) : isValidChar (UInt32.ofNatLT n (isValidUInt32 n h)) :=
  match h with
  | Or.inl h =>
    Or.inl (UInt32.ofNatLT_lt_of_lt _ (by decide) h)
  | Or.inr ⟨h₁, h₂⟩ =>
    Or.inr ⟨UInt32.lt_ofNatLT_of_lt _ (by decide) h₁, UInt32.ofNatLT_lt_of_lt _ (by decide) h₂⟩
        Char.isValidChar_zero
      theorem
     : isValidChar 0
        theorem isValidChar_zero : isValidChar 0 :=
  Or.inl (by decide)
        Char.toNat
      definition
     (c : Char) : Nat
        
      Char.toUInt8
      definition
     (c : Char) : UInt8
        
      Char.ofUInt8
      definition
     (n : UInt8) : Char
        /--
Converts an 8-bit unsigned integer into a character.
The integer's value is interpreted as a Unicode code point.
-/
def ofUInt8 (n : UInt8) : Char := ⟨n.toUInt32, .inl (Nat.lt_trans n.toBitVec.isLt (by decide))⟩
        Char.instInhabited
      instance
     : Inhabited Char
        
      Char.isWhitespace
      definition
     (c : Char) : Bool
        /--
Returns `true` if the character is a space `(' ', U+0020)`, a tab `('\t', U+0009)`, a carriage
return `('\r', U+000D)`, or a newline `('\n', U+000A)`.
-/
@[inline] def isWhitespace (c : Char) : Bool :=
  c = ' ' || c = '\t'c = ' ' || c = '\t' || c = '\r'c = ' ' || c = '\t' || c = '\r' || c = '\n'
        Char.isUpper
      definition
     (c : Char) : Bool
        /--
Returns `true` if the character is a uppercase ASCII letter.
The uppercase ASCII letters are the following: `ABCDEFGHIJKLMNOPQRSTUVWXYZ`.
-/
@[inline] def isUpper (c : Char) : Bool :=
  c.val ≥ 65 && c.val ≤ 90
        Char.isLower
      definition
     (c : Char) : Bool
        /--
Returns `true` if the character is a lowercase ASCII letter.
The lowercase ASCII letters are the following: `abcdefghijklmnopqrstuvwxyz`.
-/
@[inline] def isLower (c : Char) : Bool :=
  c.val ≥ 97 && c.val ≤ 122
        Char.isAlpha
      definition
     (c : Char) : Bool
        /--
Returns `true` if the character is an ASCII letter.
The ASCII letters are the following: `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`.
-/
@[inline] def isAlpha (c : Char) : Bool :=
  c.isUpper || c.isLower
        Char.isDigit
      definition
     (c : Char) : Bool
        /--
Returns `true` if the character is an ASCII digit.
The ASCII digits are the following: `0123456789`.
-/
@[inline] def isDigit (c : Char) : Bool :=
  c.val ≥ 48 && c.val ≤ 57
        Char.isAlphanum
      definition
     (c : Char) : Bool
        /--
Returns `true` if the character is an ASCII letter or digit.
The ASCII letters are the following: `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`.
The ASCII digits are the following: `0123456789`.
-/
@[inline] def isAlphanum (c : Char) : Bool :=
  c.isAlpha || c.isDigit
        Char.toLower
      definition
     (c : Char) : Char
        /--
Converts an uppercase ASCII letter to the corresponding lowercase letter. Letters outside the ASCII
alphabet are returned unchanged.
The uppercase ASCII letters are the following: `ABCDEFGHIJKLMNOPQRSTUVWXYZ`.
-/
def toLower (c : Char) : Char :=
  let n := toNat c;
  if n >= 65 ∧ n <= 90 then ofNat (n + 32) else c
        Char.toUpper
      definition
     (c : Char) : Char
        /--
Converts a lowercase ASCII letter to the corresponding uppercase letter. Letters outside the ASCII
alphabet are returned unchanged.
The lowercase ASCII letters are the following: `abcdefghijklmnopqrstuvwxyz`.
-/
def toUpper (c : Char) : Char :=
  let n := toNat c;
  if n >= 97 ∧ n <= 122 then ofNat (n - 32) else c