-- Lean 4 proof step from Mathlib.RingTheory.Length (goal)
Goal:
R : Type u_1
M : Type u_2
inst : Ring R
inst_1 : AddCommGroup M
inst_2 : Module R M
N : Type u_3
P : Type u_4
inst_3 : AddCommGroup N
inst_4 : AddCommGroup P
inst_5 : Module R N
inst_6 : Module R P
f : N →ₗ[R] M
g : M →ₗ[R] P
hf : Function.Injective.{u_3 + 1, u_2 + 1} (α := N) (β := M) (⇑f : (a : N) → M)
hg : Function.Surjective.{u_2 + 1, u_4 + 1} (α := M) (β := P) (⇑g : (a : M) → P)
H : Function.Exact.{u_3, u_2, u_4} (M := N) (N := M) (P := P) (⇑f : (a : N) → M) (⇑g : (a : M) → P)
hP : IsFiniteLength R P
hN : IsFiniteLength R N
s : CompositionSeries (Submodule R P)
hs₁ :
  RelSeries.head (r :=
      {x : Submodule R P × Submodule R P |
        match (motive := Submodule R P × Submodule R P → Prop) x with
        | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y})
      s =
    ⊥
hs₂ :
  RelSeries.last (r :=
      {x : Submodule R P × Submodule R P |
        match (motive := Submodule R P × Submodule R P → Prop) x with
        | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y})
      s =
    ⊤
t : CompositionSeries (Submodule R N)
ht₁ :
  RelSeries.head (r :=
      {x : Submodule R N × Submodule R N |
        match (motive := Submodule R N × Submodule R N → Prop) x with
        | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y})
      t =
    ⊥
ht₂ :
  RelSeries.last (r :=
      {x : Submodule R N × Submodule R N |
        match (motive := Submodule R N × Submodule R N → Prop) x with
        | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y})
      t =
    ⊤
s' : CompositionSeries (Submodule R M) :=
  RelSeries.map (r :=
    {x : Submodule R P × Submodule R P |
      match (motive := Submodule R P × Submodule R P → Prop) x with
      | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y})
    (s :=
    {x : Submodule R M × Submodule R M |
      match (motive := Submodule R M × Submodule R M → Prop) x with
      | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y})
    s
    (RelHom.mk (r := fun (x1 x2 : Submodule R P) ↦
      Membership.mem (γ := SetRel (Submodule R P) (Submodule R P))
        {x : Submodule R P × Submodule R P |
          match (motive := Submodule R P × Submodule R P → Prop) x with
          | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y}
        (x1, x2))
      (s := fun (x1 x2 : Submodule R M) ↦
      Membership.mem (γ := SetRel (Submodule R M) (Submodule R M))
        {x : Submodule R M × Submodule R M |
          match (motive := Submodule R M × Submodule R M → Prop) x with
          | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y}
        (x1, x2))
      (Submodule.comap g) ⋯)
t' : CompositionSeries (Submodule R M) :=
  RelSeries.map (r :=
    {x : Submodule R N × Submodule R N |
      match (motive := Submodule R N × Submodule R N → Prop) x with
      | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y})
    (s :=
    {x : Submodule R M × Submodule R M |
      match (motive := Submodule R M × Submodule R M → Prop) x with
      | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y})
    t
    (RelHom.mk (r := fun (x1 x2 : Submodule R N) ↦
      Membership.mem (γ := SetRel (Submodule R N) (Submodule R N))
        {x : Submodule R N × Submodule R N |
          match (motive := Submodule R N × Submodule R N → Prop) x with
          | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y}
        (x1, x2))
      (s := fun (x1 x2 : Submodule R M) ↦
      Membership.mem (γ := SetRel (Submodule R M) (Submodule R M))
        {x : Submodule R M × Submodule R M |
          match (motive := Submodule R M × Submodule R M → Prop) x with
          | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y}
        (x1, x2))
      (Submodule.map f) ⋯)
hfg : Submodule.map f ⊤ = Submodule.comap g ⊥
r : RelSeries (α := Submodule R M)
  {x : Submodule R M × Submodule R M |
    match (motive := Submodule R M × Submodule R M → Prop) x with
    | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y} :=
  RelSeries.smash (r :=
    {x : Submodule R M × Submodule R M |
      match (motive := Submodule R M × Submodule R M → Prop) x with
      | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y})
    t' s' ⋯
pos pos₁ :
  (↑(r.length (r :=
          {x : Submodule R M × Submodule R M |
            @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x.1 x.2})) :
      ℕ∞) =
    HAdd.hAdd (α := ℕ∞)
      (↑(t.length (r :=
            {x : Submodule R N × Submodule R N |
              @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x.1 x.2})) :
        ℕ∞)
      (↑(s.length (r :=
            {x : Submodule R P × Submodule R P |
              @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x.1 x.2})) :
        ℕ∞)
pos₂ :
  (↑((RelSeries.smash (r :=
              {x : Submodule R M × Submodule R M |
                @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x.1 x.2})
              t' s' ⋯).length
          (r :=
          {x : Submodule R M × Submodule R M |
            @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x.1 x.2})) :
      ℕ∞) =
    HAdd.hAdd (α := ℕ∞)
      (↑(t.length (r :=
            {x : Submodule R N × Submodule R N |
              @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x.1 x.2})) :
        ℕ∞)
      (↑(s.length (r :=
            {x : Submodule R P × Submodule R P |
              @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x.1 x.2})) :
        ℕ∞)
⊢ (↑(r.length (r :=
          {x : Submodule R M × Submodule R M |
            match (motive := Submodule R M × Submodule R M → Prop) x with
            | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y})) :
      ℕ∞) =
    HAdd.hAdd (α := ℕ∞)
      (↑(t.length (r :=
            {x : Submodule R N × Submodule R N |
              match (motive := Submodule R N × Submodule R N → Prop) x with
              | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y})) :
        ℕ∞)
      (↑(s.length (r :=
            {x : Submodule R P × Submodule R P |
              match (motive := Submodule R P × Submodule R P → Prop) x with
              | (x, y) => @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x y})) :
        ℕ∞)
have pos₃ : (↑(t'.length (r :=
          {x : Submodule R M × Submodule R M |
            @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x.1 x.2}) +
        s'.length (r :=
          {x : Submodule R M × Submodule R M |
            @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x.1 x.2})) :
    ℕ∞) =
  HAdd.hAdd (α := ℕ∞)
    (↑(t.length (r :=
          {x : Submodule R N × Submodule R N |
            @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x.1 x.2})) :
      ℕ∞)
    (↑(s.length (r :=
          {x : Submodule R P × Submodule R P |
            @JordanHolderLattice.IsMaximal _ ConditionallyCompleteLattice.toLattice _ x.1 x.2})) :
      ℕ∞)
Tactic: simp_rw [r, RelSeries.smash_length, Nat.cast_add, s', t', RelSeries.map_length]