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
  | h_empty => simp
  | h_cons head =>
    

Proof state:
case h_cons
ι : 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 head : ι
m✝ : M head
w✝ : Word M
h1✝ : fstIdx w✝ ≠ some head
h2✝ : m✝ ≠ 1
a✝ :
  ({
          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
⊢ ({
          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) })) }
        (cons m✝ w✝ h1✝ h2✝)).head =
    if h : ∃ (h : (cons m✝ w✝ h1✝ h2✝).toList ≠ []), (List.head (cons m✝ w✝ h1✝ h2✝).toList h).fst = i then
      (_ : (List.head (cons m✝ w✝ h1✝ h2✝).toList (_ : (cons m✝ w✝ h1✝ h2✝).toList ≠ [])).fst = i) ▸
        (List.head (cons m✝ w✝ h1✝ h2✝).toList (_ : (cons m✝ w✝ h1✝ h2✝).toList ≠ [])).snd
    else 1

Next tactic:
by_cases hi : i = head