l3lab/ntp-mathlib huggingface dataset:
/-- Two `CompositionSeries` are equal if they have the same elements. See also `ext_fun`. -/
@[ext]
theorem ext {s₁ s₂ : CompositionSeries X} (h : ∀ x, x ∈ s₁ ↔ x ∈ s₂) : s₁ = s₂ :=
  toList_injective <|
    List.eq_of_perm_of_sorted
      (by
        classical
        exact List.perm_of_nodup_nodup_toFinset_eq s₁.toList_nodup s₂.toList_nodup
          (Finset.ext <| by 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s₁ s₂ : CompositionSeries X
h : ∀ (x : X), x ∈ s₁ ↔ x ∈ s₂
⊢ ∀ (a : X), a ∈ List.toFinset (toList s₁) ↔ a ∈ List.toFinset (toList s₂)

Next tactic:
simp [*]
/-- Remove the largest element from a `CompositionSeries`. If the series `s`
has length zero, then `s.eraseTop = s` -/
@[simps]
def eraseTop (s : CompositionSeries X) : CompositionSeries X where
  length := s.length - 1
  series i := s ⟨i, lt_of_lt_of_le i.2 (Nat.succ_le_succ tsub_le_self)⟩
  step' i := by
    

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
i : Fin (s.length - 1)
⊢ IsMaximal ((fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }) (Fin.castSucc i))
    ((fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }) (Fin.succ i))

Next tactic:
have := s.step ⟨i, lt_of_lt_of_le i.2 tsub_le_self⟩
/-- Remove the largest element from a `CompositionSeries`. If the series `s`
has length zero, then `s.eraseTop = s` -/
@[simps]
def eraseTop (s : CompositionSeries X) : CompositionSeries X where
  length := s.length - 1
  series i := s ⟨i, lt_of_lt_of_le i.2 (Nat.succ_le_succ tsub_le_self)⟩
  step' i := by
    have := s.step ⟨i, lt_of_lt_of_le i.2 tsub_le_self⟩
    

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
i : Fin (s.length - 1)
this :
  IsMaximal (series s (Fin.castSucc { val := ↑i, isLt := (_ : ↑i < s.length) }))
    (series s (Fin.succ { val := ↑i, isLt := (_ : ↑i < s.length) }))
⊢ IsMaximal ((fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }) (Fin.castSucc i))
    ((fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }) (Fin.succ i))

Next tactic:
cases i
/-- Remove the largest element from a `CompositionSeries`. If the series `s`
has length zero, then `s.eraseTop = s` -/
@[simps]
def eraseTop (s : CompositionSeries X) : CompositionSeries X where
  length := s.length - 1
  series i := s ⟨i, lt_of_lt_of_le i.2 (Nat.succ_le_succ tsub_le_self)⟩
  step' i := by
    have := s.step ⟨i, lt_of_lt_of_le i.2 tsub_le_self⟩
    cases i
    

Proof state:
case mk
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
val✝ : ℕ
isLt✝ : val✝ < s.length - 1
this :
  IsMaximal
    (series s
      (Fin.castSucc
        { val := ↑{ val := val✝, isLt := isLt✝ }, isLt := (_ : ↑{ val := val✝, isLt := isLt✝ } < s.length) }))
    (series s
      (Fin.succ { val := ↑{ val := val✝, isLt := isLt✝ }, isLt := (_ : ↑{ val := val✝, isLt := isLt✝ } < s.length) }))
⊢ IsMaximal
    ((fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }) (Fin.castSucc { val := val✝, isLt := isLt✝ }))
    ((fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }) (Fin.succ { val := val✝, isLt := isLt✝ }))

