-- Lean 4 proof step from Mathlib.GroupTheory.CoprodI (goal)
Goal:
ι : Type u_1
M : ι → Type u_2
inst : (i : ι) → Monoid (M i)
inst_1 : DecidableEq ι
inst_2 : (i : ι) → DecidableEq (M i)
i j : ι
m : M i
k : ι
g : M k
tail : Word M
h1 : tail.fstIdx (M := M) ≠ some k
h2 : g ≠ 1
ih :
  Membership.mem (γ := List ((i : ι) × M i))
      (toList (M := M)
        (Pair.tail (M := M) (i := j)
          (↑(consRecOn (M := M) (motive := fun (x : Word M) ↦ { p : Pair M j // rcons (M := M) p = x }) tail
                (Subtype.mk (p := fun (p : Pair M j) ↦ rcons (M := M) p = empty (M := M))
                  (Pair.mk (M := M) 1 (empty (M := M)) ⋯) ⋯)
                fun (j_1 : ι) (m : M j_1) (w : Word M) (h1 : ¬w.fstIdx (M := M) = some j_1) (h2 : ¬m = 1)
                  (x : { p : Pair M j // rcons (M := M) p = w }) ↦
                if ij : j = j_1 then
                  Subtype.mk (p := fun (p : Pair M j) ↦ rcons (M := M) p = cons (M := M) m w h1 h2)
                    (Pair.mk (M := M) (Eq.rec (motive := fun (x : ι) (h : j_1 = x) ↦ M x) m ⋯) w ⋯) ⋯
                else
                  Subtype.mk (p := fun (p : Pair M j) ↦ rcons (M := M) p = cons (M := M) m w h1 h2)
                    (Pair.mk (M := M) 1 (cons (M := M) m w h1 h2) ⋯) ⋯) :
            Pair M j)))
      (Sigma.mk (β := fun (i : ι) ↦ M i) i m) ↔
    Sigma.mk (β := fun (i : ι) ↦ M i) i m ∈ tail.toList (M := M).tail ∨
      ¬i = j ∧ ∃ (h : ¬tail.toList (M := M) = []), tail.toList (M := M).head h = Sigma.mk (β := fun (i : ι) ↦ M i) i m
⊢ Membership.mem (γ := List ((i : ι) × M i))
      (toList (M := M)
        (Pair.tail (M := M) (i := j)
          (↑(consRecOn (M := M) (motive := fun (x : Word M) ↦ { p : Pair M j // rcons (M := M) p = x })
                (cons (M := M) g tail h1 h2)
                (Subtype.mk (p := fun (p : Pair M j) ↦ rcons (M := M) p = empty (M := M))
                  (Pair.mk (M := M) 1 (empty (M := M)) ⋯) ⋯)
                fun (j_1 : ι) (m : M j_1) (w : Word M) (h1 : ¬w.fstIdx (M := M) = some j_1) (h2 : ¬m = 1)
                  (x : { p : Pair M j // rcons (M := M) p = w }) ↦
                if ij : j = j_1 then
                  Subtype.mk (p := fun (p : Pair M j) ↦ rcons (M := M) p = cons (M := M) m w h1 h2)
                    (Pair.mk (M := M) (Eq.rec (motive := fun (x : ι) (h : j_1 = x) ↦ M x) m ⋯) w ⋯) ⋯
                else
                  Subtype.mk (p := fun (p : Pair M j) ↦ rcons (M := M) p = cons (M := M) m w h1 h2)
                    (Pair.mk (M := M) 1 (cons (M := M) m w h1 h2) ⋯) ⋯) :
            Pair M j)))
      (Sigma.mk (β := fun (i : ι) ↦ M i) i m) ↔
    Sigma.mk (β := fun (i : ι) ↦ M i) i m ∈ (cons (M := M) g tail h1 h2).toList (M := M).tail ∨
      ¬i = j ∧
        ∃ (h : ¬(cons (M := M) g tail h1 h2).toList (M := M) = []),
          (cons (M := M) g tail h1 h2).toList (M := M).head h = Sigma.mk (β := fun (i : ι) ↦ M i) i m
have cons : Membership.mem (γ := List ((i : ι) × M i))
    (toList (M := M)
      (Pair.tail (M := M) (i := j)
        (↑(if ij : j = k then
              Subtype.mk (p := fun (p : Pair M j) ↦ rcons (M := M) p = cons (M := M) g tail h1 h2)
                (Pair.mk (M := M) (Eq.rec (motive := fun (x : ι) (h : k = x) ↦ M x) g sorry) tail sorry) sorry
            else
              Subtype.mk (p := fun (p : Pair M j) ↦ rcons (M := M) p = cons (M := M) g tail h1 h2)
                (Pair.mk (M := M) 1 (cons (M := M) g tail h1 h2) sorry) sorry) :
          Pair M j)))
    (Sigma.mk (β := fun (i : ι) ↦ M i) i m) ↔
  Sigma.mk (β := fun (i : ι) ↦ M i) i m ∈ (cons (M := M) g tail h1 h2).toList (M := M).tail ∨
    ¬i = j ∧
      ∃ (h : ¬(cons (M := M) g tail h1 h2).toList (M := M) = []),
        (cons (M := M) g tail h1 h2).toList (M := M).head h = Sigma.mk (β := fun (i : ι) ↦ M i) i m
Tactic: simp only [consRecOn_cons]