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]
  induction w using consRecOn with
  

Proof state:
case h_empty
ι : 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 : ι
⊢ ({
          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) })) }
        empty).head =
    if h : ∃ (h : empty.toList ≠ []), (List.head empty.toList h).fst = i then
      (_ : (List.head empty.toList (_ : empty.toList ≠ [])).fst = i) ▸
        (List.head empty.toList (_ : empty.toList ≠ [])).snd
    else 1

Next tactic:
| h_empty => simp