Next tactic:
exact this
theorem top_eraseTop (s : CompositionSeries X) :
    s.eraseTop.top = s ⟨s.length - 1, lt_of_le_of_lt tsub_le_self (Nat.lt_succ_self _)⟩ :=
  show s _ = s _ from
    congr_arg s
      (by
        

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
⊢ { val := ↑(Fin.last (eraseTop s).length), isLt := (_ : ↑(Fin.last (eraseTop s).length) < s.length + 1) } =
    { val := s.length - 1, isLt := (_ : s.length - 1 < s.length + 1) }

Next tactic:
ext
theorem top_eraseTop (s : CompositionSeries X) :
    s.eraseTop.top = s ⟨s.length - 1, lt_of_le_of_lt tsub_le_self (Nat.lt_succ_self _)⟩ :=
  show s _ = s _ from
    congr_arg s
      (by
        ext
        

Proof state:
case h
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
⊢ ↑{ val := ↑(Fin.last (eraseTop s).length), isLt := (_ : ↑(Fin.last (eraseTop s).length) < s.length + 1) } =
    ↑{ val := s.length - 1, isLt := (_ : s.length - 1 < s.length + 1) }

Next tactic:
simp only [eraseTop_length, Fin.val_last, Fin.coe_castSucc, Fin.coe_ofNat_eq_mod,
          Fin.val_mk]
theorem eraseTop_top_le (s : CompositionSeries X) : s.eraseTop.top ≤ s.top := by
  

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
⊢ top (eraseTop s) ≤ top s

Next tactic:
simp [eraseTop, top, s.strictMono.le_iff_le, Fin.le_iff_val_le_val, tsub_le_self]
theorem mem_eraseTop_of_ne_of_mem {s : CompositionSeries X} {x : X} (hx : x ≠ s.top) (hxs : x ∈ s) :
    x ∈ s.eraseTop := by
  

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
x : X
hx : x ≠ top s
hxs : x ∈ s
⊢ x ∈ eraseTop s

Next tactic:
rcases hxs with ⟨i, rfl⟩
theorem mem_eraseTop_of_ne_of_mem {s : CompositionSeries X} {x : X} (hx : x ≠ s.top) (hxs : x ∈ s) :
    x ∈ s.eraseTop := by
  rcases hxs with ⟨i, rfl⟩
  

Proof state:
case intro
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
i : Fin (s.length + 1)
hx : series s i ≠ top s
⊢ series s i ∈ eraseTop s

Next tactic:
have hi : (i : ℕ) < (s.length - 1).succ := by
    conv_rhs => rw [← Nat.succ_sub (length_pos_of_mem_ne ⟨i, rfl⟩ s.top_mem hx),
      Nat.add_one_sub_one]
    exact lt_of_le_of_ne (Nat.le_of_lt_succ i.2) (by simpa [top, s.inj, Fin.ext_iff] using hx)
theorem mem_eraseTop_of_ne_of_mem {s : CompositionSeries X} {x : X} (hx : x ≠ s.top) (hxs : x ∈ s) :
    x ∈ s.eraseTop := by
  rcases hxs with ⟨i, rfl⟩
  have hi : (i : ℕ) < (s.length - 1).succ := by
    

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
i : Fin (s.length + 1)
hx : series s i ≠ top s
⊢ ↑i < Nat.succ (s.length - 1)

Next tactic:
conv_rhs => rw [← Nat.succ_sub (length_pos_of_mem_ne ⟨i, rfl⟩ s.top_mem hx),
      Nat.add_one_sub_one]
theorem mem_eraseTop_of_ne_of_mem {s : CompositionSeries X} {x : X} (hx : x ≠ s.top) (hxs : x ∈ s) :
    x ∈ s.eraseTop := by
  rcases hxs with ⟨i, rfl⟩
  have hi : (i : ℕ) < (s.length - 1).succ := by
    conv_rhs => 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
i : Fin (s.length + 1)
hx : series s i ≠ top s
| Nat.succ (s.length - 1)

Next tactic:
rw [← Nat.succ_sub (length_pos_of_mem_ne ⟨i, rfl⟩ s.top_mem hx),
      Nat.add_one_sub_one]
theorem mem_eraseTop_of_ne_of_mem {s : CompositionSeries X} {x : X} (hx : x ≠ s.top) (hxs : x ∈ s) :
    x ∈ s.eraseTop := by
  rcases hxs with ⟨i, rfl⟩
  have hi : (i : ℕ) < (s.length - 1).succ := by
    conv_rhs => rw [← Nat.succ_sub (length_pos_of_mem_ne ⟨i, rfl⟩ s.top_mem hx),
      Nat.add_one_sub_one]
    

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
i : Fin (s.length + 1)
hx : series s i ≠ top s
⊢ ↑i < s.length

Next tactic:
exact lt_of_le_of_ne (Nat.le_of_lt_succ i.2) (by simpa [top, s.inj, Fin.ext_iff] using hx)
theorem mem_eraseTop_of_ne_of_mem {s : CompositionSeries X} {x : X} (hx : x ≠ s.top) (hxs : x ∈ s) :
    x ∈ s.eraseTop := by
  rcases hxs with ⟨i, rfl⟩
  have hi : (i : ℕ) < (s.length - 1).succ := by
    conv_rhs => rw [← Nat.succ_sub (length_pos_of_mem_ne ⟨i, rfl⟩ s.top_mem hx),
      Nat.add_one_sub_one]
    exact lt_of_le_of_ne (Nat.le_of_lt_succ i.2) (by 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
i : Fin (s.length + 1)
hx : series s i ≠ top s
⊢ ↑i ≠ s.length

Next tactic:
simpa [top, s.inj, Fin.ext_iff] using hx
theorem mem_eraseTop_of_ne_of_mem {s : CompositionSeries X} {x : X} (hx : x ≠ s.top) (hxs : x ∈ s) :
    x ∈ s.eraseTop := by
  rcases hxs with ⟨i, rfl⟩
  have hi : (i : ℕ) < (s.length - 1).succ := by
    conv_rhs => rw [← Nat.succ_sub (length_pos_of_mem_ne ⟨i, rfl⟩ s.top_mem hx),
      Nat.add_one_sub_one]
    exact lt_of_le_of_ne (Nat.le_of_lt_succ i.2) (by simpa [top, s.inj, Fin.ext_iff] using hx)
  

Proof state:
case intro
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
i : Fin (s.length + 1)
hx : series s i ≠ top s
hi : ↑i < Nat.succ (s.length - 1)
⊢ series s i ∈ eraseTop s

Next tactic:
refine' ⟨Fin.castSucc (n := s.length + 1) i, _⟩
theorem mem_eraseTop_of_ne_of_mem {s : CompositionSeries X} {x : X} (hx : x ≠ s.top) (hxs : x ∈ s) :
    x ∈ s.eraseTop := by
  rcases hxs with ⟨i, rfl⟩
  have hi : (i : ℕ) < (s.length - 1).succ := by
    conv_rhs => rw [← Nat.succ_sub (length_pos_of_mem_ne ⟨i, rfl⟩ s.top_mem hx),
      Nat.add_one_sub_one]
    exact lt_of_le_of_ne (Nat.le_of_lt_succ i.2) (by simpa [top, s.inj, Fin.ext_iff] using hx)
  refine' ⟨Fin.castSucc (n := s.length + 1) i, _⟩
  

Proof state:
case intro
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
i : Fin (s.length + 1)
hx : series s i ≠ top s
hi : ↑i < Nat.succ (s.length - 1)
⊢ series (eraseTop s) ↑↑(Fin.castSucc i) = series s i

Next tactic:
simp [Fin.ext_iff, Nat.mod_eq_of_lt hi]
theorem mem_eraseTop {s : CompositionSeries X} {x : X} (h : 0 < s.length) :
    x ∈ s.eraseTop ↔ x ≠ s.top ∧ x ∈ s := by
  

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
x : X
h : 0 < s.length
⊢ x ∈ eraseTop s ↔ x ≠ top s ∧ x ∈ s

Next tactic:
simp only [mem_def]
theorem mem_eraseTop {s : CompositionSeries X} {x : X} (h : 0 < s.length) :
    x ∈ s.eraseTop ↔ x ≠ s.top ∧ x ∈ s := by
  simp only [mem_def]
  

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
x : X
h : 0 < s.length
⊢ x ∈ range (eraseTop s).series ↔ x ≠ top s ∧ x ∈ range s.series

Next tactic:
dsimp only [eraseTop]
theorem mem_eraseTop {s : CompositionSeries X} {x : X} (h : 0 < s.length) :
    x ∈ s.eraseTop ↔ x ≠ s.top ∧ x ∈ s := by
  simp only [mem_def]
  dsimp only [eraseTop]
  

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
x : X
h : 0 < s.length
⊢ (x ∈ range fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }) ↔ x ≠ top s ∧ x ∈ range s.series

Next tactic:
constructor
theorem mem_eraseTop {s : CompositionSeries X} {x : X} (h : 0 < s.length) :
    x ∈ s.eraseTop ↔ x ≠ s.top ∧ x ∈ s := by
  simp only [mem_def]
  dsimp only [eraseTop]
  constructor
  · 

Proof state:
case mp
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
x : X
h : 0 < s.length
⊢ (x ∈ range fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }) → x ≠ top s ∧ x ∈ range s.series

Next tactic:
rintro ⟨i, rfl⟩
theorem mem_eraseTop {s : CompositionSeries X} {x : X} (h : 0 < s.length) :
    x ∈ s.eraseTop ↔ x ≠ s.top ∧ x ∈ s := by
  simp only [mem_def]
  dsimp only [eraseTop]
  constructor
  · rintro ⟨i, rfl⟩
    

Proof state:
case mp.intro
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
i : Fin (s.length - 1 + 1)
⊢ (fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }) i ≠ top s ∧
    (fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }) i ∈ range s.series

