@@ -855,11 +855,11 @@ theorem map_eq (f : Char → Char) (s) : Legacy.map f s = ofList (s.toList.map f
855855
856856@[nolint unusedHavesSuffices] -- false positive from unfolding String.takeWhileAux
857857theorem takeWhileAux_of_valid (p : Char → Bool) : ∀ l m r,
858- Substring.takeWhileAux (ofList (l ++ m ++ r)) ⟨utf8Len l + utf8Len m⟩ p ⟨utf8Len l⟩ =
858+ Substring.Raw. takeWhileAux (ofList (l ++ m ++ r)) ⟨utf8Len l + utf8Len m⟩ p ⟨utf8Len l⟩ =
859859 ⟨utf8Len l + utf8Len (m.takeWhile p)⟩
860- | l, [], r => by unfold Substring.takeWhileAux List.takeWhile; simp
860+ | l, [], r => by unfold Substring.Raw. takeWhileAux List.takeWhile; simp
861861 | l, c::m, r => by
862- unfold Substring.takeWhileAux List.takeWhile
862+ unfold Substring.Raw. takeWhileAux List.takeWhile
863863 rw [dif_pos (by exact Nat.lt_add_of_pos_right add_utf8Size_pos)]
864864 simp only [List.append_assoc, List.cons_append, get_of_valid l (c :: (m ++ r)),
865865 Char.reduceDefault, List.headD_cons, utf8Len_cons, next_of_valid l c (m ++ r)]
@@ -891,10 +891,10 @@ end String
891891
892892open String
893893
894- namespace Substring
894+ namespace Substring.Raw
895895
896896/-- Validity for a substring. -/
897- structure Valid (s : Substring) : Prop where
897+ structure Valid (s : Substring.Raw ) : Prop where
898898 /-- The start position of a valid substring is valid. -/
899899 startValid : s.startPos.Valid s.str
900900 /-- The stop position of a valid substring is valid. -/
@@ -906,7 +906,7 @@ theorem Valid_default : Valid default := ⟨Pos.Raw.valid_zero, Pos.Raw.valid_ze
906906
907907/-- A substring is represented by three lists `l m r`, where `m` is the middle section
908908(the actual substring) and `l ++ m ++ r` is the underlying string. -/
909- inductive ValidFor (l m r : List Char) : Substring → Prop
909+ inductive ValidFor (l m r : List Char) : Substring.Raw → Prop
910910 /-- The constructor for `ValidFor`. -/
911911 | mk : ValidFor l m r ⟨String.ofList (l ++ m ++ r), ⟨utf8Len l⟩, ⟨utf8Len l + utf8Len m⟩⟩
912912
@@ -925,7 +925,7 @@ theorem of_eq : ∀ s,
925925 exact ⟨⟩
926926
927927theorem _root_.String.validFor_toSubstring (s : String) : ValidFor [] s.toList [] s :=
928- .of_eq _ (by simp [toSubstring ]) rfl (by simp [toSubstring , rawEndPos])
928+ .of_eq _ (by simp [toRawSubstring ]) rfl (by simp [toRawSubstring , rawEndPos])
929929
930930theorem str : ∀ {s}, ValidFor l m r s → s.str = String.ofList (l ++ m ++ r)
931931 | _, ⟨⟩ => rfl
@@ -937,17 +937,17 @@ theorem stopPos : ∀ {s}, ValidFor l m r s → s.stopPos = ⟨utf8Len l + utf8L
937937 | _, ⟨⟩ => rfl
938938
939939theorem bsize : ∀ {s}, ValidFor l m r s → s.bsize = utf8Len m
940- | _, ⟨⟩ => by simp [Substring.bsize, Nat.add_sub_cancel_left]
940+ | _, ⟨⟩ => by simp [Substring.Raw. bsize, Nat.add_sub_cancel_left]
941941
942942theorem isEmpty : ∀ {s}, ValidFor l m r s → (s.isEmpty ↔ m = [])
943- | _, h => by simp [Substring.isEmpty, h.bsize]
943+ | _, h => by simp [Substring.Raw. isEmpty, h.bsize]
944944
945945theorem toString : ∀ {s}, ValidFor l m r s → s.toString = String.ofList m
946946 | _, ⟨⟩ => extract_of_valid l m r
947947
948948theorem toIterator : ∀ {s}, ValidFor l m r s → s.toLegacyIterator.ValidFor l.reverse (m ++ r)
949949 | _, h => by
950- simp only [Substring.toLegacyIterator]
950+ simp only [Substring.Raw. toLegacyIterator]
951951 exact .of_eq _ (by simp [h.str, List.reverseAux_eq]) (by simp [h.startPos])
952952
953953theorem get : ∀ {s}, ValidFor l (m₁ ++ c :: m₂) r s → s.get ⟨utf8Len m₁⟩ = c
@@ -956,7 +956,8 @@ theorem get : ∀ {s}, ValidFor l (m₁ ++ c :: m₂) r s → s.get ⟨utf8Len m
956956theorem next : ∀ {s}, ValidFor l (m₁ ++ c :: m₂) r s →
957957 s.next ⟨utf8Len m₁⟩ = ⟨utf8Len m₁ + c.utf8Size⟩
958958 | _, ⟨⟩ => by
959- simp only [Substring.next, utf8Len_append, utf8Len_cons, List.append_assoc, List.cons_append]
959+ simp only [Substring.Raw.next, utf8Len_append, utf8Len_cons, List.append_assoc,
960+ List.cons_append]
960961 rw [if_neg (mt Pos.Raw.ext_iff.1 ?a)]
961962 case a =>
962963 simpa [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using
@@ -966,12 +967,12 @@ theorem next : ∀ {s}, ValidFor l (m₁ ++ c :: m₂) r s →
966967 simp [Nat.add_assoc, Nat.add_sub_cancel_left]
967968
968969theorem next_stop : ∀ {s}, ValidFor l m r s → s.next ⟨utf8Len m⟩ = ⟨utf8Len m⟩
969- | _, ⟨⟩ => by simp [Substring.next, Pos.Raw.offsetBy_eq]
970+ | _, ⟨⟩ => by simp [Substring.Raw. next, Pos.Raw.offsetBy_eq]
970971
971972theorem prev : ∀ {s}, ValidFor l (m₁ ++ c :: m₂) r s →
972973 s.prev ⟨utf8Len m₁ + c.utf8Size⟩ = ⟨utf8Len m₁⟩
973974 | _, ⟨⟩ => by
974- simp only [Substring.prev, List.append_assoc, List.cons_append]
975+ simp only [Substring.Raw. prev, List.append_assoc, List.cons_append]
975976 rw [if_neg (mt Pos.Raw.ext_iff.1 <| Ne.symm ?a)]
976977 case a => simpa [Nat.add_comm] using @ne_add_utf8Size_add_self (utf8Len l) (utf8Len m₁) c
977978 have := prev_of_valid (l ++ m₁) c (m₂ ++ r)
@@ -981,13 +982,13 @@ theorem prev : ∀ {s}, ValidFor l (m₁ ++ c :: m₂) r s →
981982
982983theorem nextn_stop : ∀ {s}, ValidFor l m r s → ∀ n, s.nextn n ⟨utf8Len m⟩ = ⟨utf8Len m⟩
983984 | _, _, 0 => rfl
984- | _, h, n+1 => by simp [Substring.nextn, h.next_stop, h.nextn_stop n]
985+ | _, h, n+1 => by simp [Substring.Raw. nextn, h.next_stop, h.nextn_stop n]
985986
986987theorem nextn : ∀ {s}, ValidFor l (m₁ ++ m₂) r s →
987988 ∀ n, s.nextn n ⟨utf8Len m₁⟩ = ⟨utf8Len m₁ + utf8Len (m₂.take n)⟩
988- | _, _, 0 => by simp [Substring.nextn]
989+ | _, _, 0 => by simp [Substring.Raw. nextn]
989990 | s, h, n+1 => by
990- simp only [Substring.nextn]
991+ simp only [Substring.Raw. nextn]
991992 match m₂ with
992993 | [] => simp at h; simp [h.next_stop, h.nextn_stop]
993994 | c::m₂ =>
@@ -997,9 +998,9 @@ theorem nextn : ∀ {s}, ValidFor l (m₁ ++ m₂) r s →
997998
998999theorem prevn : ∀ {s}, ValidFor l (m₁.reverse ++ m₂) r s →
9991000 ∀ n, s.prevn n ⟨utf8Len m₁⟩ = ⟨utf8Len (m₁.drop n)⟩
1000- | _, _, 0 => by simp [Substring.prevn]
1001+ | _, _, 0 => by simp [Substring.Raw. prevn]
10011002 | s, h, n+1 => by
1002- simp only [Substring.prevn]
1003+ simp only [Substring.Raw. prevn]
10031004 match m₁ with
10041005 | [] => simp
10051006 | c::m₁ =>
@@ -1012,9 +1013,9 @@ theorem front : ∀ {s}, ValidFor l (c :: m) r s → s.front = c
10121013theorem drop :
10131014 ∀ {s}, ValidFor l m r s → ∀ n, ValidFor (l ++ m.take n) (m.drop n) r (s.drop n)
10141015 | s, h, n => by
1015- have : Substring.nextn {..} .. = _ := h.nextn (m₁ := []) n
1016+ have : Substring.Raw. nextn {..} .. = _ := h.nextn (m₁ := []) n
10161017 simp only [utf8Len_nil, Pos.Raw.mk_zero, Nat.zero_add] at this
1017- simp only [Substring.drop, this ]
1018+ simp only [Substring.Raw. drop, this ]
10181019 simp only [h.str, List.append_assoc, h.startPos, h.stopPos]
10191020 rw [← List.take_append_drop n m] at h
10201021 refine .of_eq _ (by simp) (by simp) ?_
@@ -1024,9 +1025,9 @@ theorem drop :
10241025theorem take : ∀ {s}, ValidFor l m r s →
10251026 ∀ n, ValidFor l (m.take n) (m.drop n ++ r) (s.take n)
10261027 | s, h, n => by
1027- have : Substring.nextn {..} .. = _ := h.nextn (m₁ := []) n
1028+ have : Substring.Raw. nextn {..} .. = _ := h.nextn (m₁ := []) n
10281029 simp at this
1029- simp only [Substring.take, this ]
1030+ simp only [Substring.Raw. take, this ]
10301031 simp only [h.str, List.append_assoc, h.startPos]
10311032 rw [← List.take_append_drop n m] at h
10321033 refine .of_eq _ ?_ (by simp) (by simp)
@@ -1036,13 +1037,14 @@ theorem take : ∀ {s}, ValidFor l m r s →
10361037-- TODO: takeRight, dropRight
10371038
10381039theorem atEnd : ∀ {s}, ValidFor l m r s → (s.atEnd ⟨p⟩ ↔ p = utf8Len m)
1039- | _, ⟨⟩ => by simp [Substring.atEnd, Pos.Raw.ext_iff, Nat.add_left_cancel_iff]
1040+ | _, ⟨⟩ => by simp [Substring.Raw. atEnd, Pos.Raw.ext_iff, Nat.add_left_cancel_iff]
10401041
10411042theorem extract' : ∀ {s}, ValidFor l (ml ++ mm ++ mr) r s →
10421043 ValidFor ml mm mr ⟨String.ofList (ml ++ mm ++ mr), b, e⟩ →
10431044 ∃ l' r', ValidFor l' mm r' (s.extract b e)
10441045 | _, ⟨⟩, ⟨⟩ => by
1045- simp only [Substring.extract, ge_iff_le, Pos.Raw.mk_le_mk, List.append_assoc, utf8Len_append]
1046+ simp only [Substring.Raw.extract, ge_iff_le, Pos.Raw.mk_le_mk, List.append_assoc,
1047+ utf8Len_append]
10461048 split
10471049 · next h =>
10481050 rw [utf8Len_eq_zero.1 <| Nat.le_zero.1 <| Nat.add_le_add_iff_left.1 h]
@@ -1063,33 +1065,33 @@ theorem extract : ∀ {s}, ValidFor l m r s →
10631065-- TODO: splitOn
10641066
10651067theorem foldl (f) (init : α) : ∀ {s}, ValidFor l m r s → s.foldl f init = m.foldl f init
1066- | _, ⟨⟩ => by simp [-ofList_append, -List.append_assoc, Substring.foldl,
1068+ | _, ⟨⟩ => by simp [-ofList_append, -List.append_assoc, Substring.Raw. foldl,
10671069 foldlAux_of_valid]
10681070
10691071theorem foldr (f) (init : α) : ∀ {s}, ValidFor l m r s → s.foldr f init = m.foldr f init
1070- | _, ⟨⟩ => by simp [-ofList_append, -List.append_assoc, Substring.foldr,
1072+ | _, ⟨⟩ => by simp [-ofList_append, -List.append_assoc, Substring.Raw. foldr,
10711073 foldrAux_of_valid]
10721074
10731075theorem any (f) : ∀ {s}, ValidFor l m r s → s.any f = m.any f
1074- | _, ⟨⟩ => by simp [-ofList_append, -List.append_assoc, Substring.any, anyAux_of_valid]
1076+ | _, ⟨⟩ => by simp [-ofList_append, -List.append_assoc, Substring.Raw. any, anyAux_of_valid]
10751077
10761078theorem all (f) : ∀ {s}, ValidFor l m r s → s.all f = m.all f
1077- | _, h => by simp [Substring.all, h.any, List.all_eq_not_any_not]
1079+ | _, h => by simp [Substring.Raw. all, h.any, List.all_eq_not_any_not]
10781080
10791081theorem contains (c) : ∀ {s}, ValidFor l m r s → (s.contains c ↔ c ∈ m)
1080- | _, h => by simp [Substring.contains, h.any]
1082+ | _, h => by simp [Substring.Raw. contains, h.any]
10811083
10821084theorem takeWhile (p : Char → Bool) : ∀ {s}, ValidFor l m r s →
10831085 ValidFor l (m.takeWhile p) (m.dropWhile p ++ r) (s.takeWhile p)
10841086 | _, ⟨⟩ => by
1085- simp only [Substring.takeWhile, takeWhileAux_of_valid]
1087+ simp only [Substring.Raw. takeWhile, takeWhileAux_of_valid]
10861088 apply ValidFor.of_eq <;> simp
10871089 rw [← List.append_assoc, List.takeWhile_append_dropWhile]
10881090
10891091theorem dropWhile (p : Char → Bool) : ∀ {s}, ValidFor l m r s →
10901092 ValidFor (l ++ m.takeWhile p) (m.dropWhile p) r (s.dropWhile p)
10911093 | _, ⟨⟩ => by
1092- simp only [Substring.dropWhile, takeWhileAux_of_valid]
1094+ simp only [Substring.Raw. dropWhile, takeWhileAux_of_valid]
10931095 apply ValidFor.of_eq <;> simp
10941096 rw [Nat.add_assoc, ← utf8Len_append (m.takeWhile p), List.takeWhile_append_dropWhile]
10951097
@@ -1233,7 +1235,7 @@ theorem data_dropWhile (p) : ∀ {s}, Valid s →
12331235-- TODO: takeRightWhile
12341236
12351237end Valid
1236- end Substring
1238+ end Substring.Raw
12371239
12381240namespace String
12391241
0 commit comments