Documentation

Init.Data.String.Basic

Equations
  • s.asString = { data := s }
Instances For
    Equations
    Equations
    @[extern lean_string_dec_lt]
    instance String.decLt (s₁ : String) (s₂ : String) :
    Decidable (s₁ < s₂)
    Equations
    • s₁.decLt s₂ = s₁.data.hasDecidableLt s₂.data
    @[reducible]
    def String.le (a : String) (b : String) :
    Equations
    Instances For
      instance String.decLE (s₁ : String) (s₂ : String) :
      Decidable (s₁ s₂)
      Equations
      @[extern lean_string_length]

      Returns the length of a string in Unicode code points.

      Examples:

      Equations
      • { data := s }.length = s.length
      Instances For
        @[extern lean_string_push]

        Pushes a character onto the end of a string.

        The internal implementation uses dynamic arrays and will perform destructive updates if the string is not shared.

        Example: "abc".push 'd' = "abcd"

        Equations
        • { data := s }.push x = { data := s ++ [x] }
        Instances For
          @[extern lean_string_append]

          Appends two strings.

          The internal implementation uses dynamic arrays and will perform destructive updates if the string is not shared.

          Example: "abc".append "def" = "abcdef"

          Equations
          • { data := a }.append { data := b } = { data := a ++ b }
          Instances For

            Converts a string to a list of characters.

            Even though the logical model of strings is as a structure that wraps a list of characters, this operation takes time and space linear in the length of the string, because the compiler uses an optimized representation as dynamic arrays.

            Example: "abc".toList = ['a', 'b', 'c']

            Equations
            • s.toList = s.data
            Instances For
              @[extern lean_string_is_valid_pos]

              Returns true if p is a valid UTF-8 position in the string s, meaning that p ≤ s.endPos and p lies on a UTF-8 character boundary. This has an O(1) implementation in the runtime.

              Equations
              Instances For
                Equations
                Instances For
                  Equations
                  Instances For
                    @[extern lean_string_utf8_get]
                    def String.get (s : String) (p : String.Pos) :

                    Returns the character at position p of a string. If p is not a valid position, returns (default : Char).

                    See utf8GetAux for the reference implementation.

                    Examples:

                    • "abc".get ⟨1⟩ = 'b'
                    • "abc".get ⟨3⟩ = (default : Char) = 'A'

                    Positions can also be invalid if a byte index points into the middle of a multi-byte UTF-8 character. For example,"L∃∀N".get ⟨2⟩ = (default : Char) = 'A'.

                    Equations
                    Instances For
                      Equations
                      Instances For
                        @[extern lean_string_utf8_get_opt]

                        Returns the character at position p. If p is not a valid position, returns none.

                        Examples:

                        • "abc".get? ⟨1⟩ = some 'b'
                        • "abc".get? ⟨3⟩ = none

                        Positions can also be invalid if a byte index points into the middle of a multi-byte UTF-8 character. For example, "L∃∀N".get? ⟨2⟩ = none

                        Equations
                        Instances For
                          @[extern lean_string_utf8_get_bang]

                          Returns the character at position p of a string. If p is not a valid position, returns (default : Char) and produces a panic error message.

                          Examples:

                          • "abc".get! ⟨1⟩ = 'b'
                          • "abc".get! ⟨3⟩ panics

                          Positions can also be invalid if a byte index points into the middle of a multi-byte UTF-8 character. For example, "L∃∀N".get! ⟨2⟩ panics.

                          Equations
                          Instances For
                            Equations
                            Instances For
                              @[extern lean_string_utf8_set]

                              Replaces the character at a specified position in a string with a new character. If the position is invalid, the string is returned unchanged.

                              If both the replacement character and the replaced character are ASCII characters and the string is not shared, destructive updates are used.

                              Examples:

                              • "abc".set ⟨1⟩ 'B' = "aBc"
                              • "abc".set ⟨3⟩ 'D' = "abc"
                              • "L∃∀N".set ⟨4⟩ 'X' = "L∃XN"

                              Because '∃' is a multi-byte character, the byte index 2 in L∃∀N is an invalid position, so "L∃∀N".set ⟨2⟩ 'X' = "L∃∀N".

                              Equations
                              Instances For
                                def String.modify (s : String) (i : String.Pos) (f : CharChar) :

                                Replaces the character at position p in the string s with the result of applying f to that character. If p is an invalid position, the string is returned unchanged.

                                Examples:

                                Equations
                                • s.modify i f = s.set i (f (s.get i))
                                Instances For
                                  @[extern lean_string_utf8_next]

                                  Returns the next position in a string after position p. If p is not a valid position or p = s.endPos, the result is unspecified.

                                  Examples: Given def abc := "abc" and def lean := "L∃∀N",

                                  • abc.get (0 |> abc.next) = 'b'
                                  • lean.get (0 |> lean.next |> lean.next) = '∀'

                                  Cases where the result is unspecified:

                                  • "abc".next ⟨3⟩, since 3 = s.endPos
                                  • "L∃∀N".next ⟨2⟩, since 2 points into the middle of a multi-byte UTF-8 character
                                  Equations
                                  • s.next p = p + s.get p
                                  Instances For
                                    Equations
                                    Instances For
                                      @[extern lean_string_utf8_prev]

                                      Returns the position in a string before a specified position, p. If p = ⟨0⟩, returns 0. If p is not a valid position, the result is unspecified.

                                      Examples: Given def abc := "abc" and def lean := "L∃∀N",

                                      • abc.get (abc.endPos |> abc.prev) = 'c'
                                      • lean.get (lean.endPos |> lean.prev |> lean.prev |> lean.prev) = '∃'
                                      • "L∃∀N".prev ⟨3⟩ is unspecified, since byte 3 occurs in the middle of the multi-byte character '∃'.
                                      Equations
                                      Instances For
                                        @[inline]

                                        Returns the first character in s. If s = "", returns (default : Char).

                                        Examples:

                                        Equations
                                        • s.front = s.get 0
                                        Instances For
                                          @[inline]

                                          Returns the last character in s. If s = "", returns (default : Char).

                                          Examples:

                                          • "abc".back = 'c'
                                          • "".back = (default : Char)
                                          Equations
                                          • s.back = s.get (s.prev s.endPos)
                                          Instances For
                                            @[extern lean_string_utf8_at_end]

                                            Returns true if a specified position is greater than or equal to the position which points to the end of a string. Otherwise, returns false.

                                            Examples: Given def abc := "abc" and def lean := "L∃∀N",

                                            Because "L∃∀N" contains multi-byte characters, lean.next (lean.next 0) is not equal to abc.next (abc.next 0).

                                            Equations
                                            • x✝.atEnd x = decide (x.byteIdx x✝.utf8ByteSize)
                                            Instances For
                                              @[extern lean_string_utf8_get_fast]
                                              def String.get' (s : String) (p : String.Pos) (h : ¬s.atEnd p = true) :

                                              Returns the character at position p of a string. If p is not a valid position, returns (default : Char).

                                              Requires evidence, h, that p is within bounds instead of performing a runtime bounds check as in get.

                                              Examples:

                                              • "abc".get' 0 (by decide) = 'a'
                                              • let lean := "L∃∀N"; lean.get' (0 |> lean.next |> lean.next) (by decide) = '∀'

                                              A typical pattern combines get' with a dependent if-else expression to avoid the overhead of an additional bounds check. For example:

                                              def getInBounds? (s : String) (p : String.Pos) : Option Char :=
                                                if h : s.atEnd p then none else some (s.get' p h)
                                              

                                              Even with evidence of ¬ s.atEnd p, p may be invalid if a byte index points into the middle of a multi-byte UTF-8 character. For example, "L∃∀N".get' ⟨2⟩ (by decide) = (default : Char).

                                              Equations
                                              Instances For
                                                @[extern lean_string_utf8_next_fast]
                                                def String.next' (s : String) (p : String.Pos) (h : ¬s.atEnd p = true) :

                                                Returns the next position in a string after position p. If p is not a valid position, the result is unspecified.

                                                Requires evidence, h, that p is within bounds instead of performing a runtime bounds check as in next.

                                                Examples:

                                                • let abc := "abc"; abc.get (abc.next' 0 (by decide)) = 'b'

                                                A typical pattern combines next' with a dependent if-else expression to avoid the overhead of an additional bounds check. For example:

                                                def next? (s: String) (p : String.Pos) : Option Char :=
                                                  if h : s.atEnd p then none else s.get (s.next' p h)
                                                
                                                Equations
                                                • s.next' p h = p + s.get p
                                                Instances For
                                                  theorem Char.utf8Size_pos (c : Char) :
                                                  0 < c.utf8Size
                                                  theorem Char.utf8Size_le_four (c : Char) :
                                                  c.utf8Size 4
                                                  @[reducible, inline, deprecated Char.utf8Size_pos]
                                                  abbrev String.one_le_csize (c : Char) :
                                                  0 < c.utf8Size
                                                  Equations
                                                  Instances For
                                                    @[simp]
                                                    theorem String.pos_lt_eq (p₁ : String.Pos) (p₂ : String.Pos) :
                                                    (p₁ < p₂) = (p₁.byteIdx < p₂.byteIdx)
                                                    @[simp]
                                                    theorem String.pos_add_char (p : String.Pos) (c : Char) :
                                                    (p + c).byteIdx = p.byteIdx + c.utf8Size
                                                    theorem String.lt_next (s : String) (i : String.Pos) :
                                                    i.byteIdx < (s.next i).byteIdx
                                                    theorem String.utf8PrevAux_lt_of_pos (cs : List Char) (i : String.Pos) (p : String.Pos) :
                                                    p 0(String.utf8PrevAux cs i p).byteIdx < p.byteIdx
                                                    theorem String.prev_lt_of_pos (s : String) (i : String.Pos) (h : i 0) :
                                                    (s.prev i).byteIdx < i.byteIdx
                                                    @[irreducible]
                                                    def String.posOfAux (s : String) (c : Char) (stopPos : String.Pos) (pos : String.Pos) :
                                                    Equations
                                                    • s.posOfAux c stopPos pos = if h : pos < stopPos then if (s.get pos == c) = true then pos else let_fun this := ; s.posOfAux c stopPos (s.next pos) else pos
                                                    Instances For
                                                      @[inline]

                                                      Returns the position of the first occurrence of a character, c, in s. If s does not contain c, returns s.endPos.

                                                      Examples:

                                                      • "abba".posOf 'a' = ⟨0⟩
                                                      • "abba".posOf 'z' = ⟨4⟩
                                                      • "L∃∀N".posOf '∀' = ⟨4⟩
                                                      Equations
                                                      • s.posOf c = s.posOfAux c s.endPos 0
                                                      Instances For
                                                        @[irreducible]
                                                        Equations
                                                        • s.revPosOfAux c pos = if h : pos = 0 then none else let_fun this := ; let pos := s.prev pos; if (s.get pos == c) = true then some pos else s.revPosOfAux c pos
                                                        Instances For
                                                          @[inline]

                                                          Returns the position of the last occurrence of a character, c, in s. If s does not contain c, returns none.

                                                          Examples:

                                                          • "abba".posOf 'a' = some ⟨3⟩
                                                          • "abba".posOf 'z' = none
                                                          • "L∃∀N".posOf '∀' = some ⟨4⟩
                                                          Equations
                                                          • s.revPosOf c = s.revPosOfAux c s.endPos
                                                          Instances For
                                                            @[irreducible]
                                                            def String.findAux (s : String) (p : CharBool) (stopPos : String.Pos) (pos : String.Pos) :
                                                            Equations
                                                            • s.findAux p stopPos pos = if h : pos < stopPos then if p (s.get pos) = true then pos else let_fun this := ; s.findAux p stopPos (s.next pos) else pos
                                                            Instances For
                                                              @[inline]
                                                              def String.find (s : String) (p : CharBool) :
                                                              Equations
                                                              • s.find p = s.findAux p s.endPos 0
                                                              Instances For
                                                                @[irreducible]
                                                                Equations
                                                                • s.revFindAux p pos = if h : pos = 0 then none else let_fun this := ; let pos := s.prev pos; if p (s.get pos) = true then some pos else s.revFindAux p pos
                                                                Instances For
                                                                  @[inline]
                                                                  Equations
                                                                  • s.revFind p = s.revFindAux p s.endPos
                                                                  Instances For
                                                                    @[reducible, inline]
                                                                    Equations
                                                                    • p₁.min p₂ = { byteIdx := p₁.byteIdx.min p₂.byteIdx }
                                                                    Instances For

                                                                      Returns the first position where the two strings differ.

                                                                      Equations
                                                                      Instances For
                                                                        @[irreducible]
                                                                        Equations
                                                                        • One or more equations did not get rendered due to their size.
                                                                        Instances For
                                                                          @[extern lean_string_utf8_extract]
                                                                          Equations
                                                                          Instances For
                                                                            Equations
                                                                            Instances For
                                                                              Equations
                                                                              Instances For
                                                                                @[irreducible, specialize #[]]
                                                                                def String.splitAux (s : String) (p : CharBool) (b : String.Pos) (i : String.Pos) (r : List String) :
                                                                                Equations
                                                                                • One or more equations did not get rendered due to their size.
                                                                                Instances For
                                                                                  @[specialize #[]]
                                                                                  def String.split (s : String) (p : CharBool) :
                                                                                  Equations
                                                                                  • s.split p = s.splitAux p 0 0 []
                                                                                  Instances For
                                                                                    @[irreducible]

                                                                                    Auxiliary for splitOn. Preconditions:

                                                                                    • sep is not empty
                                                                                    • b <= i are indexes into s
                                                                                    • j is an index into sep, and not at the end

                                                                                    It represents the state where we have currently parsed some split parts into r (in reverse order), b is the beginning of the string / the end of the previous match of sep, and the first j bytes of sep match the bytes i-j .. i of s.

                                                                                    Equations
                                                                                    • One or more equations did not get rendered due to their size.
                                                                                    Instances For
                                                                                      @[inline]

                                                                                      Splits a string s on occurrences of the separator sep. When sep is empty, it returns [s]; when sep occurs in overlapping patterns, the first match is taken. There will always be exactly n+1 elements in the returned list if there were n nonoverlapping matches of sep in the string. The default separator is " ". The separators are not included in the returned substrings.

                                                                                      "here is some text ".splitOn = ["here", "is", "some", "text", ""]
                                                                                      "here is some text ".splitOn "some" = ["here is ", " text "]
                                                                                      "here is some text ".splitOn "" = ["here is some text "]
                                                                                      "ababacabac".splitOn "aba" = ["", "bac", "c"]
                                                                                      
                                                                                      Equations
                                                                                      • s.splitOn sep = if (sep == "") = true then [s] else s.splitOnAux sep 0 0 0 []
                                                                                      Instances For
                                                                                        @[deprecated String.push]
                                                                                        Equations
                                                                                        Instances For
                                                                                          @[inline]
                                                                                          def String.pushn (s : String) (c : Char) (n : Nat) :
                                                                                          Equations
                                                                                          Instances For
                                                                                            @[inline]
                                                                                            Equations
                                                                                            • s.isEmpty = (s.endPos == 0)
                                                                                            Instances For
                                                                                              @[inline]
                                                                                              Equations
                                                                                              Instances For
                                                                                                @[inline]
                                                                                                Equations
                                                                                                Instances For
                                                                                                  Equations
                                                                                                  Instances For
                                                                                                    Equations
                                                                                                    Instances For

                                                                                                      Iterator over the characters (Char) of a String.

                                                                                                      Typically created by s.iter, where s is a String.

                                                                                                      An iterator is valid if the position i is valid for the string s, meaning 0 ≤ i ≤ s.endPos and i lies on a UTF8 byte boundary. If i = s.endPos, the iterator is at the end of the string.

                                                                                                      Most operations on iterators return arbitrary values if the iterator is not valid. The functions in the String.Iterator API should rule out the creation of invalid iterators, with two exceptions:

                                                                                                      • s : String

                                                                                                        The string the iterator is for.

                                                                                                      • The current position.

                                                                                                        This position is not necessarily valid for the string, for instance if one keeps calling Iterator.next when Iterator.atEnd is true. If the position is not valid, then the current character is (default : Char), similar to String.get on an invalid position.

                                                                                                      Instances For
                                                                                                        Equations
                                                                                                        @[inline]

                                                                                                        Creates an iterator at the beginning of a string.

                                                                                                        Equations
                                                                                                        • s.mkIterator = { s := s, i := 0 }
                                                                                                        Instances For
                                                                                                          @[reducible, inline]

                                                                                                          Creates an iterator at the beginning of a string.

                                                                                                          Equations
                                                                                                          Instances For

                                                                                                            The size of a string iterator is the number of bytes remaining.

                                                                                                            Equations
                                                                                                            theorem String.Iterator.sizeOf_eq (i : String.Iterator) :
                                                                                                            sizeOf i = i.s.utf8ByteSize - i.i.byteIdx
                                                                                                            @[inline]

                                                                                                            The string the iterator is for.

                                                                                                            Equations
                                                                                                            Instances For
                                                                                                              @[inline]

                                                                                                              Number of bytes remaining in the iterator.

                                                                                                              Equations
                                                                                                              • { s := s, i := i }.remainingBytes = s.endPos.byteIdx - i.byteIdx
                                                                                                              Instances For
                                                                                                                @[inline]

                                                                                                                The current position.

                                                                                                                This position is not necessarily valid for the string, for instance if one keeps calling Iterator.next when Iterator.atEnd is true. If the position is not valid, then the current character is (default : Char), similar to String.get on an invalid position.

                                                                                                                Equations
                                                                                                                Instances For
                                                                                                                  @[inline]

                                                                                                                  The character at the current position.

                                                                                                                  On an invalid position, returns (default : Char).

                                                                                                                  Equations
                                                                                                                  • { s := s, i := i }.curr = s.get i
                                                                                                                  Instances For
                                                                                                                    @[inline]

                                                                                                                    Moves the iterator's position forward by one character, unconditionally.

                                                                                                                    It is only valid to call this function if the iterator is not at the end of the string, i.e. Iterator.atEnd is false; otherwise, the resulting iterator will be invalid.

                                                                                                                    Equations
                                                                                                                    • { s := s, i := i }.next = { s := s, i := s.next i }
                                                                                                                    Instances For
                                                                                                                      @[inline]

                                                                                                                      Decreases the iterator's position.

                                                                                                                      If the position is zero, this function is the identity.

                                                                                                                      Equations
                                                                                                                      • { s := s, i := i }.prev = { s := s, i := s.prev i }
                                                                                                                      Instances For
                                                                                                                        @[inline]

                                                                                                                        True if the iterator is past the string's last character.

                                                                                                                        Equations
                                                                                                                        • { s := s, i := i }.atEnd = decide (i.byteIdx s.endPos.byteIdx)
                                                                                                                        Instances For
                                                                                                                          @[inline]

                                                                                                                          True if the iterator is not past the string's last character.

                                                                                                                          Equations
                                                                                                                          • { s := s, i := i }.hasNext = decide (i.byteIdx < s.endPos.byteIdx)
                                                                                                                          Instances For
                                                                                                                            @[inline]

                                                                                                                            True if the position is not zero.

                                                                                                                            Equations
                                                                                                                            • { s := s, i := i }.hasPrev = decide (i.byteIdx > 0)
                                                                                                                            Instances For
                                                                                                                              @[inline]
                                                                                                                              def String.Iterator.curr' (it : String.Iterator) (h : it.hasNext = true) :
                                                                                                                              Equations
                                                                                                                              • { s := s, i := i }.curr' h_2 = s.get' i
                                                                                                                              Instances For
                                                                                                                                @[inline]
                                                                                                                                Equations
                                                                                                                                • { s := s, i := i }.next' h_2 = { s := s, i := s.next' i }
                                                                                                                                Instances For
                                                                                                                                  @[inline]

                                                                                                                                  Replaces the current character in the string.

                                                                                                                                  Does nothing if the iterator is at the end of the string. If the iterator contains the only reference to its string, this function will mutate the string in-place instead of allocating a new one.

                                                                                                                                  Equations
                                                                                                                                  • { s := s, i := i }.setCurr x = { s := s.set i x, i := i }
                                                                                                                                  Instances For
                                                                                                                                    @[inline]

                                                                                                                                    Moves the iterator's position to the end of the string.

                                                                                                                                    Note that i.toEnd.atEnd is always true.

                                                                                                                                    Equations
                                                                                                                                    • { s := s, i := i }.toEnd = { s := s, i := s.endPos }
                                                                                                                                    Instances For
                                                                                                                                      @[inline]

                                                                                                                                      Extracts the substring between the positions of two iterators.

                                                                                                                                      Returns the empty string if the iterators are for different strings, or if the position of the first iterator is past the position of the second iterator.

                                                                                                                                      Equations
                                                                                                                                      • { s := a, i := a_1 }.extract { s := b, i := b_1 } = if (decide (a b) || decide (a_1 > b_1)) = true then "" else a.extract a_1 b_1
                                                                                                                                      Instances For

                                                                                                                                        Moves the iterator's position several characters forward.

                                                                                                                                        The resulting iterator is only valid if the number of characters to skip is less than or equal to the number of characters left in the iterator.

                                                                                                                                        Equations
                                                                                                                                        • x.forward 0 = x
                                                                                                                                        • x.forward n.succ = x.next.forward n
                                                                                                                                        Instances For
                                                                                                                                          @[inline]

                                                                                                                                          The remaining characters in an iterator, as a string.

                                                                                                                                          Equations
                                                                                                                                          • { s := s, i := i }.remainingToString = s.extract i s.endPos
                                                                                                                                          Instances For

                                                                                                                                            Moves the iterator's position several characters forward.

                                                                                                                                            The resulting iterator is only valid if the number of characters to skip is less than or equal to the number of characters left in the iterator.

                                                                                                                                            Equations
                                                                                                                                            • x.nextn 0 = x
                                                                                                                                            • x.nextn n.succ = x.next.nextn n
                                                                                                                                            Instances For

                                                                                                                                              Moves the iterator's position several characters back.

                                                                                                                                              If asked to go back more characters than available, stops at the beginning of the string.

                                                                                                                                              Equations
                                                                                                                                              • x.prevn 0 = x
                                                                                                                                              • x.prevn n.succ = x.prev.prevn n
                                                                                                                                              Instances For
                                                                                                                                                @[irreducible]
                                                                                                                                                def String.offsetOfPosAux (s : String) (pos : String.Pos) (i : String.Pos) (offset : Nat) :
                                                                                                                                                Equations
                                                                                                                                                • s.offsetOfPosAux pos i offset = if i pos then offset else if h : s.atEnd i = true then offset else let_fun this := ; s.offsetOfPosAux pos (s.next i) (offset + 1)
                                                                                                                                                Instances For
                                                                                                                                                  @[inline]
                                                                                                                                                  Equations
                                                                                                                                                  • s.offsetOfPos pos = s.offsetOfPosAux pos 0 0
                                                                                                                                                  Instances For
                                                                                                                                                    @[irreducible, specialize #[]]
                                                                                                                                                    def String.foldlAux {α : Type u} (f : αCharα) (s : String) (stopPos : String.Pos) (i : String.Pos) (a : α) :
                                                                                                                                                    α
                                                                                                                                                    Equations
                                                                                                                                                    Instances For
                                                                                                                                                      @[inline]
                                                                                                                                                      def String.foldl {α : Type u} (f : αCharα) (init : α) (s : String) :
                                                                                                                                                      α
                                                                                                                                                      Equations
                                                                                                                                                      Instances For
                                                                                                                                                        @[irreducible, specialize #[]]
                                                                                                                                                        def String.foldrAux {α : Type u} (f : Charαα) (a : α) (s : String) (i : String.Pos) (begPos : String.Pos) :
                                                                                                                                                        α
                                                                                                                                                        Equations
                                                                                                                                                        Instances For
                                                                                                                                                          @[inline]
                                                                                                                                                          def String.foldr {α : Type u} (f : Charαα) (init : α) (s : String) :
                                                                                                                                                          α
                                                                                                                                                          Equations
                                                                                                                                                          Instances For
                                                                                                                                                            @[irreducible, specialize #[]]
                                                                                                                                                            def String.anyAux (s : String) (stopPos : String.Pos) (p : CharBool) (i : String.Pos) :
                                                                                                                                                            Equations
                                                                                                                                                            • s.anyAux stopPos p i = if h : i < stopPos then if p (s.get i) = true then true else let_fun this := ; s.anyAux stopPos p (s.next i) else false
                                                                                                                                                            Instances For
                                                                                                                                                              @[inline]
                                                                                                                                                              def String.any (s : String) (p : CharBool) :
                                                                                                                                                              Equations
                                                                                                                                                              • s.any p = s.anyAux s.endPos p 0
                                                                                                                                                              Instances For
                                                                                                                                                                @[inline]
                                                                                                                                                                def String.all (s : String) (p : CharBool) :
                                                                                                                                                                Equations
                                                                                                                                                                • s.all p = !s.any fun (c : Char) => !p c
                                                                                                                                                                Instances For
                                                                                                                                                                  @[inline]
                                                                                                                                                                  def String.contains (s : String) (c : Char) :
                                                                                                                                                                  Equations
                                                                                                                                                                  • s.contains c = s.any fun (a : Char) => a == c
                                                                                                                                                                  Instances For
                                                                                                                                                                    theorem String.utf8SetAux_of_gt (c' : Char) (cs : List Char) {i : String.Pos} {p : String.Pos} :
                                                                                                                                                                    i > pString.utf8SetAux c' cs i p = cs
                                                                                                                                                                    theorem String.set_next_add (s : String) (i : String.Pos) (c : Char) (b₁ : Nat) (b₂ : Nat) (h : (s.next i).byteIdx + b₁ = s.endPos.byteIdx + b₂) :
                                                                                                                                                                    ((s.set i c).next i).byteIdx + b₁ = (s.set i c).endPos.byteIdx + b₂
                                                                                                                                                                    theorem String.set_next_add.foo (i : String.Pos) (c : Char) (cs : List Char) (a : String.Pos) (b₁ : Nat) (b₂ : Nat) :
                                                                                                                                                                    (String.utf8GetAux cs a i).utf8Size + b₁ = String.utf8ByteSize.go cs + b₂(String.utf8GetAux (String.utf8SetAux c cs a i) a i).utf8Size + b₁ = String.utf8ByteSize.go (String.utf8SetAux c cs a i) + b₂
                                                                                                                                                                    theorem String.mapAux_lemma (s : String) (i : String.Pos) (c : Char) (h : ¬s.atEnd i = true) :
                                                                                                                                                                    (s.set i c).endPos.byteIdx - ((s.set i c).next i).byteIdx < s.endPos.byteIdx - i.byteIdx
                                                                                                                                                                    @[irreducible, specialize #[]]
                                                                                                                                                                    def String.mapAux (f : CharChar) (i : String.Pos) (s : String) :
                                                                                                                                                                    Equations
                                                                                                                                                                    Instances For
                                                                                                                                                                      @[inline]
                                                                                                                                                                      def String.map (f : CharChar) (s : String) :
                                                                                                                                                                      Equations
                                                                                                                                                                      Instances For
                                                                                                                                                                        @[inline]
                                                                                                                                                                        Equations
                                                                                                                                                                        • s.isNat = (!s.isEmpty && s.all fun (x : Char) => x.isDigit)
                                                                                                                                                                        Instances For
                                                                                                                                                                          Equations
                                                                                                                                                                          Instances For
                                                                                                                                                                            def String.substrEq (s1 : String) (off1 : String.Pos) (s2 : String) (off2 : String.Pos) (sz : Nat) :

                                                                                                                                                                            Return true iff the substring of byte size sz starting at position off1 in s1 is equal to that starting at off2 in s2.. False if either substring of that byte size does not exist.

                                                                                                                                                                            Equations
                                                                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                                                                            Instances For
                                                                                                                                                                              @[irreducible]
                                                                                                                                                                              def String.substrEq.loop (s1 : String) (s2 : String) (off1 : String.Pos) (off2 : String.Pos) (stop1 : String.Pos) :
                                                                                                                                                                              Equations
                                                                                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                                                                                              Instances For

                                                                                                                                                                                Return true iff p is a prefix of s

                                                                                                                                                                                Equations
                                                                                                                                                                                • p.isPrefixOf s = p.substrEq 0 s 0 p.endPos.byteIdx
                                                                                                                                                                                Instances For
                                                                                                                                                                                  def String.replace (s : String) (pattern : String) (replacement : String) :

                                                                                                                                                                                  Replace all occurrences of pattern in s with replacement.

                                                                                                                                                                                  Equations
                                                                                                                                                                                  • s.replace pattern replacement = if h : pattern.endPos.byteIdx = 0 then s else let_fun hPatt := ; String.replace.loop s pattern replacement hPatt "" 0 0
                                                                                                                                                                                  Instances For
                                                                                                                                                                                    @[irreducible]
                                                                                                                                                                                    def String.replace.loop (s : String) (pattern : String) (replacement : String) (hPatt : 0 < pattern.endPos.byteIdx) (acc : String) (accStop : String.Pos) (pos : String.Pos) :
                                                                                                                                                                                    Equations
                                                                                                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                                                                                                    Instances For

                                                                                                                                                                                      Return the beginning of the line that contains character pos.

                                                                                                                                                                                      Equations
                                                                                                                                                                                      • s.findLineStart pos = match s.revFindAux (fun (x : Char) => decide (x = '\n')) pos with | none => 0 | some n => { byteIdx := n.byteIdx + 1 }
                                                                                                                                                                                      Instances For
                                                                                                                                                                                        @[inline]
                                                                                                                                                                                        Equations
                                                                                                                                                                                        • ss.isEmpty = (ss.bsize == 0)
                                                                                                                                                                                        Instances For
                                                                                                                                                                                          @[inline]
                                                                                                                                                                                          Equations
                                                                                                                                                                                          • { str := s, startPos := b, stopPos := e }.toString = s.extract b e
                                                                                                                                                                                          Instances For
                                                                                                                                                                                            @[inline]
                                                                                                                                                                                            Equations
                                                                                                                                                                                            • { str := s, startPos := b, stopPos := e }.toIterator = { s := s, i := b }
                                                                                                                                                                                            Instances For
                                                                                                                                                                                              @[inline]

                                                                                                                                                                                              Return the codepoint at the given offset into the substring.

                                                                                                                                                                                              Equations
                                                                                                                                                                                              • { str := s, startPos := b, stopPos := stopPos }.get x = s.get (b + x)
                                                                                                                                                                                              Instances For
                                                                                                                                                                                                @[inline]

                                                                                                                                                                                                Given an offset of a codepoint into the substring, return the offset there of the next codepoint.

                                                                                                                                                                                                Equations
                                                                                                                                                                                                • { str := s, startPos := b, stopPos := stopPos }.next x = if b + x = stopPos then x else { byteIdx := (s.next (b + x)).byteIdx - b.byteIdx }
                                                                                                                                                                                                Instances For
                                                                                                                                                                                                  theorem Substring.lt_next (s : Substring) (i : String.Pos) (h : i.byteIdx < s.bsize) :
                                                                                                                                                                                                  i.byteIdx < (s.next i).byteIdx
                                                                                                                                                                                                  @[inline]

                                                                                                                                                                                                  Given an offset of a codepoint into the substring, return the offset there of the previous codepoint.

                                                                                                                                                                                                  Equations
                                                                                                                                                                                                  • { str := s, startPos := b, stopPos := stopPos }.prev x = if b + x = b then x else { byteIdx := (s.prev (b + x)).byteIdx - b.byteIdx }
                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                    Equations
                                                                                                                                                                                                    • x✝.nextn 0 x = x
                                                                                                                                                                                                    • x✝.nextn i.succ x = x✝.nextn i (x✝.next x)
                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                      Equations
                                                                                                                                                                                                      • x✝.prevn 0 x = x
                                                                                                                                                                                                      • x✝.prevn i.succ x = x✝.prevn i (x✝.prev x)
                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                        Equations
                                                                                                                                                                                                        • s.front = s.get 0
                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                          @[inline]

                                                                                                                                                                                                          Return the offset into s of the first occurrence of c in s, or s.bsize if c doesn't occur.

                                                                                                                                                                                                          Equations
                                                                                                                                                                                                          • { str := s_1, startPos := b, stopPos := e }.posOf c = { byteIdx := (s_1.posOfAux c e b).byteIdx - b.byteIdx }
                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                            @[inline]
                                                                                                                                                                                                            Equations
                                                                                                                                                                                                            • { str := s, startPos := b, stopPos := e }.drop x = { str := s, startPos := b + { str := s, startPos := b, stopPos := e }.nextn x 0, stopPos := e }
                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                              Equations
                                                                                                                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                • { str := s, startPos := b, stopPos := e }.take x = { str := s, startPos := b, stopPos := b + { str := s, startPos := b, stopPos := e }.nextn x 0 }
                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                    @[inline]
                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                    • { str := s, startPos := b, stopPos := stopPos }.atEnd x = (b + x == stopPos)
                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                      • { str := s, startPos := b, stopPos := e }.extract x✝ x = if x✝ x then { str := "", startPos := 0, stopPos := 0 } else { str := s, startPos := e.min (b + x✝), stopPos := e.min (b + x) }
                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                          @[irreducible]
                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                            @[inline]
                                                                                                                                                                                                                            def Substring.foldl {α : Type u} (f : αCharα) (init : α) (s : Substring) :
                                                                                                                                                                                                                            α
                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                                              def Substring.foldr {α : Type u} (f : Charαα) (init : α) (s : Substring) :
                                                                                                                                                                                                                              α
                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                def Substring.any (s : Substring) (p : CharBool) :
                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                • { str := s_1, startPos := b, stopPos := e }.any p = s_1.anyAux e p b
                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                  def Substring.all (s : Substring) (p : CharBool) :
                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                  • s.all p = !s.any fun (c : Char) => !p c
                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                    @[inline]
                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                    • s.contains c = s.any fun (a : Char) => a == c
                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                      @[irreducible, specialize #[]]
                                                                                                                                                                                                                                      def Substring.takeWhileAux (s : String) (stopPos : String.Pos) (p : CharBool) (i : String.Pos) :
                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                        • { str := s, startPos := b, stopPos := e }.takeWhile x = { str := s, startPos := b, stopPos := Substring.takeWhileAux s e x b }
                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                          @[inline]
                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                          • { str := s, startPos := b, stopPos := e }.dropWhile x = { str := s, startPos := Substring.takeWhileAux s e x b, stopPos := e }
                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                            @[irreducible, specialize #[]]
                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                    @[inline]
                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                        • s.isNat = s.all fun (c : Char) => c.isDigit
                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                            def Substring.beq (ss1 : Substring) (ss2 : Substring) :
                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                            • ss1.beq ss2 = (ss1.bsize == ss2.bsize && ss1.str.substrEq ss1.startPos ss2.str ss2.startPos ss1.bsize)
                                                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                                                              Checks whether two substrings have the same position and content.

                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                              • ss1.sameAs ss2 = (ss1.startPos == ss2.startPos && ss1 == ss2)
                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                                                def String.drop (s : String) (n : Nat) :
                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                • s.drop n = (s.toSubstring.drop n).toString
                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                                  • s.dropRight n = (s.toSubstring.dropRight n).toString
                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                    @[inline]
                                                                                                                                                                                                                                                                    def String.take (s : String) (n : Nat) :
                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                    • s.take n = (s.toSubstring.take n).toString
                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                      • s.takeRight n = (s.toSubstring.takeRight n).toString
                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                                                                        def String.takeWhile (s : String) (p : CharBool) :
                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                        • s.takeWhile p = (s.toSubstring.takeWhile p).toString
                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                          @[inline]
                                                                                                                                                                                                                                                                          def String.dropWhile (s : String) (p : CharBool) :
                                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                                          • s.dropWhile p = (s.toSubstring.dropWhile p).toString
                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                            @[inline]
                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                            • s.takeRightWhile p = (s.toSubstring.takeRightWhile p).toString
                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                              • s.dropRightWhile p = (s.toSubstring.dropRightWhile p).toString
                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                                                                def String.startsWith (s : String) (pre : String) :
                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                • s.startsWith pre = (s.toSubstring.take pre.length == pre.toSubstring)
                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                                                  def String.endsWith (s : String) (post : String) :
                                                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                                                  • s.endsWith post = (s.toSubstring.takeRight post.length == post.toSubstring)
                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                    @[inline]
                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                    • s.trimRight = s.toSubstring.trimRight.toString
                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                                      • s.trimLeft = s.toSubstring.trimLeft.toString
                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                        • s.trim = s.toSubstring.trim.toString
                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                          @[inline]
                                                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                            @[inline]
                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                            • s.nextUntil p i = s.nextWhile (fun (c : Char) => !p c) i
                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                                                                  • s.capitalize = s.set 0 (s.get 0).toUpper
                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                    @[inline]
                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                    • s.decapitalize = s.set 0 (s.get 0).toLower
                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem Char.length_toString (c : Char) :
                                                                                                                                                                                                                                                                                                        c.toString.length = 1
                                                                                                                                                                                                                                                                                                        theorem String.ext {s₁ : String} {s₂ : String} (h : s₁.data = s₂.data) :
                                                                                                                                                                                                                                                                                                        s₁ = s₂
                                                                                                                                                                                                                                                                                                        theorem String.ext_iff {s₁ : String} {s₂ : String} :
                                                                                                                                                                                                                                                                                                        s₁ = s₂ s₁.data = s₂.data
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.default_eq :
                                                                                                                                                                                                                                                                                                        default = ""
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.length_mk (s : List Char) :
                                                                                                                                                                                                                                                                                                        { data := s }.length = s.length
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.length_empty :
                                                                                                                                                                                                                                                                                                        "".length = 0
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.length_singleton (c : Char) :
                                                                                                                                                                                                                                                                                                        (String.singleton c).length = 1
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.length_push {s : String} (c : Char) :
                                                                                                                                                                                                                                                                                                        (s.push c).length = s.length + 1
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.length_pushn {s : String} (c : Char) (n : Nat) :
                                                                                                                                                                                                                                                                                                        (s.pushn c n).length = s.length + n
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.length_append (s : String) (t : String) :
                                                                                                                                                                                                                                                                                                        (s ++ t).length = s.length + t.length
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.data_push (s : String) (c : Char) :
                                                                                                                                                                                                                                                                                                        (s.push c).data = s.data ++ [c]
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.data_append (s : String) (t : String) :
                                                                                                                                                                                                                                                                                                        (s ++ t).data = s.data ++ t.data
                                                                                                                                                                                                                                                                                                        theorem String.lt_iff {s : String} {t : String} :
                                                                                                                                                                                                                                                                                                        s < t s.data < t.data
                                                                                                                                                                                                                                                                                                        theorem String.Pos.byteIdx_mk (n : Nat) :
                                                                                                                                                                                                                                                                                                        { byteIdx := n }.byteIdx = n
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.Pos.mk_zero :
                                                                                                                                                                                                                                                                                                        { byteIdx := 0 } = 0
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.Pos.mk_byteIdx (p : String.Pos) :
                                                                                                                                                                                                                                                                                                        { byteIdx := p.byteIdx } = p
                                                                                                                                                                                                                                                                                                        theorem String.Pos.ext {i₁ : String.Pos} {i₂ : String.Pos} (h : i₁.byteIdx = i₂.byteIdx) :
                                                                                                                                                                                                                                                                                                        i₁ = i₂
                                                                                                                                                                                                                                                                                                        theorem String.Pos.ext_iff {i₁ : String.Pos} {i₂ : String.Pos} :
                                                                                                                                                                                                                                                                                                        i₁ = i₂ i₁.byteIdx = i₂.byteIdx
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.Pos.add_byteIdx (p₁ : String.Pos) (p₂ : String.Pos) :
                                                                                                                                                                                                                                                                                                        (p₁ + p₂).byteIdx = p₁.byteIdx + p₂.byteIdx
                                                                                                                                                                                                                                                                                                        theorem String.Pos.add_eq (p₁ : String.Pos) (p₂ : String.Pos) :
                                                                                                                                                                                                                                                                                                        p₁ + p₂ = { byteIdx := p₁.byteIdx + p₂.byteIdx }
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.Pos.sub_byteIdx (p₁ : String.Pos) (p₂ : String.Pos) :
                                                                                                                                                                                                                                                                                                        (p₁ - p₂).byteIdx = p₁.byteIdx - p₂.byteIdx
                                                                                                                                                                                                                                                                                                        theorem String.Pos.sub_eq (p₁ : String.Pos) (p₂ : String.Pos) :
                                                                                                                                                                                                                                                                                                        p₁ - p₂ = { byteIdx := p₁.byteIdx - p₂.byteIdx }
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.Pos.addChar_byteIdx (p : String.Pos) (c : Char) :
                                                                                                                                                                                                                                                                                                        (p + c).byteIdx = p.byteIdx + c.utf8Size
                                                                                                                                                                                                                                                                                                        theorem String.Pos.addChar_eq (p : String.Pos) (c : Char) :
                                                                                                                                                                                                                                                                                                        p + c = { byteIdx := p.byteIdx + c.utf8Size }
                                                                                                                                                                                                                                                                                                        theorem String.Pos.zero_addChar_byteIdx (c : Char) :
                                                                                                                                                                                                                                                                                                        (0 + c).byteIdx = c.utf8Size
                                                                                                                                                                                                                                                                                                        theorem String.Pos.zero_addChar_eq (c : Char) :
                                                                                                                                                                                                                                                                                                        0 + c = { byteIdx := c.utf8Size }
                                                                                                                                                                                                                                                                                                        theorem String.Pos.addChar_right_comm (p : String.Pos) (c₁ : Char) (c₂ : Char) :
                                                                                                                                                                                                                                                                                                        p + c₁ + c₂ = p + c₂ + c₁
                                                                                                                                                                                                                                                                                                        theorem String.Pos.ne_of_lt {i₁ : String.Pos} {i₂ : String.Pos} (h : i₁ < i₂) :
                                                                                                                                                                                                                                                                                                        i₁ i₂
                                                                                                                                                                                                                                                                                                        theorem String.Pos.ne_of_gt {i₁ : String.Pos} {i₂ : String.Pos} (h : i₁ < i₂) :
                                                                                                                                                                                                                                                                                                        i₂ i₁
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.Pos.addString_byteIdx (p : String.Pos) (s : String) :
                                                                                                                                                                                                                                                                                                        (p + s).byteIdx = p.byteIdx + s.utf8ByteSize
                                                                                                                                                                                                                                                                                                        theorem String.Pos.addString_eq (p : String.Pos) (s : String) :
                                                                                                                                                                                                                                                                                                        p + s = { byteIdx := p.byteIdx + s.utf8ByteSize }
                                                                                                                                                                                                                                                                                                        theorem String.Pos.zero_addString_byteIdx (s : String) :
                                                                                                                                                                                                                                                                                                        (0 + s).byteIdx = s.utf8ByteSize
                                                                                                                                                                                                                                                                                                        theorem String.Pos.zero_addString_eq (s : String) :
                                                                                                                                                                                                                                                                                                        0 + s = { byteIdx := s.utf8ByteSize }
                                                                                                                                                                                                                                                                                                        theorem String.Pos.le_iff {i₁ : String.Pos} {i₂ : String.Pos} :
                                                                                                                                                                                                                                                                                                        i₁ i₂ i₁.byteIdx i₂.byteIdx
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.Pos.mk_le_mk {i₁ : Nat} {i₂ : Nat} :
                                                                                                                                                                                                                                                                                                        { byteIdx := i₁ } { byteIdx := i₂ } i₁ i₂
                                                                                                                                                                                                                                                                                                        theorem String.Pos.lt_iff {i₁ : String.Pos} {i₂ : String.Pos} :
                                                                                                                                                                                                                                                                                                        i₁ < i₂ i₁.byteIdx < i₂.byteIdx
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.Pos.mk_lt_mk {i₁ : Nat} {i₂ : Nat} :
                                                                                                                                                                                                                                                                                                        { byteIdx := i₁ } < { byteIdx := i₂ } i₁ < i₂
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.get!_eq_get (s : String) (p : String.Pos) :
                                                                                                                                                                                                                                                                                                        s.get! p = s.get p
                                                                                                                                                                                                                                                                                                        theorem String.lt_next' (s : String) (p : String.Pos) :
                                                                                                                                                                                                                                                                                                        p < s.next p
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.prev_zero (s : String) :
                                                                                                                                                                                                                                                                                                        s.prev 0 = 0
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.get'_eq (s : String) (p : String.Pos) (h : ¬s.atEnd p = true) :
                                                                                                                                                                                                                                                                                                        s.get' p h = s.get p
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.next'_eq (s : String) (p : String.Pos) (h : ¬s.atEnd p = true) :
                                                                                                                                                                                                                                                                                                        s.next' p h = s.next p
                                                                                                                                                                                                                                                                                                        theorem String.singleton_eq (c : Char) :
                                                                                                                                                                                                                                                                                                        String.singleton c = { data := [c] }
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.data_singleton (c : Char) :
                                                                                                                                                                                                                                                                                                        (String.singleton c).data = [c]
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.append_empty (s : String) :
                                                                                                                                                                                                                                                                                                        s ++ "" = s
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem String.empty_append (s : String) :
                                                                                                                                                                                                                                                                                                        "" ++ s = s
                                                                                                                                                                                                                                                                                                        theorem String.append_assoc (s₁ : String) (s₂ : String) (s₃ : String) :
                                                                                                                                                                                                                                                                                                        s₁ ++ s₂ ++ s₃ = s₁ ++ (s₂ ++ s₃)
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem Substring.prev_zero (s : Substring) :
                                                                                                                                                                                                                                                                                                        s.prev 0 = 0
                                                                                                                                                                                                                                                                                                        @[simp]
                                                                                                                                                                                                                                                                                                        theorem Substring.prevn_zero (s : Substring) (n : Nat) :
                                                                                                                                                                                                                                                                                                        s.prevn n 0 = 0