Next tactic:
have hi : (i : ℕ) < s.length := by
      conv_rhs => rw [← Nat.add_one_sub_one s.length, Nat.succ_sub h]
      exact i.2
theorem mem_eraseTop {s : CompositionSeries X} {x : X} (h : 0 < s.length) :
    x ∈ s.eraseTop ↔ x ≠ s.top ∧ x ∈ s := by
  simp only [mem_def]
  dsimp only [eraseTop]
  constructor
  · rintro ⟨i, rfl⟩
    have hi : (i : ℕ) < s.length := by
      

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
i : Fin (s.length - 1 + 1)
⊢ ↑i < s.length

Next tactic:
conv_rhs => rw [← Nat.add_one_sub_one s.length, Nat.succ_sub h]
theorem mem_eraseTop {s : CompositionSeries X} {x : X} (h : 0 < s.length) :
    x ∈ s.eraseTop ↔ x ≠ s.top ∧ x ∈ s := by
  simp only [mem_def]
  dsimp only [eraseTop]
  constructor
  · rintro ⟨i, rfl⟩
    have hi : (i : ℕ) < s.length := by
      conv_rhs => 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
i : Fin (s.length - 1 + 1)
| s.length

Next tactic:
rw [← Nat.add_one_sub_one s.length, Nat.succ_sub h]
theorem mem_eraseTop {s : CompositionSeries X} {x : X} (h : 0 < s.length) :
    x ∈ s.eraseTop ↔ x ≠ s.top ∧ x ∈ s := by
  simp only [mem_def]
  dsimp only [eraseTop]
  constructor
  · rintro ⟨i, rfl⟩
    have hi : (i : ℕ) < s.length := by
      conv_rhs => rw [← Nat.add_one_sub_one s.length, Nat.succ_sub h]
      

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
i : Fin (s.length - 1 + 1)
⊢ ↑i < Nat.succ (s.length - Nat.succ 0)

