l3lab/ntp-mathlib huggingface dataset:
/-- Given a `CompositionSeries`, `s`, and an element `x`
such that `x` is maximal inside `s.top` there is a series, `t`,
such that `t.top = x`, `t.bot = s.bot`
and `snoc t s.top _` is equivalent to `s`. -/
theorem exists_top_eq_snoc_equivalant (s : CompositionSeries X) (x : X) (hm : IsMaximal x s.top)
    (hb : s.bot ≤ x) :
    ∃ t : CompositionSeries X,
      t.bot = s.bot ∧ t.length + 1 = s.length ∧
      ∃ htx : t.top = x, Equivalent s (snoc t s.top (htx.symm ▸ hm)) := by
  induction' hn : s.length with n ih generalizing s x
  · exact
      (ne_of_gt (lt_of_le_of_lt hb (lt_of_isMaximal hm))
          (forall_mem_eq_of_length_eq_zero hn s.top_mem s.bot_mem)).elim
  · have h0s : 0 < s.length := hn.symm ▸ Nat.succ_pos _
    by_cases hetx : s.eraseTop.top = x
    · use s.eraseTop
      simp [← hetx, hn]
      -- Porting note: `rfl` is required.
      rfl
    · have imxs : IsMaximal (x ⊓ s.eraseTop.top) s.eraseTop.top :=
        isMaximal_of_eq_inf x s.top rfl (Ne.symm hetx) hm (isMaximal_eraseTop_top h0s)
      have := ih _ _ imxs (le_inf (by simpa) (le_top_of_mem s.eraseTop.bot_mem)) (by simp [hn])
      rcases this with ⟨t, htb, htl, htt, hteqv⟩
      have hmtx : IsMaximal t.top x :=
        isMaximal_of_eq_inf s.eraseTop.top s.top (by 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
n : ℕ
ih :
  ∀ (s : CompositionSeries X) (x : X) (hm : IsMaximal x (top s)),
    bot s ≤ x →
      s.length = n →
        ∃ t,
          bot t = bot s ∧
            t.length + 1 = n ∧ ∃ (htx : top t = x), Equivalent s (snoc t (top s) (_ : IsMaximal (top t) (top s)))
s : CompositionSeries X
x : X
hm : IsMaximal x (top s)
hb : bot s ≤ x
hn : s.length = Nat.succ n
h0s : 0 < s.length
hetx : ¬top (eraseTop s) = x
imxs : IsMaximal (x ⊓ top (eraseTop s)) (top (eraseTop s))
t : CompositionSeries X
htb : bot t = bot (eraseTop s)
htl : t.length + 1 = n
htt : top t = x ⊓ top (eraseTop s)
hteqv : Equivalent (eraseTop s) (snoc t (top (eraseTop s)) (_ : IsMaximal (top t) (top (eraseTop s))))
⊢ top (eraseTop s) ⊓ x = top t

Next tactic:
rw [inf_comm, htt]
/-- Given a `CompositionSeries`, `s`, and an element `x`
such that `x` is maximal inside `s.top` there is a series, `t`,
such that `t.top = x`, `t.bot = s.bot`
and `snoc t s.top _` is equivalent to `s`. -/
theorem exists_top_eq_snoc_equivalant (s : CompositionSeries X) (x : X) (hm : IsMaximal x s.top)
    (hb : s.bot ≤ x) :
    ∃ t : CompositionSeries X,
      t.bot = s.bot ∧ t.length + 1 = s.length ∧
      ∃ htx : t.top = x, Equivalent s (snoc t s.top (htx.symm ▸ hm)) := by
  induction' hn : s.length with n ih generalizing s x
  · exact
      (ne_of_gt (lt_of_le_of_lt hb (lt_of_isMaximal hm))
          (forall_mem_eq_of_length_eq_zero hn s.top_mem s.bot_mem)).elim
  · have h0s : 0 < s.length := hn.symm ▸ Nat.succ_pos _
    by_cases hetx : s.eraseTop.top = x
    · use s.eraseTop
      simp [← hetx, hn]
      -- Porting note: `rfl` is required.
      rfl
    · have imxs : IsMaximal (x ⊓ s.eraseTop.top) s.eraseTop.top :=
        isMaximal_of_eq_inf x s.top rfl (Ne.symm hetx) hm (isMaximal_eraseTop_top h0s)
      have := ih _ _ imxs (le_inf (by simpa) (le_top_of_mem s.eraseTop.bot_mem)) (by simp [hn])
      rcases this with ⟨t, htb, htl, htt, hteqv⟩
      have hmtx : IsMaximal t.top x :=
        isMaximal_of_eq_inf s.eraseTop.top s.top (by rw [inf_comm, htt]) hetx
          (isMaximal_eraseTop_top h0s) hm
      

Proof state:
case neg.intro.intro.intro.intro
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
n : ℕ
ih :
  ∀ (s : CompositionSeries X) (x : X) (hm : IsMaximal x (top s)),
    bot s ≤ x →
      s.length = n →
        ∃ t,
          bot t = bot s ∧
            t.length + 1 = n ∧ ∃ (htx : top t = x), Equivalent s (snoc t (top s) (_ : IsMaximal (top t) (top s)))
s : CompositionSeries X
x : X
hm : IsMaximal x (top s)
hb : bot s ≤ x
hn : s.length = Nat.succ n
h0s : 0 < s.length
hetx : ¬top (eraseTop s) = x
imxs : IsMaximal (x ⊓ top (eraseTop s)) (top (eraseTop s))
t : CompositionSeries X
htb : bot t = bot (eraseTop s)
htl : t.length + 1 = n
htt : top t = x ⊓ top (eraseTop s)
hteqv : Equivalent (eraseTop s) (snoc t (top (eraseTop s)) (_ : IsMaximal (top t) (top (eraseTop s))))
hmtx : IsMaximal (top t) x
⊢ ∃ t,
    bot t = bot s ∧
      t.length + 1 = Nat.succ n ∧ ∃ (htx : top t = x), Equivalent s (snoc t (top s) (_ : IsMaximal (top t) (top s)))

Next tactic:
use snoc t x hmtx
/-- Given a `CompositionSeries`, `s`, and an element `x`
such that `x` is maximal inside `s.top` there is a series, `t`,
such that `t.top = x`, `t.bot = s.bot`
and `snoc t s.top _` is equivalent to `s`. -/
theorem exists_top_eq_snoc_equivalant (s : CompositionSeries X) (x : X) (hm : IsMaximal x s.top)
    (hb : s.bot ≤ x) :
    ∃ t : CompositionSeries X,
      t.bot = s.bot ∧ t.length + 1 = s.length ∧
      ∃ htx : t.top = x, Equivalent s (snoc t s.top (htx.symm ▸ hm)) := by
  induction' hn : s.length with n ih generalizing s x
  · exact
      (ne_of_gt (lt_of_le_of_lt hb (lt_of_isMaximal hm))
          (forall_mem_eq_of_length_eq_zero hn s.top_mem s.bot_mem)).elim
  · have h0s : 0 < s.length := hn.symm ▸ Nat.succ_pos _
    by_cases hetx : s.eraseTop.top = x
    · use s.eraseTop
      simp [← hetx, hn]
      -- Porting note: `rfl` is required.
      rfl
    · have imxs : IsMaximal (x ⊓ s.eraseTop.top) s.eraseTop.top :=
        isMaximal_of_eq_inf x s.top rfl (Ne.symm hetx) hm (isMaximal_eraseTop_top h0s)
      have := ih _ _ imxs (le_inf (by simpa) (le_top_of_mem s.eraseTop.bot_mem)) (by simp [hn])
      rcases this with ⟨t, htb, htl, htt, hteqv⟩
      have hmtx : IsMaximal t.top x :=
        isMaximal_of_eq_inf s.eraseTop.top s.top (by rw [inf_comm, htt]) hetx
          (isMaximal_eraseTop_top h0s) hm
      use snoc t x hmtx
      

Proof state:
case h
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
n : ℕ
ih :
  ∀ (s : CompositionSeries X) (x : X) (hm : IsMaximal x (top s)),
    bot s ≤ x →
      s.length = n →
        ∃ t,
          bot t = bot s ∧
            t.length + 1 = n ∧ ∃ (htx : top t = x), Equivalent s (snoc t (top s) (_ : IsMaximal (top t) (top s)))
s : CompositionSeries X
x : X
hm : IsMaximal x (top s)
hb : bot s ≤ x
hn : s.length = Nat.succ n
h0s : 0 < s.length
hetx : ¬top (eraseTop s) = x
imxs : IsMaximal (x ⊓ top (eraseTop s)) (top (eraseTop s))
t : CompositionSeries X
htb : bot t = bot (eraseTop s)
htl : t.length + 1 = n
htt : top t = x ⊓ top (eraseTop s)
hteqv : Equivalent (eraseTop s) (snoc t (top (eraseTop s)) (_ : IsMaximal (top t) (top (eraseTop s))))
hmtx : IsMaximal (top t) x
⊢ bot (snoc t x hmtx) = bot s ∧
    (snoc t x hmtx).length + 1 = Nat.succ n ∧
      ∃ (htx : top (snoc t x hmtx) = x),
        Equivalent s (snoc (snoc t x hmtx) (top s) (_ : IsMaximal (top (snoc t x hmtx)) (top s)))

Next tactic:
refine' ⟨by simp [htb], by simp [htl], by simp, _⟩
/-- Given a `CompositionSeries`, `s`, and an element `x`
such that `x` is maximal inside `s.top` there is a series, `t`,
such that `t.top = x`, `t.bot = s.bot`
and `snoc t s.top _` is equivalent to `s`. -/
theorem exists_top_eq_snoc_equivalant (s : CompositionSeries X) (x : X) (hm : IsMaximal x s.top)
    (hb : s.bot ≤ x) :
    ∃ t : CompositionSeries X,
      t.bot = s.bot ∧ t.length + 1 = s.length ∧
      ∃ htx : t.top = x, Equivalent s (snoc t s.top (htx.symm ▸ hm)) := by
  induction' hn : s.length with n ih generalizing s x
  · exact
      (ne_of_gt (lt_of_le_of_lt hb (lt_of_isMaximal hm))
          (forall_mem_eq_of_length_eq_zero hn s.top_mem s.bot_mem)).elim
  · have h0s : 0 < s.length := hn.symm ▸ Nat.succ_pos _
    by_cases hetx : s.eraseTop.top = x
    · use s.eraseTop
      simp [← hetx, hn]
      -- Porting note: `rfl` is required.
      rfl
    · have imxs : IsMaximal (x ⊓ s.eraseTop.top) s.eraseTop.top :=
        isMaximal_of_eq_inf x s.top rfl (Ne.symm hetx) hm (isMaximal_eraseTop_top h0s)
      have := ih _ _ imxs (le_inf (by simpa) (le_top_of_mem s.eraseTop.bot_mem)) (by simp [hn])
      rcases this with ⟨t, htb, htl, htt, hteqv⟩
      have hmtx : IsMaximal t.top x :=
        isMaximal_of_eq_inf s.eraseTop.top s.top (by rw [inf_comm, htt]) hetx
          (isMaximal_eraseTop_top h0s) hm
      use snoc t x hmtx
      refine' ⟨by 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
n : ℕ
ih :
  ∀ (s : CompositionSeries X) (x : X) (hm : IsMaximal x (top s)),
    bot s ≤ x →
      s.length = n →
        ∃ t,
          bot t = bot s ∧
            t.length + 1 = n ∧ ∃ (htx : top t = x), Equivalent s (snoc t (top s) (_ : IsMaximal (top t) (top s)))
s : CompositionSeries X
x : X
hm : IsMaximal x (top s)
hb : bot s ≤ x
hn : s.length = Nat.succ n
h0s : 0 < s.length
hetx : ¬top (eraseTop s) = x
imxs : IsMaximal (x ⊓ top (eraseTop s)) (top (eraseTop s))
t : CompositionSeries X
htb : bot t = bot (eraseTop s)
htl : t.length + 1 = n
htt : top t = x ⊓ top (eraseTop s)
hteqv : Equivalent (eraseTop s) (snoc t (top (eraseTop s)) (_ : IsMaximal (top t) (top (eraseTop s))))
hmtx : IsMaximal (top t) x
⊢ bot (snoc t x hmtx) = bot s

Next tactic:
simp [htb]
/-- Given a `CompositionSeries`, `s`, and an element `x`
such that `x` is maximal inside `s.top` there is a series, `t`,
such that `t.top = x`, `t.bot = s.bot`
and `snoc t s.top _` is equivalent to `s`. -/
theorem exists_top_eq_snoc_equivalant (s : CompositionSeries X) (x : X) (hm : IsMaximal x s.top)
    (hb : s.bot ≤ x) :
    ∃ t : CompositionSeries X,
      t.bot = s.bot ∧ t.length + 1 = s.length ∧
      ∃ htx : t.top = x, Equivalent s (snoc t s.top (htx.symm ▸ hm)) := by
  induction' hn : s.length with n ih generalizing s x
  · exact
      (ne_of_gt (lt_of_le_of_lt hb (lt_of_isMaximal hm))
          (forall_mem_eq_of_length_eq_zero hn s.top_mem s.bot_mem)).elim
  · have h0s : 0 < s.length := hn.symm ▸ Nat.succ_pos _
    by_cases hetx : s.eraseTop.top = x
    · use s.eraseTop
      simp [← hetx, hn]
      -- Porting note: `rfl` is required.
      rfl
    · have imxs : IsMaximal (x ⊓ s.eraseTop.top) s.eraseTop.top :=
        isMaximal_of_eq_inf x s.top rfl (Ne.symm hetx) hm (isMaximal_eraseTop_top h0s)
      have := ih _ _ imxs (le_inf (by simpa) (le_top_of_mem s.eraseTop.bot_mem)) (by simp [hn])
      rcases this with ⟨t, htb, htl, htt, hteqv⟩
      have hmtx : IsMaximal t.top x :=
        isMaximal_of_eq_inf s.eraseTop.top s.top (by rw [inf_comm, htt]) hetx
          (isMaximal_eraseTop_top h0s) hm
      use snoc t x hmtx
      refine' ⟨by simp [htb], by 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
n : ℕ
ih :
  ∀ (s : CompositionSeries X) (x : X) (hm : IsMaximal x (top s)),
    bot s ≤ x →
      s.length = n →
        ∃ t,
          bot t = bot s ∧
            t.length + 1 = n ∧ ∃ (htx : top t = x), Equivalent s (snoc t (top s) (_ : IsMaximal (top t) (top s)))
s : CompositionSeries X
x : X
hm : IsMaximal x (top s)
hb : bot s ≤ x
hn : s.length = Nat.succ n
h0s : 0 < s.length
hetx : ¬top (eraseTop s) = x
imxs : IsMaximal (x ⊓ top (eraseTop s)) (top (eraseTop s))
t : CompositionSeries X
htb : bot t = bot (eraseTop s)
htl : t.length + 1 = n
htt : top t = x ⊓ top (eraseTop s)
hteqv : Equivalent (eraseTop s) (snoc t (top (eraseTop s)) (_ : IsMaximal (top t) (top (eraseTop s))))
hmtx : IsMaximal (top t) x
⊢ (snoc t x hmtx).length + 1 = Nat.succ n

Next tactic:
simp [htl]
/-- Given a `CompositionSeries`, `s`, and an element `x`
such that `x` is maximal inside `s.top` there is a series, `t`,
such that `t.top = x`, `t.bot = s.bot`
and `snoc t s.top _` is equivalent to `s`. -/
theorem exists_top_eq_snoc_equivalant (s : CompositionSeries X) (x : X) (hm : IsMaximal x s.top)
    (hb : s.bot ≤ x) :
    ∃ t : CompositionSeries X,
      t.bot = s.bot ∧ t.length + 1 = s.length ∧
      ∃ htx : t.top = x, Equivalent s (snoc t s.top (htx.symm ▸ hm)) := by
  induction' hn : s.length with n ih generalizing s x
  · exact
      (ne_of_gt (lt_of_le_of_lt hb (lt_of_isMaximal hm))
          (forall_mem_eq_of_length_eq_zero hn s.top_mem s.bot_mem)).elim
  · have h0s : 0 < s.length := hn.symm ▸ Nat.succ_pos _
    by_cases hetx : s.eraseTop.top = x
    · use s.eraseTop
      simp [← hetx, hn]
      -- Porting note: `rfl` is required.
      rfl
    · have imxs : IsMaximal (x ⊓ s.eraseTop.top) s.eraseTop.top :=
        isMaximal_of_eq_inf x s.top rfl (Ne.symm hetx) hm (isMaximal_eraseTop_top h0s)
      have := ih _ _ imxs (le_inf (by simpa) (le_top_of_mem s.eraseTop.bot_mem)) (by simp [hn])
      rcases this with ⟨t, htb, htl, htt, hteqv⟩
      have hmtx : IsMaximal t.top x :=
        isMaximal_of_eq_inf s.eraseTop.top s.top (by rw [inf_comm, htt]) hetx
          (isMaximal_eraseTop_top h0s) hm
      use snoc t x hmtx
      refine' ⟨by simp [htb], by simp [htl], by 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
n : ℕ
ih :
  ∀ (s : CompositionSeries X) (x : X) (hm : IsMaximal x (top s)),
    bot s ≤ x →
      s.length = n →
        ∃ t,
          bot t = bot s ∧
            t.length + 1 = n ∧ ∃ (htx : top t = x), Equivalent s (snoc t (top s) (_ : IsMaximal (top t) (top s)))
s : CompositionSeries X
x : X
hm : IsMaximal x (top s)
hb : bot s ≤ x
hn : s.length = Nat.succ n
h0s : 0 < s.length
hetx : ¬top (eraseTop s) = x
imxs : IsMaximal (x ⊓ top (eraseTop s)) (top (eraseTop s))
t : CompositionSeries X
htb : bot t = bot (eraseTop s)
htl : t.length + 1 = n
htt : top t = x ⊓ top (eraseTop s)
hteqv : Equivalent (eraseTop s) (snoc t (top (eraseTop s)) (_ : IsMaximal (top t) (top (eraseTop s))))
hmtx : IsMaximal (top t) x
⊢ top (snoc t x hmtx) = x

Next tactic:
simp
/-- Given a `CompositionSeries`, `s`, and an element `x`
such that `x` is maximal inside `s.top` there is a series, `t`,
such that `t.top = x`, `t.bot = s.bot`
and `snoc t s.top _` is equivalent to `s`. -/
theorem exists_top_eq_snoc_equivalant (s : CompositionSeries X) (x : X) (hm : IsMaximal x s.top)
    (hb : s.bot ≤ x) :
    ∃ t : CompositionSeries X,
      t.bot = s.bot ∧ t.length + 1 = s.length ∧
      ∃ htx : t.top = x, Equivalent s (snoc t s.top (htx.symm ▸ hm)) := by
  induction' hn : s.length with n ih generalizing s x
  · exact
      (ne_of_gt (lt_of_le_of_lt hb (lt_of_isMaximal hm))
          (forall_mem_eq_of_length_eq_zero hn s.top_mem s.bot_mem)).elim
  · have h0s : 0 < s.length := hn.symm ▸ Nat.succ_pos _
    by_cases hetx : s.eraseTop.top = x
    · use s.eraseTop
      simp [← hetx, hn]
      -- Porting note: `rfl` is required.
      rfl
    · have imxs : IsMaximal (x ⊓ s.eraseTop.top) s.eraseTop.top :=
        isMaximal_of_eq_inf x s.top rfl (Ne.symm hetx) hm (isMaximal_eraseTop_top h0s)
      have := ih _ _ imxs (le_inf (by simpa) (le_top_of_mem s.eraseTop.bot_mem)) (by simp [hn])
      rcases this with ⟨t, htb, htl, htt, hteqv⟩
      have hmtx : IsMaximal t.top x :=
        isMaximal_of_eq_inf s.eraseTop.top s.top (by rw [inf_comm, htt]) hetx
          (isMaximal_eraseTop_top h0s) hm
      use snoc t x hmtx
      refine' ⟨by simp [htb], by simp [htl], by simp, _⟩
      

Proof state:
case h
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
n : ℕ
ih :
  ∀ (s : CompositionSeries X) (x : X) (hm : IsMaximal x (top s)),
    bot s ≤ x →
      s.length = n →
        ∃ t,
          bot t = bot s ∧
            t.length + 1 = n ∧ ∃ (htx : top t = x), Equivalent s (snoc t (top s) (_ : IsMaximal (top t) (top s)))
s : CompositionSeries X
x : X
hm : IsMaximal x (top s)
hb : bot s ≤ x
hn : s.length = Nat.succ n
h0s : 0 < s.length
hetx : ¬top (eraseTop s) = x
imxs : IsMaximal (x ⊓ top (eraseTop s)) (top (eraseTop s))
t : CompositionSeries X
htb : bot t = bot (eraseTop s)
htl : t.length + 1 = n
htt : top t = x ⊓ top (eraseTop s)
hteqv : Equivalent (eraseTop s) (snoc t (top (eraseTop s)) (_ : IsMaximal (top t) (top (eraseTop s))))
hmtx : IsMaximal (top t) x
⊢ Equivalent s (snoc (snoc t x hmtx) (top s) (_ : IsMaximal (top (snoc t x hmtx)) (top s)))

Next tactic:
have : s.Equivalent ((snoc t s.eraseTop.top (htt.symm ▸ imxs)).snoc s.top
          (by simpa using isMaximal_eraseTop_top h0s)) := by
        conv_lhs => rw [eq_snoc_eraseTop h0s]
        exact Equivalent.snoc hteqv (by simpa using (isMaximal_eraseTop_top h0s).iso_refl)
/-- Given a `CompositionSeries`, `s`, and an element `x`
such that `x` is maximal inside `s.top` there is a series, `t`,
such that `t.top = x`, `t.bot = s.bot`
and `snoc t s.top _` is equivalent to `s`. -/
theorem exists_top_eq_snoc_equivalant (s : CompositionSeries X) (x : X) (hm : IsMaximal x s.top)
    (hb : s.bot ≤ x) :
    ∃ t : CompositionSeries X,
      t.bot = s.bot ∧ t.length + 1 = s.length ∧
      ∃ htx : t.top = x, Equivalent s (snoc t s.top (htx.symm ▸ hm)) := by
  induction' hn : s.length with n ih generalizing s x
  · exact
      (ne_of_gt (lt_of_le_of_lt hb (lt_of_isMaximal hm))
          (forall_mem_eq_of_length_eq_zero hn s.top_mem s.bot_mem)).elim
  · have h0s : 0 < s.length := hn.symm ▸ Nat.succ_pos _
    by_cases hetx : s.eraseTop.top = x
    · use s.eraseTop
      simp [← hetx, hn]
      -- Porting note: `rfl` is required.
      rfl
    · have imxs : IsMaximal (x ⊓ s.eraseTop.top) s.eraseTop.top :=
        isMaximal_of_eq_inf x s.top rfl (Ne.symm hetx) hm (isMaximal_eraseTop_top h0s)
      have := ih _ _ imxs (le_inf (by simpa) (le_top_of_mem s.eraseTop.bot_mem)) (by simp [hn])
      rcases this with ⟨t, htb, htl, htt, hteqv⟩
      have hmtx : IsMaximal t.top x :=
        isMaximal_of_eq_inf s.eraseTop.top s.top (by rw [inf_comm, htt]) hetx
          (isMaximal_eraseTop_top h0s) hm
      use snoc t x hmtx
      refine' ⟨by simp [htb], by simp [htl], by simp, _⟩
      have : s.Equivalent ((snoc t s.eraseTop.top (htt.symm ▸ imxs)).snoc s.top
          (by 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
n : ℕ
ih :
  ∀ (s : CompositionSeries X) (x : X) (hm : IsMaximal x (top s)),
    bot s ≤ x →
      s.length = n →
        ∃ t,
          bot t = bot s ∧
            t.length + 1 = n ∧ ∃ (htx : top t = x), Equivalent s (snoc t (top s) (_ : IsMaximal (top t) (top s)))
s : CompositionSeries X
x : X
hm : IsMaximal x (top s)
hb : bot s ≤ x
hn : s.length = Nat.succ n
h0s : 0 < s.length
hetx : ¬top (eraseTop s) = x
imxs : IsMaximal (x ⊓ top (eraseTop s)) (top (eraseTop s))
t : CompositionSeries X
htb : bot t = bot (eraseTop s)
htl : t.length + 1 = n
htt : top t = x ⊓ top (eraseTop s)
hteqv : Equivalent (eraseTop s) (snoc t (top (eraseTop s)) (_ : IsMaximal (top t) (top (eraseTop s))))
hmtx : IsMaximal (top t) x
⊢ IsMaximal (top (snoc t (top (eraseTop s)) (_ : IsMaximal (top t) (top (eraseTop s))))) (top s)

Next tactic:
simpa using isMaximal_eraseTop_top h0s
/-- Given a `CompositionSeries`, `s`, and an element `x`
such that `x` is maximal inside `s.top` there is a series, `t`,
such that `t.top = x`, `t.bot = s.bot`
and `snoc t s.top _` is equivalent to `s`. -/
theorem exists_top_eq_snoc_equivalant (s : CompositionSeries X) (x : X) (hm : IsMaximal x s.top)
    (hb : s.bot ≤ x) :
    ∃ t : CompositionSeries X,
      t.bot = s.bot ∧ t.length + 1 = s.length ∧
      ∃ htx : t.top = x, Equivalent s (snoc t s.top (htx.symm ▸ hm)) := by
  induction' hn : s.length with n ih generalizing s x
  · exact
      (ne_of_gt (lt_of_le_of_lt hb (lt_of_isMaximal hm))
          (forall_mem_eq_of_length_eq_zero hn s.top_mem s.bot_mem)).elim
  · have h0s : 0 < s.length := hn.symm ▸ Nat.succ_pos _
    by_cases hetx : s.eraseTop.top = x
    · use s.eraseTop
      simp [← hetx, hn]
      -- Porting note: `rfl` is required.
      rfl
    · have imxs : IsMaximal (x ⊓ s.eraseTop.top) s.eraseTop.top :=
        isMaximal_of_eq_inf x s.top rfl (Ne.symm hetx) hm (isMaximal_eraseTop_top h0s)
      have := ih _ _ imxs (le_inf (by simpa) (le_top_of_mem s.eraseTop.bot_mem)) (by simp [hn])
      rcases this with ⟨t, htb, htl, htt, hteqv⟩
      have hmtx : IsMaximal t.top x :=
        isMaximal_of_eq_inf s.eraseTop.top s.top (by rw [inf_comm, htt]) hetx
          (isMaximal_eraseTop_top h0s) hm
      use snoc t x hmtx
      refine' ⟨by simp [htb], by simp [htl], by simp, _⟩
      have : s.Equivalent ((snoc t s.eraseTop.top (htt.symm ▸ imxs)).snoc s.top
          (by simpa using isMaximal_eraseTop_top h0s)) := by
        

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
n : ℕ
ih :
  ∀ (s : CompositionSeries X) (x : X) (hm : IsMaximal x (top s)),
    bot s ≤ x →
      s.length = n →
        ∃ t,
          bot t = bot s ∧
            t.length + 1 = n ∧ ∃ (htx : top t = x), Equivalent s (snoc t (top s) (_ : IsMaximal (top t) (top s)))
s : CompositionSeries X
x : X
hm : IsMaximal x (top s)
hb : bot s ≤ x
hn : s.length = Nat.succ n
h0s : 0 < s.length
hetx : ¬top (eraseTop s) = x
imxs : IsMaximal (x ⊓ top (eraseTop s)) (top (eraseTop s))
t : CompositionSeries X
htb : bot t = bot (eraseTop s)
htl : t.length + 1 = n
htt : top t = x ⊓ top (eraseTop s)
hteqv : Equivalent (eraseTop s) (snoc t (top (eraseTop s)) (_ : IsMaximal (top t) (top (eraseTop s))))
hmtx : IsMaximal (top t) x
⊢ Equivalent s
    (snoc (snoc t (top (eraseTop s)) (_ : IsMaximal (top t) (top (eraseTop s)))) (top s)
      (_ : IsMaximal (top (snoc t (top (eraseTop s)) (_ : IsMaximal (top t) (top (eraseTop s))))) (top s)))

Next tactic:
conv_lhs => rw [eq_snoc_eraseTop h0s]
/-- Given a `CompositionSeries`, `s`, and an element `x`
such that `x` is maximal inside `s.top` there is a series, `t`,
such that `t.top = x`, `t.bot = s.bot`
and `snoc t s.top _` is equivalent to `s`. -/
theorem exists_top_eq_snoc_equivalant (s : CompositionSeries X) (x : X) (hm : IsMaximal x s.top)
    (hb : s.bot ≤ x) :
    ∃ t : CompositionSeries X,
      t.bot = s.bot ∧ t.length + 1 = s.length ∧
      ∃ htx : t.top = x, Equivalent s (snoc t s.top (htx.symm ▸ hm)) := by
  induction' hn : s.length with n ih generalizing s x
  · exact
      (ne_of_gt (lt_of_le_of_lt hb (lt_of_isMaximal hm))
          (forall_mem_eq_of_length_eq_zero hn s.top_mem s.bot_mem)).elim
  · have h0s : 0 < s.length := hn.symm ▸ Nat.succ_pos _
    by_cases hetx : s.eraseTop.top = x
    · use s.eraseTop
      simp [← hetx, hn]
      -- Porting note: `rfl` is required.
      rfl
    · have imxs : IsMaximal (x ⊓ s.eraseTop.top) s.eraseTop.top :=
        isMaximal_of_eq_inf x s.top rfl (Ne.symm hetx) hm (isMaximal_eraseTop_top h0s)
      have := ih _ _ imxs (le_inf (by simpa) (le_top_of_mem s.eraseTop.bot_mem)) (by simp [hn])
      rcases this with ⟨t, htb, htl, htt, hteqv⟩
      have hmtx : IsMaximal t.top x :=
        isMaximal_of_eq_inf s.eraseTop.top s.top (by rw [inf_comm, htt]) hetx
          (isMaximal_eraseTop_top h0s) hm
      use snoc t x hmtx
      refine' ⟨by simp [htb], by simp [htl], by simp, _⟩
      have : s.Equivalent ((snoc t s.eraseTop.top (htt.symm ▸ imxs)).snoc s.top
          (by simpa using isMaximal_eraseTop_top h0s)) := by
        conv_lhs => 

Proof state:
X : Type u
inst✝¹ : Lattice X
inst✝ : JordanHolderLattice X
n : ℕ
ih :
  ∀ (s : CompositionSeries X) (x : X) (hm : IsMaximal x (top s)),
    bot s ≤ x →
      s.length = n →
        ∃ t,
          bot t = bot s ∧
            t.length + 1 = n ∧ ∃ (htx : top t = x), Equivalent s (snoc t (top s) (_ : IsMaximal (top t) (top s)))
s : CompositionSeries X
x : X
hm : IsMaximal x (top s)
hb : bot s ≤ x
hn : s.length = Nat.succ n
h0s : 0 < s.length
hetx : ¬top (eraseTop s) = x
imxs : IsMaximal (x ⊓ top (eraseTop s)) (top (eraseTop s))
t : CompositionSeries X
htb : bot t = bot (eraseTop s)
htl : t.length + 1 = n
htt : top t = x ⊓ top (eraseTop s)
hteqv : Equivalent (eraseTop s) (snoc t (top (eraseTop s)) (_ : IsMaximal (top t) (top (eraseTop s))))
hmtx : IsMaximal (top t) x
| s

Next tactic:
rw [eq_snoc_eraseTop h0s]