Skip to content

Commit

Permalink
refactor: move theorems about lists from mathlib
Browse files Browse the repository at this point in the history
`List.isEmpty_iff_eq_nil` and `List.modifyHead_modifyHead` are from
`Mathlib.Data.List.Basic`. I removed the `simp` priority and `nolint`
attribute from `modifyHead_modifyHead` because we don't need them
anymore.

We need these theorems to prove `String.splitOn_of_valid`. See
#756.

Co-authored-by: Kim Morrison <[email protected]>
  • Loading branch information
chabulhwi and kim-em committed Sep 3, 2024
1 parent 9c6c2d6 commit 6fb4f5e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Batteries/Data/List/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ open Nat
@[simp] theorem mem_toArray {a : α} {l : List α} : a ∈ l.toArray ↔ a ∈ l := by
simp [Array.mem_def]

/-! ### isEmpty -/

theorem isEmpty_iff_eq_nil {l : List α} : l.isEmpty ↔ l = [] := by cases l <;> simp [isEmpty]

/-! ### next? -/

@[simp] theorem next?_nil : @next? α [] = none := rfl
Expand All @@ -34,6 +38,11 @@ theorem get?_inj
apply getElem?_inj h₀ h₁
simp_all

/-! ### modifyHead -/

@[simp] theorem modifyHead_modifyHead (l : List α) (f g : α → α) :
(l.modifyHead f).modifyHead g = l.modifyHead (g ∘ f) := by cases l <;> simp [modifyHead]

/-! ### modifyNth -/

@[simp] theorem modifyNth_nil (f : α → α) (n) : [].modifyNth f n = [] := by cases n <;> rfl
Expand Down

0 comments on commit 6fb4f5e

Please sign in to comment.