Next tactic:
exact i.2
theorem mem_eraseTop {s : CompositionSeries X} {x : X} (h : 0 < s.length) :
    x ∈ s.eraseTop ↔ x ≠ s.top ∧ x ∈ s := by
  simp only [mem_def]
  dsimp only [eraseTop]
  constructor
  · rintro ⟨i, rfl⟩
    have hi : (i : ℕ) < s.length := by
      conv_rhs => rw [← Nat.add_one_sub_one s.length, Nat.succ_sub h]
      exact i.2
    -- Porting note: Was `simp [top, Fin.ext_iff, ne_of_lt hi]`.
    

Proof state:
case mp.intro
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
i : Fin (s.length - 1 + 1)
hi : ↑i < s.length
⊢ (fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }) i ≠ top s ∧
    (fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }) i ∈ range s.series

Next tactic:
simp [top, Fin.ext_iff, ne_of_lt hi, -Set.mem_range, Set.mem_range_self]
theorem mem_eraseTop {s : CompositionSeries X} {x : X} (h : 0 < s.length) :
    x ∈ s.eraseTop ↔ x ≠ s.top ∧ x ∈ s := by
  simp only [mem_def]
  dsimp only [eraseTop]
  constructor
  · rintro ⟨i, rfl⟩
    have hi : (i : ℕ) < s.length := by
      conv_rhs => rw [← Nat.add_one_sub_one s.length, Nat.succ_sub h]
      exact i.2
    -- Porting note: Was `simp [top, Fin.ext_iff, ne_of_lt hi]`.
    simp [top, Fin.ext_iff, ne_of_lt hi, -Set.mem_range, Set.mem_range_self]
  · 

