-- Lean 4 proof step from Mathlib.Order.JordanHolder (goal)
Goal:
X : Type u
inst : Lattice X
inst_1 : JordanHolderLattice X
s : CompositionSeries X
x₁ x₂ y₁ y₂ : X
hsat₁ :
  @IsMaximal _ inst _
    (last (r :=
      {x : X × X |
        match (motive := X × X → Prop) x with
        | (x, y) => @IsMaximal _ inst _ x y})
      s)
    x₁
hsat₂ :
  @IsMaximal _ inst _
    (last (r :=
      {x : X × X |
        match (motive := X × X → Prop) x with
        | (x, y) => @IsMaximal _ inst _ x y})
      s)
    x₂
hsaty₁ :
  @IsMaximal _ inst _
    ((snoc (r :=
          {x : X × X |
            match (motive := X × X → Prop) x with
            | (x, y) => @IsMaximal _ inst _ x y})
          s x₁ hsat₁).last
      (r :=
      {x : X × X |
        match (motive := X × X → Prop) x with
        | (x, y) => @IsMaximal _ inst _ x y}))
    y₁
hsaty₂ :
  @IsMaximal _ inst _
    ((snoc (r :=
          {x : X × X |
            match (motive := X × X → Prop) x with
            | (x, y) => @IsMaximal _ inst _ x y})
          s x₂ hsat₂).last
      (r :=
      {x : X × X |
        match (motive := X × X → Prop) x with
        | (x, y) => @IsMaximal _ inst _ x y}))
    y₂
hr₁ :
  @Iso _ inst _
    (last (r :=
        {x : X × X |
          match (motive := X × X → Prop) x with
          | (x, y) => @IsMaximal _ inst _ x y})
        s,
      x₁)
    (x₂, y₂)
hr₂ :
  @Iso _ inst _ (x₁, y₁)
    (last (r :=
        {x : X × X |
          match (motive := X × X → Prop) x with
          | (x, y) => @IsMaximal _ inst _ x y})
        s,
      x₂)
e : Fin
    (s.length (r :=
          {x : X × X |
            match (motive := X × X → Prop) x with
            | (x, y) => @IsMaximal _ inst _ x y}) +
        1 +
      1) ≃
  Fin
    (s.length (r :=
          {x : X × X |
            match (motive := X × X → Prop) x with
            | (x, y) => @IsMaximal _ inst _ x y}) +
        1 +
      1) :=
  Equiv.swap
    (Fin.last
      (s.length (r :=
          {x : X × X |
            match (motive := X × X → Prop) x with
            | (x, y) => @IsMaximal _ inst _ x y}) +
        1))
    (Fin.castSucc
      (Fin.last
        (s.length (r :=
          {x : X × X |
            match (motive := X × X → Prop) x with
            | (x, y) => @IsMaximal _ inst _ x y}))))
h1 :
  ∀
    {i :
      Fin
        (s.length (r :=
          {x : X × X |
            match (motive := X × X → Prop) x with
            | (x, y) => @IsMaximal _ inst _ x y}))},
    i.castSucc.castSucc ≠
      Fin.castSucc
        (Fin.last
          (s.length (r :=
            {x : X × X |
              match (motive := X × X → Prop) x with
              | (x, y) => @IsMaximal _ inst _ x y})))
h2 :
  ∀
    {i :
      Fin
        (s.length (r :=
          {x : X × X |
            match (motive := X × X → Prop) x with
            | (x, y) => @IsMaximal _ inst _ x y}))},
    i.castSucc.castSucc ≠
      Fin.last
        (s.length (r :=
            {x : X × X |
              match (motive := X × X → Prop) x with
              | (x, y) => @IsMaximal _ inst _ x y}) +
          1)
i :
  Fin
    (((snoc (r :=
              {x : X × X |
                match (motive := X × X → Prop) x with
                | (x, y) => @IsMaximal _ inst _ x y})
              s x₁ hsat₁).snoc
          (r :=
          {x : X × X |
            match (motive := X × X → Prop) x with
            | (x, y) => @IsMaximal _ inst _ x y})
          y₁ hsaty₁).length
      (r :=
      {x : X × X |
        match (motive := X × X → Prop) x with
        | (x, y) => @IsMaximal _ inst _ x y}))
