l3lab/ntp-mathlib huggingface dataset:
theorem mem_snoc {s : CompositionSeries X} {x y : X} {hsat : IsMaximal s.top x} :
    y ∈ snoc s x hsat ↔ y ∈ s ∨ y = x := by
  simp only [snoc, mem_def]
  constructor
  · rintro ⟨i, rfl⟩
    refine' Fin.lastCases _ (fun i => _) i
    · right
      simp
    · left
      simp
  · intro h
    rcases h with (⟨i, rfl⟩ | rfl)
    · use Fin.castSucc i
      simp
    · 

Proof state:
case mpr.inr
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
y : X
hsat : IsMaximal (top s) y
⊢ y ∈ range (Fin.snoc s.series y)

Next tactic:
use Fin.last _
theorem mem_snoc {s : CompositionSeries X} {x y : X} {hsat : IsMaximal s.top x} :
    y ∈ snoc s x hsat ↔ y ∈ s ∨ y = x := by
  simp only [snoc, mem_def]
  constructor
  · rintro ⟨i, rfl⟩
    refine' Fin.lastCases _ (fun i => _) i
    · right
      simp
    · left
      simp
  · intro h
    rcases h with (⟨i, rfl⟩ | rfl)
    · use Fin.castSucc i
      simp
    · use Fin.last _
      

Proof state:
case h
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
y : X
hsat : IsMaximal (top s) y
⊢ Fin.snoc s.series y (Fin.last (s.length + 1)) = y

Next tactic:
simp
theorem eq_snoc_eraseTop {s : CompositionSeries X} (h : 0 < s.length) :
    s = snoc (eraseTop s) s.top (isMaximal_eraseTop_top h) := by
  

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

Next tactic:
ext x
theorem eq_snoc_eraseTop {s : CompositionSeries X} (h : 0 < s.length) :
    s = snoc (eraseTop s) s.top (isMaximal_eraseTop_top h) := by
  ext x
  

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

Next tactic:
simp only [mem_snoc, mem_eraseTop h, ne_eq]
theorem eq_snoc_eraseTop {s : CompositionSeries X} (h : 0 < s.length) :
    s = snoc (eraseTop s) s.top (isMaximal_eraseTop_top h) := by
  ext x
  simp only [mem_snoc, mem_eraseTop h, ne_eq]
  

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

Next tactic:
by_cases h : x = s.top
theorem eq_snoc_eraseTop {s : CompositionSeries X} (h : 0 < s.length) :
    s = snoc (eraseTop s) s.top (isMaximal_eraseTop_top h) := by
  ext x
  simp only [mem_snoc, mem_eraseTop h, ne_eq]
  by_cases h : x = s.top <;> 

Proof state:
case pos
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h✝ : 0 < s.length
x : X
h : x = top s
⊢ x ∈ s ↔ ¬x = top s ∧ x ∈ s ∨ x = top s

Next tactic:
simp [*, s.top_mem]
theorem eq_snoc_eraseTop {s : CompositionSeries X} (h : 0 < s.length) :
    s = snoc (eraseTop s) s.top (isMaximal_eraseTop_top h) := by
  ext x
  simp only [mem_snoc, mem_eraseTop h, ne_eq]
  by_cases h : x = s.top <;> 

Proof state:
case neg
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
h✝ : 0 < s.length
x : X
h : ¬x = top s
⊢ x ∈ s ↔ ¬x = top s ∧ x ∈ s ∨ x = top s