Proof state:
case mpr
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
x : X
h : 0 < s.length
⊢ x ≠ top s ∧ x ∈ range s.series → x ∈ range fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }

Next tactic:
intro h
theorem mem_eraseTop {s : CompositionSeries X} {x : X} (h : 0 < s.length) :
    x ∈ s.eraseTop ↔ x ≠ s.top ∧ x ∈ s := by
  simp only [mem_def]
  dsimp only [eraseTop]
  constructor
  · rintro ⟨i, rfl⟩
    have hi : (i : ℕ) < s.length := by
      conv_rhs => rw [← Nat.add_one_sub_one s.length, Nat.succ_sub h]
      exact i.2
    -- Porting note: Was `simp [top, Fin.ext_iff, ne_of_lt hi]`.
    simp [top, Fin.ext_iff, ne_of_lt hi, -Set.mem_range, Set.mem_range_self]
  · intro h
    

Proof state:
case mpr
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
x : X
h✝ : 0 < s.length
h : x ≠ top s ∧ x ∈ range s.series
⊢ x ∈ range fun i => series s { val := ↑i, isLt := (_ : ↑i < s.length + 1) }

Next tactic:
exact mem_eraseTop_of_ne_of_mem h.1 h.2
theorem isMaximal_eraseTop_top {s : CompositionSeries X} (h : 0 < s.length) :
    IsMaximal s.eraseTop.top s.top := by
  

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
⊢ IsMaximal (top (eraseTop s)) (top s)

Next tactic:
have : s.length - 1 + 1 = s.length := by
    conv_rhs => rw [← Nat.add_one_sub_one s.length]; rw [Nat.succ_sub h]
theorem isMaximal_eraseTop_top {s : CompositionSeries X} (h : 0 < s.length) :
    IsMaximal s.eraseTop.top s.top := by
  have : s.length - 1 + 1 = s.length := by
    

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
⊢ s.length - 1 + 1 = s.length

Next tactic:
conv_rhs => rw [← Nat.add_one_sub_one s.length]; rw [Nat.succ_sub h]
theorem isMaximal_eraseTop_top {s : CompositionSeries X} (h : 0 < s.length) :
    IsMaximal s.eraseTop.top s.top := by
  have : s.length - 1 + 1 = s.length := by
    conv_rhs => 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
| s.length

Next tactic:
rw [← Nat.add_one_sub_one s.length]; rw [Nat.succ_sub h]
theorem isMaximal_eraseTop_top {s : CompositionSeries X} (h : 0 < s.length) :
    IsMaximal s.eraseTop.top s.top := by
  have : s.length - 1 + 1 = s.length := by
    conv_rhs => 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
| s.length

Next tactic:
rw [← Nat.add_one_sub_one s.length]
theorem isMaximal_eraseTop_top {s : CompositionSeries X} (h : 0 < s.length) :
    IsMaximal s.eraseTop.top s.top := by
  have : s.length - 1 + 1 = s.length := by
    conv_rhs => rw [← Nat.add_one_sub_one s.length]; 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
| s.length + 1 - 1

Next tactic:
rw [Nat.succ_sub h]
theorem isMaximal_eraseTop_top {s : CompositionSeries X} (h : 0 < s.length) :
    IsMaximal s.eraseTop.top s.top := by
  have : s.length - 1 + 1 = s.length := by
    conv_rhs => rw [← Nat.add_one_sub_one s.length]; rw [Nat.succ_sub h]
  

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
this : s.length - 1 + 1 = s.length
⊢ IsMaximal (top (eraseTop s)) (top s)

Next tactic:
rw [top_eraseTop, top]
theorem isMaximal_eraseTop_top {s : CompositionSeries X} (h : 0 < s.length) :
    IsMaximal s.eraseTop.top s.top := by
  have : s.length - 1 + 1 = s.length := by
    conv_rhs => rw [← Nat.add_one_sub_one s.length]; rw [Nat.succ_sub h]
  rw [top_eraseTop, top]
  

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
this : s.length - 1 + 1 = s.length
⊢ IsMaximal (series s { val := s.length - 1, isLt := (_ : s.length - 1 < s.length + 1) }) (series s (Fin.last s.length))

