@@ -92,7 +92,7 @@ open List
9292theorem utf8Len_le_of_sublist : ∀ {cs₁ cs₂}, cs₁ <+ cs₂ → utf8Len cs₁ ≤ utf8Len cs₂
9393 | _, _, .slnil => Nat.le_refl _
9494 | _, _, .cons _ h => Nat.le_trans (utf8Len_le_of_sublist h) (Nat.le_add_right ..)
95- | _, _, .cons₂ _ h => Nat.add_le_add_right (utf8Len_le_of_sublist h) _
95+ | _, _, .cons_cons _ h => Nat.add_le_add_right (utf8Len_le_of_sublist h) _
9696
9797theorem utf8Len_le_of_infix (h : cs₁ <:+: cs₂) : utf8Len cs₁ ≤ utf8Len cs₂ :=
9898 utf8Len_le_of_sublist h.sublist
@@ -322,25 +322,13 @@ theorem prev_of_valid' (cs cs' : List Char) :
322322 | _, .inl rfl => apply Pos.Raw.prev_zero
323323 | _, .inr ⟨cs, c, rfl⟩ => simp [prev_of_valid, -ofList_append]
324324
325- theorem front_eq (s : String) : Legacy.front s = s.toList.headD default := by
326- unfold Legacy.front; simpa using get_of_valid [] s.toList
327-
328325theorem back_eq_get_prev_rawEndPos {s : String} : Legacy.back s = (s.rawEndPos.prev s).get s := rfl
329326
330- theorem back_eq (s : String) : Legacy.back s = s.toList.getLastD default := by
331- conv => lhs; rw [← s.ofList_toList]
332- match s.toList.eq_nil_or_concat with
333- | .inl h => simp [h]; rfl
334- | .inr ⟨cs, c, h⟩ =>
335- simp only [h, back_eq_get_prev_rawEndPos]
336- have : (ofList (cs ++ [c])).rawEndPos = ⟨utf8Len cs + c.utf8Size⟩ := by
337- simp [rawEndPos, utf8ByteSize_ofList]
338- simp [-ofList_append, this , prev_of_valid, get_of_valid]
339-
340327theorem atEnd_of_valid (cs : List Char) (cs' : List Char) :
341328 String.Pos.Raw.atEnd (ofList (cs ++ cs')) ⟨utf8Len cs⟩ ↔ cs' = [] := by
342329 rw [atEnd_iff]
343- cases cs' <;> simp [add_utf8Size_pos, rawEndPos, utf8ByteSize_ofList]
330+ cases cs' <;> simp [rawEndPos, utf8ByteSize_ofList]
331+ exact Nat.add_pos_left (Char.utf8Size_pos _) _
344332
345333unseal Legacy.posOfAux Legacy.findAux in
346334theorem posOfAux_eq (s c) : Legacy.posOfAux s c = Legacy.findAux s (· == c) := (rfl)
@@ -517,24 +505,25 @@ theorem extract_of_valid (l m r : List Char) :
517505
518506theorem splitAux_of_valid (p l m r acc) :
519507 splitAux (ofList (l ++ m ++ r)) p ⟨utf8Len l⟩ ⟨utf8Len l + utf8Len m⟩ acc =
520- acc.reverse ++ (List.splitOnP.go p r m.reverse).map ofList := by
508+ acc.reverse ++ (List.splitOnPPrepend p r m.reverse).map ofList := by
521509 unfold splitAux
522510 simp only [List.append_assoc, atEnd_iff, rawEndPos_ofList, utf8Len_append, Pos.Raw.mk_le_mk,
523511 Nat.add_le_add_iff_left, (by omega : utf8Len m + utf8Len r ≤ utf8Len m ↔ utf8Len r = 0 ),
524512 utf8Len_eq_zero, List.reverse_cons, dite_eq_ite]
525513 split
526- · subst r; simpa [List.splitOnP.go] using extract_of_valid l m []
514+ · subst r
515+ simpa using extract_of_valid l m []
527516 · obtain ⟨c, r, rfl⟩ := r.exists_cons_of_ne_nil ‹_›
528517 simp only [by
529518 simpa [-ofList_append] using
530519 (⟨get_of_valid (l ++ m) (c :: r), next_of_valid (l ++ m) c r,
531520 extract_of_valid l m (c :: r)⟩ :
532- _ ∧ _ ∧ _),
533- List.splitOnP.go, List.reverse_reverse]
521+ _ ∧ _ ∧ _)]
534522 split <;> rename_i h
535- · simpa [Nat.add_assoc]
536- using splitAux_of_valid p (l++m++[c]) [] r ((ofList m)::acc)
537- · simpa [Nat.add_assoc] using splitAux_of_valid p l (m++[c]) r acc
523+ · simpa [Nat.add_assoc, List.splitOnPPrepend_cons_eq_if, h] using
524+ splitAux_of_valid p (l++m++[c]) [] r ((ofList m)::acc)
525+ · simpa [List.splitOnPPrepend_cons_eq_if, h, Nat.add_assoc] using
526+ splitAux_of_valid p l (m++[c]) r acc
538527
539528theorem splitToList_of_valid (s p) : splitToList s p = (List.splitOnP p s.toList).map ofList := by
540529 simpa [splitToList] using splitAux_of_valid p [] [] s.toList []
@@ -559,12 +548,9 @@ theorem join_eq (ss : List String) : join ss = ofList (ss.map toList).flatten :=
559548 | nil => simp
560549 | cons s ss ih => simp [ih]
561550
562- @[simp] theorem toList_join (ss : List String) : (join ss).toList = (ss.map toList).flatten := by
563- simp [join_eq]
564-
565551@[deprecated toList_join (since := " 2025-10-31" )]
566552theorem data_join (ss : List String) : (join ss).toList = (ss.map toList).flatten :=
567- toList_join ss
553+ toList_join
568554
569555namespace Legacy.Iterator
570556
@@ -573,7 +559,7 @@ namespace Legacy.Iterator
573559
574560theorem hasNext_cons_addChar (c : Char) (cs : List Char) (i : Pos.Raw) :
575561 hasNext ⟨String.ofList (c :: cs), i + c⟩ = hasNext ⟨String.ofList cs, i⟩ := by
576- simp [hasNext, Nat.add_lt_add_iff_right]
562+ simp [hasNext, utf8ByteSize_ofList]; lia
577563
578564/-- Validity for a string iterator. -/
579565def Valid (it : Iterator) : Prop := it.pos.Valid it.s
0 commit comments