-- Mathlib/GroupTheory/CoprodI.lean
theorem of_word (w : Word M) (h : w ≠ empty) : ∃ (i j : _) (w' : NeWord M i j), w'.toWord = w

Proof state:
ι : Type u_1
M : ι → Type u_2
inst✝ : (i : ι) → Monoid (M i)
x y : (i : ι) × M i
l : List ((i : ι) × M i)
hi :
  ∀ (hnot1 : ∀ l_1 ∈ y :: l, l_1.snd ≠ 1) (hchain : List.Chain' (fun l l' => l.fst ≠ l'.fst) (y :: l)),
    { toList := y :: l, ne_one := hnot1, chain_ne := hchain } ≠ empty →
      ∃ i j w', w'.toWord.toList = { toList := y :: l, ne_one := hnot1, chain_ne := hchain }.toList
hnot1✝ : ∀ l_1 ∈ x :: y :: l, l_1.snd ≠ 1
hnot1 : x.snd ≠ 1 ∧ ∀ x ∈ y :: l, x.snd ≠ 1
hchain✝ : List.Chain' (fun l l' => l.fst ≠ l'.fst) (x :: y :: l)
hchain : x.fst ≠ y.fst ∧ List.Chain' (fun l l' => l.fst ≠ l'.fst) (y :: l)
h : { toList := x :: y :: l, ne_one := hnot1✝, chain_ne := hchain✝ } ≠ empty
⊢ { toList := y :: l, ne_one := ⋯, chain_ne := ⋯ } ≠ empty

Tactic:
rintro ⟨rfl⟩

Result:
no goals

Proof state:
case mk.cons.cons.intro.intro.intro
ι : Type u_1
M : ι → Type u_2
inst✝ : (i : ι) → Monoid (M i)
x : (i : ι) × M i
l : List ((i : ι) × M i)
i j : ι
w' : NeWord M i j
hnot1✝ : ∀ l_1 ∈ x :: ⟨i, w'.head⟩ :: l, l_1.snd ≠ 1
hnot1 : x.snd ≠ 1 ∧ ∀ x ∈ ⟨i, w'.head⟩ :: l, x.snd ≠ 1
hchain✝ : List.Chain' (fun l l' => l.fst ≠ l'.fst) (x :: ⟨i, w'.head⟩ :: l)
hchain : x.fst ≠ ⟨i, w'.head⟩.fst ∧ List.Chain' (fun l l' => l.fst ≠ l'.fst) (⟨i, w'.head⟩ :: l)
h : { toList := x :: ⟨i, w'.head⟩ :: l, ne_one := hnot1✝, chain_ne := hchain✝ } ≠ empty
hw' : w'.toList = ⟨i, w'.head⟩ :: l
⊢ ∃ i_1 j_1 w'_1,
    w'_1.toWord.toList = { toList := x :: ⟨i, w'.head⟩ :: l, ne_one := hnot1✝, chain_ne := hchain✝ }.toList

Tactic:
refine ⟨x.1, j, append (singleton x.2 hnot1.1) hchain.1 w', ?_⟩

Result:
case mk.cons.cons.intro.intro.intro
ι : Type u_1
M : ι → Type u_2
inst✝ : (i : ι) → Monoid (M i)
x : (i : ι) × M i
l : List ((i : ι) × M i)
i j : ι
w' : NeWord M i j
hnot1✝ : ∀ l_1 ∈ x :: ⟨i, w'.head⟩ :: l, l_1.snd ≠ 1
hnot1 : x.snd ≠ 1 ∧ ∀ x ∈ ⟨i, w'.head⟩ :: l, x.snd ≠ 1
hchain✝ : List.Chain' (fun l l' => l.fst ≠ l'.fst) (x :: ⟨i, w'.head⟩ :: l)
hchain : x.fst ≠ ⟨i, w'.head⟩.fst ∧ List.Chain' (fun l l' => l.fst ≠ l'.fst) (⟨i, w'.head⟩ :: l)
h : { toList := x :: ⟨i, w'.head⟩ :: l, ne_one := hnot1✝, chain_ne := hchain✝ } ≠ empty
hw' : w'.toList = ⟨i, w'.head⟩ :: l
⊢ ((singleton x.snd ⋯).append ⋯ w').toWord.toList =
    { toList := x :: ⟨i, w'.head⟩ :: l, ne_one := hnot1✝, chain_ne := hchain✝ }.toList

Proof state:
case mk.cons
ι : Type u_1
M : ι → Type u_2
inst✝ : (i : ι) → Monoid (M i)
x : (i : ι) × M i
l : List ((i : ι) × M i)
hi :
  ∀ (hnot1 : ∀ l_1 ∈ l, l_1.snd ≠ 1) (hchain : List.Chain' (fun l l' => l.fst ≠ l'.fst) l),
    { toList := l, ne_one := hnot1, chain_ne := hchain } ≠ empty →
      ∃ i j w', w'.toWord.toList = { toList := l, ne_one := hnot1, chain_ne := hchain }.toList
hnot1 : ∀ l_1 ∈ x :: l, l_1.snd ≠ 1
hchain : List.Chain' (fun l l' => l.fst ≠ l'.fst) (x :: l)
h : { toList := x :: l, ne_one := hnot1, chain_ne := hchain } ≠ empty
⊢ ∃ i j w', w'.toWord.toList = { toList := x :: l, ne_one := hnot1, chain_ne := hchain }.toList

Tactic:
rw [List.forall_mem_cons] at hnot1

Result:
case mk.cons
ι : Type u_1
M : ι → Type u_2
inst✝ : (i : ι) → Monoid (M i)
x : (i : ι) × M i
l : List ((i : ι) × M i)
hi :
  ∀ (hnot1 : ∀ l_1 ∈ l, l_1.snd ≠ 1) (hchain : List.Chain' (fun l l' => l.fst ≠ l'.fst) l),
    { toList := l, ne_one := hnot1, chain_ne := hchain } ≠ empty →
      ∃ i j w', w'.toWord.toList = { toList := l, ne_one := hnot1, chain_ne := hchain }.toList
hnot1✝ : ∀ l_1 ∈ x :: l, l_1.snd ≠ 1
hnot1 : x.snd ≠ 1 ∧ ∀ x ∈ l, x.snd ≠ 1
hchain : List.Chain' (fun l l' => l.fst ≠ l'.fst) (x :: l)
h : { toList := x :: l, ne_one := hnot1✝, chain_ne := hchain } ≠ empty
⊢ ∃ i j w', w'.toWord.toList = { toList := x :: l, ne_one := hnot1✝, chain_ne := hchain }.toList

Proof state:
case intro.intro.intro.toList.h.a
ι : Type u_1
M : ι → Type u_2
inst✝ : (i : ι) → Monoid (M i)
w✝ : Word M
h✝ : w✝ ≠ empty
i j : ι
w : NeWord M i j
h : w.toWord.toList = w✝.toList
i✝ : ℕ
a✝ : (i : ι) × M i
⊢ a✝ ∈ w.toWord.toList[i✝]? ↔ a✝ ∈ w✝.toList[i✝]?

Tactic:
rw [h]

Result:
no goals

Proof state:
case mk.cons.cons
ι : Type u_1
M : ι → Type u_2
inst✝ : (i : ι) → Monoid (M i)
x y : (i : ι) × M i
l : List ((i : ι) × M i)
hi :
  ∀ (hnot1 : ∀ l_1 ∈ y :: l, l_1.snd ≠ 1) (hchain : List.Chain' (fun l l' => l.fst ≠ l'.fst) (y :: l)),
    { toList := y :: l, ne_one := hnot1, chain_ne := hchain } ≠ empty →
      ∃ i j w', w'.toWord.toList = { toList := y :: l, ne_one := hnot1, chain_ne := hchain }.toList
hnot1✝ : ∀ l_1 ∈ x :: y :: l, l_1.snd ≠ 1
hnot1 : x.snd ≠ 1 ∧ ∀ x ∈ y :: l, x.snd ≠ 1
hchain✝ : List.Chain' (fun l l' => l.fst ≠ l'.fst) (x :: y :: l)
hchain : x.fst ≠ y.fst ∧ List.Chain' (fun l l' => l.fst ≠ l'.fst) (y :: l)
h : { toList := x :: y :: l, ne_one := hnot1✝, chain_ne := hchain✝ } ≠ empty
⊢ ∃ i j w', w'.toWord.toList = { toList := x :: y :: l, ne_one := hnot1✝, chain_ne := hchain✝ }.toList

Tactic:
specialize hi hnot1.2 hchain.2 (by rintro ⟨rfl⟩)

Result:
case mk.cons.cons
ι : Type u_1
M : ι → Type u_2
inst✝ : (i : ι) → Monoid (M i)
x y : (i : ι) × M i
l : List ((i : ι) × M i)
hnot1✝ : ∀ l_1 ∈ x :: y :: l, l_1.snd ≠ 1
hnot1 : x.snd ≠ 1 ∧ ∀ x ∈ y :: l, x.snd ≠ 1
hchain✝ : List.Chain' (fun l l' => l.fst ≠ l'.fst) (x :: y :: l)
hchain : x.fst ≠ y.fst ∧ List.Chain' (fun l l' => l.fst ≠ l'.fst) (y :: l)
h : { toList := x :: y :: l, ne_one := hnot1✝, chain_ne := hchain✝ } ≠ empty
hi : ∃ i j w', w'.toWord.toList = { toList := y :: l, ne_one := ⋯, chain_ne := ⋯ }.toList
⊢ ∃ i j w', w'.toWord.toList = { toList := x :: y :: l, ne_one := hnot1✝, chain_ne := hchain✝ }.toList

Proof state:
case mk.cons.cons.intro.intro.intro
ι : Type u_1
M : ι → Type u_2
inst✝ : (i : ι) → Monoid (M i)
x : (i : ι) × M i
l : List ((i : ι) × M i)
i j : ι
w' : NeWord M i j
hnot1✝ : ∀ l_1 ∈ x :: ⟨i, w'.head⟩ :: l, l_1.snd ≠ 1
hnot1 : x.snd ≠ 1 ∧ ∀ x ∈ ⟨i, w'.head⟩ :: l, x.snd ≠ 1
hchain✝ : List.Chain' (fun l l' => l.fst ≠ l'.fst) (x :: ⟨i, w'.head⟩ :: l)
hchain : x.fst ≠ ⟨i, w'.head⟩.fst ∧ List.Chain' (fun l l' => l.fst ≠ l'.fst) (⟨i, w'.head⟩ :: l)
h : { toList := x :: ⟨i, w'.head⟩ :: l, ne_one := hnot1✝, chain_ne := hchain✝ } ≠ empty
hw' : w'.toList = ⟨i, w'.head⟩ :: l
⊢ ((singleton x.snd ⋯).append ⋯ w').toWord.toList =
    { toList := x :: ⟨i, w'.head⟩ :: l, ne_one := hnot1✝, chain_ne := hchain✝ }.toList

Tactic:
simpa [toWord] using hw'

Result:
no goals

Proof state:
ι : Type u_1
M : ι → Type u_2
inst✝ : (i : ι) → Monoid (M i)
w : Word M
h : w ≠ empty
⊢ ∃ i j w', w'.toWord = w

Tactic:
suffices ∃ (i j : _) (w' : NeWord M i j), w'.toWord.toList = w.toList by
  rcases this with ⟨i, j, w, h⟩
  refine ⟨i, j, w, ?_⟩
  ext
  rw [h]

Result:
ι : Type u_1
M : ι → Type u_2
inst✝ : (i : ι) → Monoid (M i)
w : Word M
h : w ≠ empty
⊢ ∃ i j w', w'.toWord.toList = w.toList

Proof state:
ι : Type u_1
M : ι → Type u_2
inst✝ : (i : ι) → Monoid (M i)
w : Word M
h : w ≠ empty
this : ∃ i j w', w'.toWord.toList = w.toList
⊢ ∃ i j w', w'.toWord = w

Tactic:
rcases this with ⟨i, j, w, h⟩

Result:
case intro.intro.intro
ι : Type u_1
M : ι → Type u_2
inst✝ : (i : ι) → Monoid (M i)
w✝ : Word M
h✝ : w✝ ≠ empty
i j : ι
w : NeWord M i j
h : w.toWord.toList = w✝.toList
⊢ ∃ i j w', w'.toWord = w✝