Next tactic:
simp [*, s.top_mem]
@[simp]
theorem snoc_eraseTop_top {s : CompositionSeries X} (h : IsMaximal s.eraseTop.top s.top) :
    s.eraseTop.snoc s.top h = s :=
  have h : 0 < s.length :=
    Nat.pos_of_ne_zero
      (by
        

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

Next tactic:
intro hs
@[simp]
theorem snoc_eraseTop_top {s : CompositionSeries X} (h : IsMaximal s.eraseTop.top s.top) :
    s.eraseTop.snoc s.top h = s :=
  have h : 0 < s.length :=
    Nat.pos_of_ne_zero
      (by
        intro hs
        

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

Next tactic:
refine' ne_of_gt (lt_of_isMaximal h) _
@[simp]
theorem snoc_eraseTop_top {s : CompositionSeries X} (h : IsMaximal s.eraseTop.top s.top) :
    s.eraseTop.snoc s.top h = s :=
  have h : 0 < s.length :=
    Nat.pos_of_ne_zero
      (by
        intro hs
        refine' ne_of_gt (lt_of_isMaximal h) _
        

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

Next tactic:
simp [top, Fin.ext_iff, hs]
@[symm]
theorem symm {s₁ s₂ : CompositionSeries X} (h : Equivalent s₁ s₂) : Equivalent s₂ s₁ :=
  ⟨h.choose.symm, fun i => iso_symm (by 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s₁ s₂ : CompositionSeries X
h : Equivalent s₁ s₂
i : Fin s₂.length
⊢ Iso (series s₁ (Fin.castSucc ((Exists.choose h).symm i)), series s₁ (Fin.succ ((Exists.choose h).symm i)))
    (series s₂ (Fin.castSucc i), series s₂ (Fin.succ i))

Next tactic:
simpa using h.choose_spec (h.choose.symm i)
theorem append {s₁ s₂ t₁ t₂ : CompositionSeries X} (hs : s₁.top = s₂.bot) (ht : t₁.top = t₂.bot)
    (h₁ : Equivalent s₁ t₁) (h₂ : Equivalent s₂ t₂) :
    Equivalent (append s₁ s₂ hs) (append t₁ t₂ ht) :=
  let e : Fin (s₁.length + s₂.length) ≃ Fin (t₁.length + t₂.length) :=
    calc
      Fin (s₁.length + s₂.length) ≃ Sum (Fin s₁.length) (Fin s₂.length) := finSumFinEquiv.symm
      _ ≃ Sum (Fin t₁.length) (Fin t₂.length) := (Equiv.sumCongr h₁.choose h₂.choose)
      _ ≃ Fin (t₁.length + t₂.length) := finSumFinEquiv

  ⟨e, by
    

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s₁ s₂ t₁ t₂ : CompositionSeries X
hs : top s₁ = bot s₂
ht : top t₁ = bot t₂
h₁ : Equivalent s₁ t₁
h₂ : Equivalent s₂ t₂
e : Fin (s₁.length + s₂.length) ≃ Fin (t₁.length + t₂.length) :=
  Trans.trans (Trans.trans finSumFinEquiv.symm (Equiv.sumCongr (Exists.choose h₁) (Exists.choose h₂))) finSumFinEquiv
⊢ ∀ (i : Fin (CompositionSeries.append s₁ s₂ hs).length),
    Iso
      (series (CompositionSeries.append s₁ s₂ hs) (Fin.castSucc i),
        series (CompositionSeries.append s₁ s₂ hs) (Fin.succ i))
      (series (CompositionSeries.append t₁ t₂ ht) (Fin.castSucc (e i)),
        series (CompositionSeries.append t₁ t₂ ht) (Fin.succ (e i)))

Next tactic:
intro i
theorem append {s₁ s₂ t₁ t₂ : CompositionSeries X} (hs : s₁.top = s₂.bot) (ht : t₁.top = t₂.bot)
    (h₁ : Equivalent s₁ t₁) (h₂ : Equivalent s₂ t₂) :
    Equivalent (append s₁ s₂ hs) (append t₁ t₂ ht) :=
  let e : Fin (s₁.length + s₂.length) ≃ Fin (t₁.length + t₂.length) :=
    calc
      Fin (s₁.length + s₂.length) ≃ Sum (Fin s₁.length) (Fin s₂.length) := finSumFinEquiv.symm
      _ ≃ Sum (Fin t₁.length) (Fin t₂.length) := (Equiv.sumCongr h₁.choose h₂.choose)
      _ ≃ Fin (t₁.length + t₂.length) := finSumFinEquiv

  ⟨e, by
    intro i
    

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s₁ s₂ t₁ t₂ : CompositionSeries X
hs : top s₁ = bot s₂
ht : top t₁ = bot t₂
h₁ : Equivalent s₁ t₁
h₂ : Equivalent s₂ t₂
e : Fin (s₁.length + s₂.length) ≃ Fin (t₁.length + t₂.length) :=
  Trans.trans (Trans.trans finSumFinEquiv.symm (Equiv.sumCongr (Exists.choose h₁) (Exists.choose h₂))) finSumFinEquiv
i : Fin (CompositionSeries.append s₁ s₂ hs).length
⊢ Iso
    (series (CompositionSeries.append s₁ s₂ hs) (Fin.castSucc i),
      series (CompositionSeries.append s₁ s₂ hs) (Fin.succ i))
    (series (CompositionSeries.append t₁ t₂ ht) (Fin.castSucc (e i)),
      series (CompositionSeries.append t₁ t₂ ht) (Fin.succ (e i)))

Next tactic:
refine' Fin.addCases _ _ i
theorem append {s₁ s₂ t₁ t₂ : CompositionSeries X} (hs : s₁.top = s₂.bot) (ht : t₁.top = t₂.bot)
    (h₁ : Equivalent s₁ t₁) (h₂ : Equivalent s₂ t₂) :
    Equivalent (append s₁ s₂ hs) (append t₁ t₂ ht) :=
  let e : Fin (s₁.length + s₂.length) ≃ Fin (t₁.length + t₂.length) :=
    calc
      Fin (s₁.length + s₂.length) ≃ Sum (Fin s₁.length) (Fin s₂.length) := finSumFinEquiv.symm
      _ ≃ Sum (Fin t₁.length) (Fin t₂.length) := (Equiv.sumCongr h₁.choose h₂.choose)
      _ ≃ Fin (t₁.length + t₂.length) := finSumFinEquiv

  ⟨e, by
    intro i
    refine' Fin.addCases _ _ i
    · 

Proof state:
case refine'_1
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s₁ s₂ t₁ t₂ : CompositionSeries X
hs : top s₁ = bot s₂
ht : top t₁ = bot t₂
h₁ : Equivalent s₁ t₁
h₂ : Equivalent s₂ t₂
e : Fin (s₁.length + s₂.length) ≃ Fin (t₁.length + t₂.length) :=
  Trans.trans (Trans.trans finSumFinEquiv.symm (Equiv.sumCongr (Exists.choose h₁) (Exists.choose h₂))) finSumFinEquiv
i : Fin (CompositionSeries.append s₁ s₂ hs).length
⊢ ∀ (i : Fin s₁.length),
    Iso
      (series (CompositionSeries.append s₁ s₂ hs) (Fin.castSucc (Fin.castAdd s₂.length i)),
        series (CompositionSeries.append s₁ s₂ hs) (Fin.succ (Fin.castAdd s₂.length i)))
      (series (CompositionSeries.append t₁ t₂ ht) (Fin.castSucc (e (Fin.castAdd s₂.length i))),
        series (CompositionSeries.append t₁ t₂ ht) (Fin.succ (e (Fin.castAdd s₂.length i))))

Next tactic:
intro i
theorem append {s₁ s₂ t₁ t₂ : CompositionSeries X} (hs : s₁.top = s₂.bot) (ht : t₁.top = t₂.bot)
    (h₁ : Equivalent s₁ t₁) (h₂ : Equivalent s₂ t₂) :
    Equivalent (append s₁ s₂ hs) (append t₁ t₂ ht) :=
  let e : Fin (s₁.length + s₂.length) ≃ Fin (t₁.length + t₂.length) :=
    calc
      Fin (s₁.length + s₂.length) ≃ Sum (Fin s₁.length) (Fin s₂.length) := finSumFinEquiv.symm
      _ ≃ Sum (Fin t₁.length) (Fin t₂.length) := (Equiv.sumCongr h₁.choose h₂.choose)
      _ ≃ Fin (t₁.length + t₂.length) := finSumFinEquiv

  ⟨e, by
    intro i
    refine' Fin.addCases _ _ i
    · intro i
      

Proof state:
case refine'_1
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s₁ s₂ t₁ t₂ : CompositionSeries X
hs : top s₁ = bot s₂
ht : top t₁ = bot t₂
h₁ : Equivalent s₁ t₁
h₂ : Equivalent s₂ t₂
e : Fin (s₁.length + s₂.length) ≃ Fin (t₁.length + t₂.length) :=
  Trans.trans (Trans.trans finSumFinEquiv.symm (Equiv.sumCongr (Exists.choose h₁) (Exists.choose h₂))) finSumFinEquiv
i✝ : Fin (CompositionSeries.append s₁ s₂ hs).length
i : Fin s₁.length
⊢ Iso
    (series (CompositionSeries.append s₁ s₂ hs) (Fin.castSucc (Fin.castAdd s₂.length i)),
      series (CompositionSeries.append s₁ s₂ hs) (Fin.succ (Fin.castAdd s₂.length i)))
    (series (CompositionSeries.append t₁ t₂ ht) (Fin.castSucc (e (Fin.castAdd s₂.length i))),
      series (CompositionSeries.append t₁ t₂ ht) (Fin.succ (e (Fin.castAdd s₂.length i))))

Next tactic:
simpa [top, bot] using h₁.choose_spec i
theorem append {s₁ s₂ t₁ t₂ : CompositionSeries X} (hs : s₁.top = s₂.bot) (ht : t₁.top = t₂.bot)
    (h₁ : Equivalent s₁ t₁) (h₂ : Equivalent s₂ t₂) :
    Equivalent (append s₁ s₂ hs) (append t₁ t₂ ht) :=
  let e : Fin (s₁.length + s₂.length) ≃ Fin (t₁.length + t₂.length) :=
    calc
      Fin (s₁.length + s₂.length) ≃ Sum (Fin s₁.length) (Fin s₂.length) := finSumFinEquiv.symm
      _ ≃ Sum (Fin t₁.length) (Fin t₂.length) := (Equiv.sumCongr h₁.choose h₂.choose)
      _ ≃ Fin (t₁.length + t₂.length) := finSumFinEquiv

  ⟨e, by
    intro i
    refine' Fin.addCases _ _ i
    · intro i
      simpa [top, bot] using h₁.choose_spec i
    · 

Proof state:
case refine'_2
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s₁ s₂ t₁ t₂ : CompositionSeries X
hs : top s₁ = bot s₂
ht : top t₁ = bot t₂
h₁ : Equivalent s₁ t₁
h₂ : Equivalent s₂ t₂
e : Fin (s₁.length + s₂.length) ≃ Fin (t₁.length + t₂.length) :=
  Trans.trans (Trans.trans finSumFinEquiv.symm (Equiv.sumCongr (Exists.choose h₁) (Exists.choose h₂))) finSumFinEquiv
i : Fin (CompositionSeries.append s₁ s₂ hs).length
⊢ ∀ (i : Fin s₂.length),
    Iso
      (series (CompositionSeries.append s₁ s₂ hs) (Fin.castSucc (Fin.natAdd s₁.length i)),
        series (CompositionSeries.append s₁ s₂ hs) (Fin.succ (Fin.natAdd s₁.length i)))
      (series (CompositionSeries.append t₁ t₂ ht) (Fin.castSucc (e (Fin.natAdd s₁.length i))),
        series (CompositionSeries.append t₁ t₂ ht) (Fin.succ (e (Fin.natAdd s₁.length i))))

Next tactic:
intro i
theorem append {s₁ s₂ t₁ t₂ : CompositionSeries X} (hs : s₁.top = s₂.bot) (ht : t₁.top = t₂.bot)
    (h₁ : Equivalent s₁ t₁) (h₂ : Equivalent s₂ t₂) :
    Equivalent (append s₁ s₂ hs) (append t₁ t₂ ht) :=
  let e : Fin (s₁.length + s₂.length) ≃ Fin (t₁.length + t₂.length) :=
    calc
      Fin (s₁.length + s₂.length) ≃ Sum (Fin s₁.length) (Fin s₂.length) := finSumFinEquiv.symm
      _ ≃ Sum (Fin t₁.length) (Fin t₂.length) := (Equiv.sumCongr h₁.choose h₂.choose)
      _ ≃ Fin (t₁.length + t₂.length) := finSumFinEquiv

  ⟨e, by
    intro i
    refine' Fin.addCases _ _ i
    · intro i
      simpa [top, bot] using h₁.choose_spec i
    · intro i
      

Proof state:
case refine'_2
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s₁ s₂ t₁ t₂ : CompositionSeries X
hs : top s₁ = bot s₂
ht : top t₁ = bot t₂
h₁ : Equivalent s₁ t₁
h₂ : Equivalent s₂ t₂
e : Fin (s₁.length + s₂.length) ≃ Fin (t₁.length + t₂.length) :=
  Trans.trans (Trans.trans finSumFinEquiv.symm (Equiv.sumCongr (Exists.choose h₁) (Exists.choose h₂))) finSumFinEquiv
i✝ : Fin (CompositionSeries.append s₁ s₂ hs).length
i : Fin s₂.length
⊢ Iso
    (series (CompositionSeries.append s₁ s₂ hs) (Fin.castSucc (Fin.natAdd s₁.length i)),
      series (CompositionSeries.append s₁ s₂ hs) (Fin.succ (Fin.natAdd s₁.length i)))
    (series (CompositionSeries.append t₁ t₂ ht) (Fin.castSucc (e (Fin.natAdd s₁.length i))),
      series (CompositionSeries.append t₁ t₂ ht) (Fin.succ (e (Fin.natAdd s₁.length i))))

Next tactic:
simpa [top, bot] using h₂.choose_spec i
protected theorem snoc {s₁ s₂ : CompositionSeries X} {x₁ x₂ : X} {hsat₁ : IsMaximal s₁.top x₁}
    {hsat₂ : IsMaximal s₂.top x₂} (hequiv : Equivalent s₁ s₂)
    (htop : Iso (s₁.top, x₁) (s₂.top, x₂)) : Equivalent (s₁.snoc x₁ hsat₁) (s₂.snoc x₂ hsat₂) :=
  let e : Fin s₁.length.succ ≃ Fin s₂.length.succ :=
    calc
      Fin (s₁.length + 1) ≃ Option (Fin s₁.length) := finSuccEquivLast
      _ ≃ Option (Fin s₂.length) := (Functor.mapEquiv Option hequiv.choose)
      _ ≃ Fin (s₂.length + 1) := finSuccEquivLast.symm

  ⟨e, fun i => by
    

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s₁ s₂ : CompositionSeries X
x₁ x₂ : X
hsat₁ : IsMaximal (top s₁) x₁
hsat₂ : IsMaximal (top s₂) x₂
hequiv : Equivalent s₁ s₂
htop : Iso (top s₁, x₁) (top s₂, x₂)
e : Fin (Nat.succ s₁.length) ≃ Fin (Nat.succ s₂.length) :=
  Trans.trans (Trans.trans finSuccEquivLast (Functor.mapEquiv Option (Exists.choose hequiv))) finSuccEquivLast.symm
i : Fin (snoc s₁ x₁ hsat₁).length
⊢ Iso (series (snoc s₁ x₁ hsat₁) (Fin.castSucc i), series (snoc s₁ x₁ hsat₁) (Fin.succ i))
    (series (snoc s₂ x₂ hsat₂) (Fin.castSucc (e i)), series (snoc s₂ x₂ hsat₂) (Fin.succ (e i)))

Next tactic:
refine' Fin.lastCases _ _ i
protected theorem snoc {s₁ s₂ : CompositionSeries X} {x₁ x₂ : X} {hsat₁ : IsMaximal s₁.top x₁}
    {hsat₂ : IsMaximal s₂.top x₂} (hequiv : Equivalent s₁ s₂)
    (htop : Iso (s₁.top, x₁) (s₂.top, x₂)) : Equivalent (s₁.snoc x₁ hsat₁) (s₂.snoc x₂ hsat₂) :=
  let e : Fin s₁.length.succ ≃ Fin s₂.length.succ :=
    calc
      Fin (s₁.length + 1) ≃ Option (Fin s₁.length) := finSuccEquivLast
      _ ≃ Option (Fin s₂.length) := (Functor.mapEquiv Option hequiv.choose)
      _ ≃ Fin (s₂.length + 1) := finSuccEquivLast.symm

  ⟨e, fun i => by
    refine' Fin.lastCases _ _ i
    · 

Proof state:
case refine'_1
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s₁ s₂ : CompositionSeries X
x₁ x₂ : X
hsat₁ : IsMaximal (top s₁) x₁
hsat₂ : IsMaximal (top s₂) x₂
hequiv : Equivalent s₁ s₂
htop : Iso (top s₁, x₁) (top s₂, x₂)
e : Fin (Nat.succ s₁.length) ≃ Fin (Nat.succ s₂.length) :=
  Trans.trans (Trans.trans finSuccEquivLast (Functor.mapEquiv Option (Exists.choose hequiv))) finSuccEquivLast.symm
i : Fin (snoc s₁ x₁ hsat₁).length
⊢ Iso
    (series (snoc s₁ x₁ hsat₁) (Fin.castSucc (Fin.last s₁.length)),
      series (snoc s₁ x₁ hsat₁) (Fin.succ (Fin.last s₁.length)))
    (series (snoc s₂ x₂ hsat₂) (Fin.castSucc (e (Fin.last s₁.length))),
      series (snoc s₂ x₂ hsat₂) (Fin.succ (e (Fin.last s₁.length))))

Next tactic:
simpa [top] using htop
protected theorem snoc {s₁ s₂ : CompositionSeries X} {x₁ x₂ : X} {hsat₁ : IsMaximal s₁.top x₁}
    {hsat₂ : IsMaximal s₂.top x₂} (hequiv : Equivalent s₁ s₂)
    (htop : Iso (s₁.top, x₁) (s₂.top, x₂)) : Equivalent (s₁.snoc x₁ hsat₁) (s₂.snoc x₂ hsat₂) :=
  let e : Fin s₁.length.succ ≃ Fin s₂.length.succ :=
    calc
      Fin (s₁.length + 1) ≃ Option (Fin s₁.length) := finSuccEquivLast
      _ ≃ Option (Fin s₂.length) := (Functor.mapEquiv Option hequiv.choose)
      _ ≃ Fin (s₂.length + 1) := finSuccEquivLast.symm

  ⟨e, fun i => by
    refine' Fin.lastCases _ _ i
    · simpa [top] using htop
    · 

Proof state:
case refine'_2
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s₁ s₂ : CompositionSeries X
x₁ x₂ : X
hsat₁ : IsMaximal (top s₁) x₁
hsat₂ : IsMaximal (top s₂) x₂
hequiv : Equivalent s₁ s₂
htop : Iso (top s₁, x₁) (top s₂, x₂)
e : Fin (Nat.succ s₁.length) ≃ Fin (Nat.succ s₂.length) :=
  Trans.trans (Trans.trans finSuccEquivLast (Functor.mapEquiv Option (Exists.choose hequiv))) finSuccEquivLast.symm
i : Fin (snoc s₁ x₁ hsat₁).length
⊢ ∀ (i : Fin s₁.length),
    Iso
      (series (snoc s₁ x₁ hsat₁) (Fin.castSucc (Fin.castSucc i)), series (snoc s₁ x₁ hsat₁) (Fin.succ (Fin.castSucc i)))
      (series (snoc s₂ x₂ hsat₂) (Fin.castSucc (e (Fin.castSucc i))),
        series (snoc s₂ x₂ hsat₂) (Fin.succ (e (Fin.castSucc i))))

Next tactic:
intro i
protected theorem snoc {s₁ s₂ : CompositionSeries X} {x₁ x₂ : X} {hsat₁ : IsMaximal s₁.top x₁}
    {hsat₂ : IsMaximal s₂.top x₂} (hequiv : Equivalent s₁ s₂)
    (htop : Iso (s₁.top, x₁) (s₂.top, x₂)) : Equivalent (s₁.snoc x₁ hsat₁) (s₂.snoc x₂ hsat₂) :=
  let e : Fin s₁.length.succ ≃ Fin s₂.length.succ :=
    calc
      Fin (s₁.length + 1) ≃ Option (Fin s₁.length) := finSuccEquivLast
      _ ≃ Option (Fin s₂.length) := (Functor.mapEquiv Option hequiv.choose)
      _ ≃ Fin (s₂.length + 1) := finSuccEquivLast.symm

  ⟨e, fun i => by
    refine' Fin.lastCases _ _ i
    · simpa [top] using htop
    · intro i
      

Proof state:
case refine'_2
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s₁ s₂ : CompositionSeries X
x₁ x₂ : X
hsat₁ : IsMaximal (top s₁) x₁
hsat₂ : IsMaximal (top s₂) x₂
hequiv : Equivalent s₁ s₂
htop : Iso (top s₁, x₁) (top s₂, x₂)
e : Fin (Nat.succ s₁.length) ≃ Fin (Nat.succ s₂.length) :=
  Trans.trans (Trans.trans finSuccEquivLast (Functor.mapEquiv Option (Exists.choose hequiv))) finSuccEquivLast.symm
i✝ : Fin (snoc s₁ x₁ hsat₁).length
i : Fin s₁.length
⊢ Iso (series (snoc s₁ x₁ hsat₁) (Fin.castSucc (Fin.castSucc i)), series (snoc s₁ x₁ hsat₁) (Fin.succ (Fin.castSucc i)))
    (series (snoc s₂ x₂ hsat₂) (Fin.castSucc (e (Fin.castSucc i))),
      series (snoc s₂ x₂ hsat₂) (Fin.succ (e (Fin.castSucc i))))

Next tactic:
simpa [Fin.succ_castSucc] using hequiv.choose_spec i
theorem length_eq {s₁ s₂ : CompositionSeries X} (h : Equivalent s₁ s₂) : s₁.length = s₂.length := by
  

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s₁ s₂ : CompositionSeries X
h : Equivalent s₁ s₂
⊢ s₁.length = s₂.length

Next tactic:
simpa using Fintype.card_congr h.choose
theorem snoc_snoc_swap {s : CompositionSeries X} {x₁ x₂ y₁ y₂ : X} {hsat₁ : IsMaximal s.top x₁}
    {hsat₂ : IsMaximal s.top x₂} {hsaty₁ : IsMaximal (snoc s x₁ hsat₁).top y₁}
    {hsaty₂ : IsMaximal (snoc s x₂ hsat₂).top y₂} (hr₁ : Iso (s.top, x₁) (x₂, y₂))
    (hr₂ : Iso (x₁, y₁) (s.top, x₂)) :
    Equivalent (snoc (snoc s x₁ hsat₁) y₁ hsaty₁) (snoc (snoc s x₂ hsat₂) y₂ hsaty₂) :=
  let e : Fin (s.length + 1 + 1) ≃ Fin (s.length + 1 + 1) :=
    Equiv.swap (Fin.last _) (Fin.castSucc (Fin.last _))
  have h1 : ∀ {i : Fin s.length},
      (Fin.castSucc (Fin.castSucc i)) ≠ (Fin.castSucc (Fin.last _)) := fun {_} =>
    ne_of_lt (by 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
x₁ x₂ y₁ y₂ : X
hsat₁ : IsMaximal (top s) x₁
hsat₂ : IsMaximal (top s) x₂
hsaty₁ : IsMaximal (top (snoc s x₁ hsat₁)) y₁
hsaty₂ : IsMaximal (top (snoc s x₂ hsat₂)) y₂
hr₁ : Iso (top s, x₁) (x₂, y₂)
hr₂ : Iso (x₁, y₁) (top s, x₂)
e : Fin (s.length + 1 + 1) ≃ Fin (s.length + 1 + 1) :=
  Equiv.swap (Fin.last (s.length + 1)) (Fin.castSucc (Fin.last s.length))
x✝ : Fin s.length
⊢ Fin.castSucc (Fin.castSucc x✝) < Fin.castSucc (Fin.last s.length)

Next tactic:
simp [Fin.castSucc_lt_last]
theorem snoc_snoc_swap {s : CompositionSeries X} {x₁ x₂ y₁ y₂ : X} {hsat₁ : IsMaximal s.top x₁}
    {hsat₂ : IsMaximal s.top x₂} {hsaty₁ : IsMaximal (snoc s x₁ hsat₁).top y₁}
    {hsaty₂ : IsMaximal (snoc s x₂ hsat₂).top y₂} (hr₁ : Iso (s.top, x₁) (x₂, y₂))
    (hr₂ : Iso (x₁, y₁) (s.top, x₂)) :
    Equivalent (snoc (snoc s x₁ hsat₁) y₁ hsaty₁) (snoc (snoc s x₂ hsat₂) y₂ hsaty₂) :=
  let e : Fin (s.length + 1 + 1) ≃ Fin (s.length + 1 + 1) :=
    Equiv.swap (Fin.last _) (Fin.castSucc (Fin.last _))
  have h1 : ∀ {i : Fin s.length},
      (Fin.castSucc (Fin.castSucc i)) ≠ (Fin.castSucc (Fin.last _)) := fun {_} =>
    ne_of_lt (by simp [Fin.castSucc_lt_last])
  have h2 : ∀ {i : Fin s.length},
      (Fin.castSucc (Fin.castSucc i)) ≠ Fin.last _ := fun {_} =>
    ne_of_lt (by 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
x₁ x₂ y₁ y₂ : X
hsat₁ : IsMaximal (top s) x₁
hsat₂ : IsMaximal (top s) x₂
hsaty₁ : IsMaximal (top (snoc s x₁ hsat₁)) y₁
hsaty₂ : IsMaximal (top (snoc s x₂ hsat₂)) y₂
hr₁ : Iso (top s, x₁) (x₂, y₂)
hr₂ : Iso (x₁, y₁) (top s, x₂)
e : Fin (s.length + 1 + 1) ≃ Fin (s.length + 1 + 1) :=
  Equiv.swap (Fin.last (s.length + 1)) (Fin.castSucc (Fin.last s.length))
h1 : ∀ {i : Fin s.length}, Fin.castSucc (Fin.castSucc i) ≠ Fin.castSucc (Fin.last s.length)
x✝ : Fin s.length
⊢ Fin.castSucc (Fin.castSucc x✝) < Fin.last (s.length + 1)

Next tactic:
simp [Fin.castSucc_lt_last]
theorem snoc_snoc_swap {s : CompositionSeries X} {x₁ x₂ y₁ y₂ : X} {hsat₁ : IsMaximal s.top x₁}
    {hsat₂ : IsMaximal s.top x₂} {hsaty₁ : IsMaximal (snoc s x₁ hsat₁).top y₁}
    {hsaty₂ : IsMaximal (snoc s x₂ hsat₂).top y₂} (hr₁ : Iso (s.top, x₁) (x₂, y₂))
    (hr₂ : Iso (x₁, y₁) (s.top, x₂)) :
    Equivalent (snoc (snoc s x₁ hsat₁) y₁ hsaty₁) (snoc (snoc s x₂ hsat₂) y₂ hsaty₂) :=
  let e : Fin (s.length + 1 + 1) ≃ Fin (s.length + 1 + 1) :=
    Equiv.swap (Fin.last _) (Fin.castSucc (Fin.last _))
  have h1 : ∀ {i : Fin s.length},
      (Fin.castSucc (Fin.castSucc i)) ≠ (Fin.castSucc (Fin.last _)) := fun {_} =>
    ne_of_lt (by simp [Fin.castSucc_lt_last])
  have h2 : ∀ {i : Fin s.length},
      (Fin.castSucc (Fin.castSucc i)) ≠ Fin.last _ := fun {_} =>
    ne_of_lt (by simp [Fin.castSucc_lt_last])
  ⟨e, by
    

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
s : CompositionSeries X
x₁ x₂ y₁ y₂ : X
hsat₁ : IsMaximal (top s) x₁
hsat₂ : IsMaximal (top s) x₂
hsaty₁ : IsMaximal (top (snoc s x₁ hsat₁)) y₁
hsaty₂ : IsMaximal (top (snoc s x₂ hsat₂)) y₂
hr₁ : Iso (top s, x₁) (x₂, y₂)
hr₂ : Iso (x₁, y₁) (top s, x₂)
e : Fin (s.length + 1 + 1) ≃ Fin (s.length + 1 + 1) :=
  Equiv.swap (Fin.last (s.length + 1)) (Fin.castSucc (Fin.last s.length))
h1 : ∀ {i : Fin s.length}, Fin.castSucc (Fin.castSucc i) ≠ Fin.castSucc (Fin.last s.length)
h2 : ∀ {i : Fin s.length}, Fin.castSucc (Fin.castSucc i) ≠ Fin.last (s.length + 1)
⊢ ∀ (i : Fin (snoc (snoc s x₁ hsat₁) y₁ hsaty₁).length),
    Iso
      (series (snoc (snoc s x₁ hsat₁) y₁ hsaty₁) (Fin.castSucc i),
        series (snoc (snoc s x₁ hsat₁) y₁ hsaty₁) (Fin.succ i))
      (series (snoc (snoc s x₂ hsat₂) y₂ hsaty₂) (Fin.castSucc (e i)),
        series (snoc (snoc s x₂ hsat₂) y₂ hsaty₂) (Fin.succ (e i)))

Next tactic:
intro i