⊢ @Iso _ inst _
    (((snoc (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2}) s x₁ hsat₁).snoc (r :=
            {x : X × X | @IsMaximal _ inst _ x.1 x.2}) y₁ hsaty₁).toFun
        (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2})
        (Fin.castSucc
          (Fin.last
            ((snoc (r :=
                    {x : X × X |
                      match (motive := X × X → Prop) x with
                      | (x, y) => @IsMaximal _ inst _ x y})
                    s x₁ hsat₁).length
                (r :=
                {x : X × X |
                  match (motive := X × X → Prop) x with
                  | (x, y) => @IsMaximal _ inst _ x y}) +
              length (r :=
                {x : X × X |
                  match (motive := X × X → Prop) x with
                  | (x, y) => @IsMaximal _ inst _ x y})
                (RelSeries.singleton
                  {x : X × X |
                    match (motive := X × X → Prop) x with
                    | (x, y) => @IsMaximal _ inst _ x y}
                  y₁)))),
      ((snoc (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2}) s x₁ hsat₁).snoc (r :=
            {x : X × X | @IsMaximal _ inst _ x.1 x.2}) y₁ hsaty₁).toFun
        (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2})
        (Fin.succ
          (Fin.last
            ((snoc (r :=
                    {x : X × X |
                      match (motive := X × X → Prop) x with
                      | (x, y) => @IsMaximal _ inst _ x y})
                    s x₁ hsat₁).length
                (r :=
                {x : X × X |
                  match (motive := X × X → Prop) x with
                  | (x, y) => @IsMaximal _ inst _ x y}) +
              length (r :=
                {x : X × X |
                  match (motive := X × X → Prop) x with
                  | (x, y) => @IsMaximal _ inst _ x y})
                (RelSeries.singleton
                  {x : X × X |
                    match (motive := X × X → Prop) x with
                    | (x, y) => @IsMaximal _ inst _ x y}
                  y₁)))))
    (((snoc (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2}) s x₂ hsat₂).snoc (r :=
            {x : X × X | @IsMaximal _ inst _ x.1 x.2}) y₂ hsaty₂).toFun
        (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2})
        (Fin.castSucc
          ((Equiv.swap (Fin.last (s.length (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2}) + 1))
                (Fin.castSucc (Fin.last (s.length (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2})))) :
              (a : Fin ((snoc s x₁ hsat₁).snoc y₁ hsaty₁).length) → Fin ((snoc s x₂ hsat₂).snoc y₂ hsaty₂).length)
            (Fin.last
              ((snoc (r :=
                      {x : X × X |
                        match (motive := X × X → Prop) x with
                        | (x, y) => @IsMaximal _ inst _ x y})
                      s x₁ hsat₁).length
                  (r :=
                  {x : X × X |
                    match (motive := X × X → Prop) x with
                    | (x, y) => @IsMaximal _ inst _ x y}) +
                length (r :=
                  {x : X × X |
                    match (motive := X × X → Prop) x with
                    | (x, y) => @IsMaximal _ inst _ x y})
                  (RelSeries.singleton
                    {x : X × X |
                      match (motive := X × X → Prop) x with
                      | (x, y) => @IsMaximal _ inst _ x y}
                    y₁))))),
      ((snoc (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2}) s x₂ hsat₂).snoc (r :=
            {x : X × X | @IsMaximal _ inst _ x.1 x.2}) y₂ hsaty₂).toFun
        (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2})
        (Fin.succ
          ((Equiv.swap (Fin.last (s.length (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2}) + 1))
                (Fin.castSucc (Fin.last (s.length (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2})))) :
              (a : Fin ((snoc s x₁ hsat₁).snoc y₁ hsaty₁).length) → Fin ((snoc s x₂ hsat₂).snoc y₂ hsaty₂).length)
            (Fin.last
              ((snoc (r :=
                      {x : X × X |
                        match (motive := X × X → Prop) x with
                        | (x, y) => @IsMaximal _ inst _ x y})
                      s x₁ hsat₁).length
                  (r :=
                  {x : X × X |
                    match (motive := X × X → Prop) x with
                    | (x, y) => @IsMaximal _ inst _ x y}) +
                length (r :=
                  {x : X × X |
                    match (motive := X × X → Prop) x with
                    | (x, y) => @IsMaximal _ inst _ x y})
                  (RelSeries.singleton
                    {x : X × X |
                      match (motive := X × X → Prop) x with
                      | (x, y) => @IsMaximal _ inst _ x y}
                    y₁))))))
have refine_1 : @Iso _ inst _ (x₁, y₁)
  (s.toFun (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2})
      (Fin.last (s.length (r := {x : X × X | @IsMaximal _ inst _ x.1 x.2}))),
    x₂)
Tactic: erw [Equiv.swap_apply_left, snoc_castSucc,
      show (snoc s x₁ hsat₁).toFun (Fin.last _) = x₁ from last_snoc _ _ _, Fin.succ_last,
      show ((s.snoc x₁ hsat₁).snoc y₁ hsaty₁).toFun (Fin.last _) = y₁ from last_snoc _ _ _,
      snoc_castSucc, snoc_castSucc, Fin.succ_castSucc, snoc_castSucc, Fin.succ_last,
      show (s.snoc _ hsat₂).toFun (Fin.last _) = x₂ from last_snoc _ _ _]