-- Mathlib/Data/List/SplitOn.lean
theorem splitOn_intercalate [DecidableEq α] (x : α) (hx : ∀ l ∈ ls, x ∉ l) (hls : ls ≠ []) :
    ([x].intercalate ls).splitOn x = ls

Proof state:
case cons.cons
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
ih :
  (∀ (l : List α), l ∈ head✝ :: tail✝ → ¬x ∈ l) →
    head✝ :: tail✝ ≠ [] → splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
⊢ splitOn x (intersperse [x] (hd :: head✝ :: tail✝)).flatten = hd :: head✝ :: tail✝

Tactic:
simp only [intersperse_cons₂, singleton_append, flatten]

Result:
case cons.cons
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
ih :
  (∀ (l : List α), l ∈ head✝ :: tail✝ → ¬x ∈ l) →
    head✝ :: tail✝ ≠ [] → splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
⊢ splitOn x (hd ++ x :: (intersperse [x] (head✝ :: tail✝)).flatten) = hd :: head✝ :: tail✝

Proof state:
case cons.cons.specialize_1
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
ih :
  (∀ (l : List α), l ∈ head✝ :: tail✝ → ¬x ∈ l) →
    head✝ :: tail✝ ≠ [] → splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
l : List α
hl : l = head✝ ∨ l ∈ tail✝
⊢ l = hd ∨ l = head✝ ∨ l ∈ tail✝

Tactic:
exact Or.inr hl

Result:
no goals

Proof state:
case nil
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hx : ∀ (l : List α), l ∈ [] → ¬x ∈ l
hls : [] ≠ []
⊢ splitOn x (intersperse [x] []).flatten = []

Tactic:
contradiction

Result:
no goals

Proof state:
case cons.cons.specialize_2
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
ih :
  (∀ (l : List α), l ∈ head✝ :: tail✝ → ¬x ∈ l) →
    head✝ :: tail✝ ≠ [] → splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
⊢ head✝ :: tail✝ ≠ []

Tactic:
exact List.noConfusion

Result:
no goals

Proof state:
case cons.nil
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd : List α
ih : (∀ (l : List α), l ∈ [] → ¬x ∈ l) → [] ≠ [] → splitOn x (intersperse [x] []).flatten = []
hx : ∀ (l : List α), l ∈ [hd] → ¬x ∈ l
hls : [hd] ≠ []
y : α
hy : x ∈ hd
H : (y == x) = true
⊢ hd ∈ [hd]

Tactic:
simp

Result:
no goals

Proof state:
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
ih : splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
⊢ ∀ (x_1 : α), x_1 ∈ hd → ¬(fun x_2 => x_2 == x) x_1 = true

Tactic:
intro y hy H

Result:
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
ih : splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
y : α
hy : y ∈ hd
H : (fun x_1 => x_1 == x) y = true
⊢ False

Proof state:
case cons.cons
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
ih :
  (∀ (l : List α), l ∈ head✝ :: tail✝ → ¬x ∈ l) →
    head✝ :: tail✝ ≠ [] → splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
⊢ splitOn x (hd ++ x :: (intersperse [x] (head✝ :: tail✝)).flatten) = hd :: head✝ :: tail✝

Tactic:
specialize ih _ _

Result:
case cons.cons.specialize_1
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
ih :
  (∀ (l : List α), l ∈ head✝ :: tail✝ → ¬x ∈ l) →
    head✝ :: tail✝ ≠ [] → splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
⊢ ∀ (l : List α), l ∈ head✝ :: tail✝ → ¬x ∈ l

case cons.cons.specialize_2
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
ih :
  (∀ (l : List α), l ∈ head✝ :: tail✝ → ¬x ∈ l) →
    head✝ :: tail✝ ≠ [] → splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
⊢ head✝ :: tail✝ ≠ []

case cons.cons
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
ih : splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
⊢ splitOn x (hd ++ x :: (intersperse [x] (head✝ :: tail✝)).flatten) = hd :: head✝ :: tail✝

Proof state:
case cons.cons.specialize_1
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
ih :
  (∀ (l : List α), l ∈ head✝ :: tail✝ → ¬x ∈ l) →
    head✝ :: tail✝ ≠ [] → splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
l : List α
hl : l ∈ head✝ :: tail✝
⊢ l ∈ hd :: head✝ :: tail✝

Tactic:
simp only [mem_cons] at hl ⊢

Result:
case cons.cons.specialize_1
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
ih :
  (∀ (l : List α), l ∈ head✝ :: tail✝ → ¬x ∈ l) →
    head✝ :: tail✝ ≠ [] → splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
l : List α
hl : l = head✝ ∨ l ∈ tail✝
⊢ l = hd ∨ l = head✝ ∨ l ∈ tail✝

Proof state:
case cons.cons
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
ih : splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
this : ∀ (as : List α), splitOnP (fun x_1 => x_1 == x) (hd ++ x :: as) = hd :: splitOnP (fun x_1 => x_1 == x) as
⊢ splitOn x (hd ++ x :: (intersperse [x] (head✝ :: tail✝)).flatten) = hd :: head✝ :: tail✝

case h
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
ih : splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
⊢ ∀ (x_1 : α), x_1 ∈ hd → ¬(fun x_2 => x_2 == x) x_1 = true

Tactic:
case h =>
  intro y hy H
  rw [eq_of_beq H] at hy
  exact hx hd (.head _) hy

Result:
case cons.cons
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd head✝ : List α
tail✝ : List (List α)
hx : ∀ (l : List α), l ∈ hd :: head✝ :: tail✝ → ¬x ∈ l
hls : hd :: head✝ :: tail✝ ≠ []
ih : splitOn x (intersperse [x] (head✝ :: tail✝)).flatten = head✝ :: tail✝
this : ∀ (as : List α), splitOnP (fun x_1 => x_1 == x) (hd ++ x :: as) = hd :: splitOnP (fun x_1 => x_1 == x) as
⊢ splitOn x (hd ++ x :: (intersperse [x] (head✝ :: tail✝)).flatten) = hd :: head✝ :: tail✝

Proof state:
case cons.nil
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd : List α
ih : (∀ (l : List α), l ∈ [] → ¬x ∈ l) → [] ≠ [] → splitOn x (intersperse [x] []).flatten = []
hx : ∀ (l : List α), l ∈ [hd] → ¬x ∈ l
hls : [hd] ≠ []
⊢ splitOn x (intersperse [x] [hd]).flatten = [hd]

Tactic:
suffices hd.splitOn x = [hd] by simpa [flatten]

Result:
case cons.nil
α : Type u_1
ls : List (List α)
inst✝ : DecidableEq α
x : α
hd : List α
ih : (∀ (l : List α), l ∈ [] → ¬x ∈ l) → [] ≠ [] → splitOn x (intersperse [x] []).flatten = []
hx : ∀ (l : List α), l ∈ [hd] → ¬x ∈ l
hls : [hd] ≠ []
⊢ splitOn x hd = [hd]