theorem equivPair_head {i : ι} {w : Word M} :
    (equivPair i w).head =
      if h : ∃ (h : w.toList ≠ []), (w.toList.head h).1 = i
      then h.snd ▸ (w.toList.head h.1).2
      else 1 := by
  simp only [equivPair, equivPairAux]
  

Proof state:
ι : Type u_1
M : ι → Type u_2
inst✝³ : (i : ι) → Monoid (M i)
N : Type u_3
inst✝² : Monoid N
inst✝¹ : (i : ι) → DecidableEq (M i)
inst✝ : DecidableEq ι
i : ι
w : Word M
⊢ ({
          toFun := fun w =>
            ↑(consRecOn w
                { val := { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) },
                  property :=
                    (_ :
                      (if h : { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.head = 1 then
                          { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.tail
                        else
                          cons { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.head
                            { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.tail
                            (_ : fstIdx { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.tail ≠ some i)
                            h) =
                        empty) }
                fun j m w h1 h2 x =>
                if ij : i = j then
                  { val := { head := (_ : j = i) ▸ m, tail := w, fstIdx_ne := (_ : fstIdx w ≠ some i) },
                    property :=
                      (_ :
                        rcons { head := (_ : j = i) ▸ m, tail := w, fstIdx_ne := (_ : fstIdx w ≠ some i) } =
                          cons m w h1 h2) }
                else
                  { val := { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) },
                    property :=
                      (_ :
                        (if h : { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) }.head = 1 then
                            { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) }.tail
                          else
                            cons { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) }.head
                              { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) }.tail
                              (_ :
                                fstIdx { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) }.tail ≠
                                  some i)
                              h) =
                          cons m w h1 h2) }),
          invFun := rcons,
          left_inv :=
            (_ :
              Function.LeftInverse rcons fun w =>
                ↑(consRecOn w
                    { val := { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) },
                      property :=
                        (_ :
                          (if h : { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.head = 1 then
                              { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.tail
                            else
                              cons { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.head
                                { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.tail
                                (_ :
                                  fstIdx { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.tail ≠ some i)
                                h) =
                            empty) }
                    fun j m w h1 h2 x =>
                    if ij : i = j then
                      { val := { head := (_ : j = i) ▸ m, tail := w, fstIdx_ne := (_ : fstIdx w ≠ some i) },
                        property :=
                          (_ :
                            rcons { head := (_ : j = i) ▸ m, tail := w, fstIdx_ne := (_ : fstIdx w ≠ some i) } =
                              cons m w h1 h2) }
                    else
                      { val := { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) },
                        property :=
                          (_ :
                            (if h :
                                  { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) }.head =
                                    1 then
                                { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) }.tail
                              else
                                cons { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) }.head
                                  { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) }.tail
                                  (_ :
                                    fstIdx
                                        { head := 1, tail := cons m w h1 h2,
                                            fstIdx_ne := (_ : ¬some j = some i) }.tail ≠
                                      some i)
                                  h) =
                              cons m w h1 h2) })),
          right_inv :=
            (_ :
              Function.RightInverse rcons fun w =>
                ↑(consRecOn w
                    { val := { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) },
                      property :=
                        (_ :
                          (if h : { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.head = 1 then
                              { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.tail
                            else
                              cons { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.head
                                { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.tail
                                (_ :
                                  fstIdx { head := 1, tail := empty, fstIdx_ne := (_ : ¬none = some i) }.tail ≠ some i)
                                h) =
                            empty) }
                    fun j m w h1 h2 x =>
                    if ij : i = j then
                      { val := { head := (_ : j = i) ▸ m, tail := w, fstIdx_ne := (_ : fstIdx w ≠ some i) },
                        property :=
                          (_ :
                            rcons { head := (_ : j = i) ▸ m, tail := w, fstIdx_ne := (_ : fstIdx w ≠ some i) } =
                              cons m w h1 h2) }
                    else
                      { val := { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) },
                        property :=
                          (_ :
                            (if h :
                                  { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) }.head =
                                    1 then
                                { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) }.tail
                              else
                                cons { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) }.head
                                  { head := 1, tail := cons m w h1 h2, fstIdx_ne := (_ : ¬some j = some i) }.tail
                                  (_ :
                                    fstIdx
                                        { head := 1, tail := cons m w h1 h2,
                                            fstIdx_ne := (_ : ¬some j = some i) }.tail ≠
                                      some i)
                                  h) =
                              cons m w h1 h2) })) }
        w).head =
    if h : ∃ (h : w.toList ≠ []), (List.head w.toList h).fst = i then
      (_ : (List.head w.toList (_ : w.toList ≠ [])).fst = i) ▸ (List.head w.toList (_ : w.toList ≠ [])).snd
    else 1

Next tactic:
induction w using consRecOn with
  | h_empty => simp
  | h_cons head =>
    by_cases hi : i = head
    · subst hi; simp
    · simp [hi, Ne.symm hi]