Next tactic:
convert s.step ⟨s.length - 1, Nat.sub_lt h zero_lt_one⟩
theorem isMaximal_eraseTop_top {s : CompositionSeries X} (h : 0 < s.length) :
    IsMaximal s.eraseTop.top s.top := by
  have : s.length - 1 + 1 = s.length := by
    conv_rhs => rw [← Nat.add_one_sub_one s.length]; rw [Nat.succ_sub h]
  rw [top_eraseTop, top]
  convert s.step ⟨s.length - 1, Nat.sub_lt h zero_lt_one⟩; 

Proof state:
case h.e'_5.h.e'_5
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
this : s.length - 1 + 1 = s.length
⊢ Fin.last s.length = Fin.succ { val := s.length - 1, isLt := (_ : s.length - 1 < s.length) }

Next tactic:
ext
theorem isMaximal_eraseTop_top {s : CompositionSeries X} (h : 0 < s.length) :
    IsMaximal s.eraseTop.top s.top := by
  have : s.length - 1 + 1 = s.length := by
    conv_rhs => rw [← Nat.add_one_sub_one s.length]; rw [Nat.succ_sub h]
  rw [top_eraseTop, top]
  convert s.step ⟨s.length - 1, Nat.sub_lt h zero_lt_one⟩; ext; 

Proof state:
case h.e'_5.h.e'_5.h
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h : 0 < s.length
this : s.length - 1 + 1 = s.length
⊢ ↑(Fin.last s.length) = ↑(Fin.succ { val := s.length - 1, isLt := (_ : s.length - 1 < s.length) })

Next tactic:
simp [this]
theorem append_castAdd_aux (i : Fin m) :
    Matrix.vecAppend (Nat.add_succ _ _).symm (a ∘ Fin.castSucc) b
      (Fin.castSucc <| Fin.castAdd n i) =
      a (Fin.castSucc i) := by
  

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
α : Type u_1
m n : ℕ
a : Fin (Nat.succ m) → α
b : Fin (Nat.succ n) → α
i : Fin m
⊢ Matrix.vecAppend (_ : Nat.succ (m + n) = m + Nat.succ n) (a ∘ Fin.castSucc) b (Fin.castSucc (Fin.castAdd n i)) =
    a (Fin.castSucc i)

Next tactic:
cases i
theorem append_castAdd_aux (i : Fin m) :
    Matrix.vecAppend (Nat.add_succ _ _).symm (a ∘ Fin.castSucc) b
      (Fin.castSucc <| Fin.castAdd n i) =
      a (Fin.castSucc i) := by
  cases i
  

Proof state:
case mk
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
α : Type u_1
m n : ℕ
a : Fin (Nat.succ m) → α
b : Fin (Nat.succ n) → α
val✝ : ℕ
isLt✝ : val✝ < m
⊢ Matrix.vecAppend (_ : Nat.succ (m + n) = m + Nat.succ n) (a ∘ Fin.castSucc) b
      (Fin.castSucc (Fin.castAdd n { val := val✝, isLt := isLt✝ })) =
    a (Fin.castSucc { val := val✝, isLt := isLt✝ })

Next tactic:
simp [Matrix.vecAppend_eq_ite, *]
theorem append_succ_castAdd_aux (i : Fin m) (h : a (Fin.last _) = b 0) :
    Matrix.vecAppend (Nat.add_succ _ _).symm (a ∘ Fin.castSucc) b (Fin.castAdd n i).succ =
      a i.succ := by
  

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
α : Type u_1
m n : ℕ
a : Fin (Nat.succ m) → α
b : Fin (Nat.succ n) → α
i : Fin m
h : a (Fin.last m) = b 0
⊢ Matrix.vecAppend (_ : Nat.succ (m + n) = m + Nat.succ n) (a ∘ Fin.castSucc) b (Fin.succ (Fin.castAdd n i)) =
    a (Fin.succ i)

Next tactic:
cases' i with i hi
theorem append_succ_castAdd_aux (i : Fin m) (h : a (Fin.last _) = b 0) :
    Matrix.vecAppend (Nat.add_succ _ _).symm (a ∘ Fin.castSucc) b (Fin.castAdd n i).succ =
      a i.succ := by
  cases' i with i hi
  

