@@ -11,7 +11,7 @@ import Mathlib.Data.List.Chain
1111This file provides the basic API for `List.splitBy` which is defined in Core.
1212The main results are the following:
1313
14- - `List.join_splitBy `: the lists in `List.splitBy` join to the original list.
14+ - `List.flatten_splitBy `: the lists in `List.splitBy` join to the original list.
1515- `List.nil_notMem_splitBy`: the empty list is not contained in `List.splitBy`.
1616- `List.isChain_of_mem_splitBy`: any two adjacent elements in a list in
1717 `List.splitBy` are related by the specified relation.
@@ -54,8 +54,7 @@ theorem flatten_splitBy (r : α → α → Bool) (l : List α) : (l.splitBy r).f
5454private theorem nil_notMem_splitByLoop {r : α → α → Bool} {l : List α} {a : α} {g : List α} :
5555 [] ∉ splitBy.loop r l a g [] := by
5656 induction l generalizing a g with
57- | nil =>
58- simp [splitBy.loop]
57+ | nil => simp [splitBy.loop]
5958 | cons b l IH =>
6059 rw [splitBy.loop]
6160 split
@@ -65,16 +64,16 @@ private theorem nil_notMem_splitByLoop {r : α → α → Bool} {l : List α} {a
6564
6665@[deprecated (since := "2025-05-23")] alias nil_not_mem_splitByLoop := nil_notMem_splitByLoop
6766
67+ @[simp]
6868theorem nil_notMem_splitBy (r : α → α → Bool) (l : List α) : [] ∉ l.splitBy r :=
6969 match l with
7070 | nil => not_mem_nil
7171 | cons _ _ => nil_notMem_splitByLoop
7272
7373@[deprecated (since := "2025-05-23")] alias nil_not_mem_splitBy := nil_notMem_splitBy
7474
75- theorem ne_nil_of_mem_splitBy (r : α → α → Bool) {l : List α} (h : m ∈ l.splitBy r) : m ≠ [] := by
76- rintro rfl
77- exact nil_notMem_splitBy r l h
75+ theorem ne_nil_of_mem_splitBy {r : α → α → Bool} {l : List α} (h : m ∈ l.splitBy r) : m ≠ [] :=
76+ fun _ ↦ by simp_all
7877
7978private theorem isChain_of_mem_splitByLoop {r : α → α → Bool} {l : List α} {a : α} {g : List α}
8079 (hga : ∀ b ∈ g.head?, r b a) (hg : g.IsChain fun y x ↦ r x y)
@@ -83,33 +82,26 @@ private theorem isChain_of_mem_splitByLoop {r : α → α → Bool} {l : List α
8382 | nil =>
8483 rw [splitBy.loop, reverse_cons, mem_append, mem_reverse, mem_singleton] at h
8584 obtain hm | rfl := h
86- · exact ( not_mem_nil hm).elim
85+ · cases not_mem_nil hm
8786 · apply List.isChain_reverse.1
8887 rw [reverse_reverse]
8988 exact isChain_cons.2 ⟨hga, hg⟩
9089 | cons b l IH =>
9190 simp only [splitBy.loop, reverse_cons] at h
9291 split at h
9392 · apply IH _ (isChain_cons.2 ⟨hga, hg⟩) h
94- intro b hb
95- rw [head?_cons, Option.mem_some_iff] at hb
96- rwa [← hb]
93+ grind
9794 · rw [splitByLoop_eq_append, mem_append, reverse_singleton, mem_singleton] at h
9895 obtain rfl | hm := h
9996 · apply List.isChain_reverse.1
10097 rw [reverse_append, reverse_cons, reverse_nil, nil_append, reverse_reverse]
10198 exact isChain_cons.2 ⟨hga, hg⟩
102- · apply IH _ isChain_nil hm
103- rintro _ ⟨⟩
99+ · grind
104100
105101theorem isChain_of_mem_splitBy {r : α → α → Bool} {l : List α} (h : m ∈ l.splitBy r) :
106102 m.IsChain fun x y ↦ r x y := by
107- cases l with
108- | nil => cases h
109- | cons a l =>
110- apply isChain_of_mem_splitByLoop _ _ h
111- · rintro _ ⟨⟩
112- · exact isChain_nil
103+ match l, h with
104+ | a::l, h => apply isChain_of_mem_splitByLoop _ _ h <;> simp
113105
114106@[deprecated (since := "2025-09-24")] alias chain'_of_mem_splitBy := isChain_of_mem_splitBy
115107
0 commit comments