Proof state:
case mk
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
α : Type u_1
m n : ℕ
a : Fin (Nat.succ m) → α
b : Fin (Nat.succ n) → α
h : a (Fin.last m) = b 0
i : ℕ
hi : i < m
⊢ Matrix.vecAppend (_ : Nat.succ (m + n) = m + Nat.succ n) (a ∘ Fin.castSucc) b
      (Fin.succ (Fin.castAdd n { val := i, isLt := hi })) =
    a (Fin.succ { val := i, isLt := hi })

Next tactic:
simp only [Matrix.vecAppend_eq_ite, hi, Fin.succ_mk, Function.comp_apply, Fin.castSucc_mk,
    Fin.val_mk, Fin.castAdd_mk]
theorem append_succ_castAdd_aux (i : Fin m) (h : a (Fin.last _) = b 0) :
    Matrix.vecAppend (Nat.add_succ _ _).symm (a ∘ Fin.castSucc) b (Fin.castAdd n i).succ =
      a i.succ := by
  cases' i with i hi
  simp only [Matrix.vecAppend_eq_ite, hi, Fin.succ_mk, Function.comp_apply, Fin.castSucc_mk,
    Fin.val_mk, Fin.castAdd_mk]
  

Proof state:
case mk
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
α : Type u_1
m n : ℕ
a : Fin (Nat.succ m) → α
b : Fin (Nat.succ n) → α
h : a (Fin.last m) = b 0
i : ℕ
hi : i < m
⊢ (if h : i + 1 < m then a { val := i + 1, isLt := (_ : i + 1 < Nat.succ m) }
    else
      b
        { val := i + 1 - m,
          isLt := (_ : ↑{ val := i + 1, isLt := (_ : Nat.succ i < Nat.succ (m + n)) } - m < Nat.succ n) }) =
    a { val := i + 1, isLt := (_ : Nat.succ i < Nat.succ m) }

Next tactic:
split_ifs with h_1
theorem append_succ_castAdd_aux (i : Fin m) (h : a (Fin.last _) = b 0) :
    Matrix.vecAppend (Nat.add_succ _ _).symm (a ∘ Fin.castSucc) b (Fin.castAdd n i).succ =
      a i.succ := by
  cases' i with i hi
  simp only [Matrix.vecAppend_eq_ite, hi, Fin.succ_mk, Function.comp_apply, Fin.castSucc_mk,
    Fin.val_mk, Fin.castAdd_mk]
  split_ifs with h_1
  · 

Proof state:
case pos
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
α : Type u_1
m n : ℕ
a : Fin (Nat.succ m) → α
b : Fin (Nat.succ n) → α
h : a (Fin.last m) = b 0
i : ℕ
hi : i < m
h_1 : i + 1 < m
⊢ a { val := i + 1, isLt := (_ : i + 1 < Nat.succ m) } = a { val := i + 1, isLt := (_ : Nat.succ i < Nat.succ m) }

Next tactic:
rfl
theorem append_succ_castAdd_aux (i : Fin m) (h : a (Fin.last _) = b 0) :
    Matrix.vecAppend (Nat.add_succ _ _).symm (a ∘ Fin.castSucc) b (Fin.castAdd n i).succ =
      a i.succ := by
  cases' i with i hi
  simp only [Matrix.vecAppend_eq_ite, hi, Fin.succ_mk, Function.comp_apply, Fin.castSucc_mk,
    Fin.val_mk, Fin.castAdd_mk]
  split_ifs with h_1
  · rfl
  · 

Proof state:
case neg
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
α : Type u_1
m n : ℕ
a : Fin (Nat.succ m) → α
b : Fin (Nat.succ n) → α
h : a (Fin.last m) = b 0
i : ℕ
hi : i < m
h_1 : ¬i + 1 < m
⊢ b
      { val := i + 1 - m,
        isLt := (_ : ↑{ val := i + 1, isLt := (_ : Nat.succ i < Nat.succ (m + n)) } - m < Nat.succ n) } =
    a { val := i + 1, isLt := (_ : Nat.succ i < Nat.succ m) }

Next tactic:
have : i + 1 = m := le_antisymm hi (le_of_not_gt h_1)