l3lab/ntp-mathlib huggingface dataset:
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
  by_cases h : i < Fin.last (n + 1)
  · use θ ≫ σ (Fin.castPred i)
    ext1
    ext1
    ext1 x
    simp only [Hom.toOrderHom_mk, Function.comp_apply, OrderHom.comp_coe, Hom.comp,
      smallCategory_comp]
    by_cases h' : θ.toOrderHom x ≤ i
    · simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
      -- This was not needed before leanprover/lean4#2644
      dsimp
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
          (by simpa [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      erw [Fin.succAbove_below i]
      swap
      · simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
        exact
          lt_of_le_of_lt (Fin.coe_castPred_le_self _)
            (Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
      rw [Fin.castSucc_castPred]
      apply lt_of_le_of_lt h' h
    · 

Proof state:
case neg
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : i < Fin.last (n + 1)
x : Fin (len Δ + 1)
h' : ¬(Hom.toOrderHom θ) x ≤ i
⊢ (Hom.toOrderHom θ) x = (Hom.toOrderHom (δ i)) ((Hom.toOrderHom (σ (Fin.castPred i))) ((Hom.toOrderHom θ) x))

Next tactic:
simp only [not_le] at h'
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
  by_cases h : i < Fin.last (n + 1)
  · use θ ≫ σ (Fin.castPred i)
    ext1
    ext1
    ext1 x
    simp only [Hom.toOrderHom_mk, Function.comp_apply, OrderHom.comp_coe, Hom.comp,
      smallCategory_comp]
    by_cases h' : θ.toOrderHom x ≤ i
    · simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
      -- This was not needed before leanprover/lean4#2644
      dsimp
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
          (by simpa [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      erw [Fin.succAbove_below i]
      swap
      · simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
        exact
          lt_of_le_of_lt (Fin.coe_castPred_le_self _)
            (Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
      rw [Fin.castSucc_castPred]
      apply lt_of_le_of_lt h' h
    · simp only [not_le] at h'
      -- The next three tactics used to be a simp only call before leanprover/lean4#2644
      

Proof state:
case neg
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : i < Fin.last (n + 1)
x : Fin (len Δ + 1)
h' : i < (Hom.toOrderHom θ) x
⊢ (Hom.toOrderHom θ) x = (Hom.toOrderHom (δ i)) ((Hom.toOrderHom (σ (Fin.castPred i))) ((Hom.toOrderHom θ) x))

Next tactic:
rw [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk, OrderHom.coe_mk]
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
  by_cases h : i < Fin.last (n + 1)
  · use θ ≫ σ (Fin.castPred i)
    ext1
    ext1
    ext1 x
    simp only [Hom.toOrderHom_mk, Function.comp_apply, OrderHom.comp_coe, Hom.comp,
      smallCategory_comp]
    by_cases h' : θ.toOrderHom x ≤ i
    · simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
      -- This was not needed before leanprover/lean4#2644
      dsimp
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
          (by simpa [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      erw [Fin.succAbove_below i]
      swap
      · simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
        exact
          lt_of_le_of_lt (Fin.coe_castPred_le_self _)
            (Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
      rw [Fin.castSucc_castPred]
      apply lt_of_le_of_lt h' h
    · simp only [not_le] at h'
      -- The next three tactics used to be a simp only call before leanprover/lean4#2644
      rw [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk, OrderHom.coe_mk]
      

Proof state:
case neg
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : i < Fin.last (n + 1)
x : Fin (len Δ + 1)
h' : i < (Hom.toOrderHom θ) x
⊢ OrderHom.toFun (Hom.toOrderHom θ) x =
    OrderHom.toFun (Hom.toOrderHom (δ i))
      ({ toFun := Fin.predAbove (Fin.castPred i), monotone' := (_ : Monotone (Fin.predAbove (Fin.castPred i))) }
        (OrderHom.toFun (Hom.toOrderHom θ) x))

Next tactic:
erw [OrderHom.coe_mk]
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
  by_cases h : i < Fin.last (n + 1)
  · use θ ≫ σ (Fin.castPred i)
    ext1
    ext1
    ext1 x
    simp only [Hom.toOrderHom_mk, Function.comp_apply, OrderHom.comp_coe, Hom.comp,
      smallCategory_comp]
    by_cases h' : θ.toOrderHom x ≤ i
    · simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
      -- This was not needed before leanprover/lean4#2644
      dsimp
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
          (by simpa [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      erw [Fin.succAbove_below i]
      swap
      · simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
        exact
          lt_of_le_of_lt (Fin.coe_castPred_le_self _)
            (Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
      rw [Fin.castSucc_castPred]
      apply lt_of_le_of_lt h' h
    · simp only [not_le] at h'
      -- The next three tactics used to be a simp only call before leanprover/lean4#2644
      rw [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk, OrderHom.coe_mk]
      erw [OrderHom.coe_mk]
      

Proof state:
case neg
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : i < Fin.last (n + 1)
x : Fin (len Δ + 1)
h' : i < (Hom.toOrderHom θ) x
⊢ OrderHom.toFun (Hom.toOrderHom θ) x =
    OrderHom.toFun (Hom.toOrderHom (δ i)) (Fin.predAbove (Fin.castPred i) (OrderHom.toFun (Hom.toOrderHom θ) x))

Next tactic:
erw [Fin.predAbove_above (Fin.castPred i) (θ.toOrderHom x)
          (by simpa only [Fin.castSucc_castPred h] using h')]
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
  by_cases h : i < Fin.last (n + 1)
  · use θ ≫ σ (Fin.castPred i)
    ext1
    ext1
    ext1 x
    simp only [Hom.toOrderHom_mk, Function.comp_apply, OrderHom.comp_coe, Hom.comp,
      smallCategory_comp]
    by_cases h' : θ.toOrderHom x ≤ i
    · simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
      -- This was not needed before leanprover/lean4#2644
      dsimp
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
          (by simpa [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      erw [Fin.succAbove_below i]
      swap
      · simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
        exact
          lt_of_le_of_lt (Fin.coe_castPred_le_self _)
            (Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
      rw [Fin.castSucc_castPred]
      apply lt_of_le_of_lt h' h
    · simp only [not_le] at h'
      -- The next three tactics used to be a simp only call before leanprover/lean4#2644
      rw [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk, OrderHom.coe_mk]
      erw [OrderHom.coe_mk]
      erw [Fin.predAbove_above (Fin.castPred i) (θ.toOrderHom x)
          (by 

Proof state:
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : i < Fin.last (n + 1)
x : Fin (len Δ + 1)
h' : i < (Hom.toOrderHom θ) x
⊢ Fin.castSucc (Fin.castPred i) < (Hom.toOrderHom θ) x

Next tactic:
simpa only [Fin.castSucc_castPred h] using h'
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
  by_cases h : i < Fin.last (n + 1)
  · use θ ≫ σ (Fin.castPred i)
    ext1
    ext1
    ext1 x
    simp only [Hom.toOrderHom_mk, Function.comp_apply, OrderHom.comp_coe, Hom.comp,
      smallCategory_comp]
    by_cases h' : θ.toOrderHom x ≤ i
    · simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
      -- This was not needed before leanprover/lean4#2644
      dsimp
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
          (by simpa [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      erw [Fin.succAbove_below i]
      swap
      · simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
        exact
          lt_of_le_of_lt (Fin.coe_castPred_le_self _)
            (Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
      rw [Fin.castSucc_castPred]
      apply lt_of_le_of_lt h' h
    · simp only [not_le] at h'
      -- The next three tactics used to be a simp only call before leanprover/lean4#2644
      rw [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk, OrderHom.coe_mk]
      erw [OrderHom.coe_mk]
      erw [Fin.predAbove_above (Fin.castPred i) (θ.toOrderHom x)
          (by simpa only [Fin.castSucc_castPred h] using h')]
      

Proof state:
case neg
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : i < Fin.last (n + 1)
x : Fin (len Δ + 1)
h' : i < (Hom.toOrderHom θ) x
⊢ OrderHom.toFun (Hom.toOrderHom θ) x =
    OrderHom.toFun (Hom.toOrderHom (δ i)) (Fin.pred ((Hom.toOrderHom θ) x) (_ : (Hom.toOrderHom θ) x ≠ 0))

Next tactic:
dsimp [δ]
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
  by_cases h : i < Fin.last (n + 1)
  · use θ ≫ σ (Fin.castPred i)
    ext1
    ext1
    ext1 x
    simp only [Hom.toOrderHom_mk, Function.comp_apply, OrderHom.comp_coe, Hom.comp,
      smallCategory_comp]
    by_cases h' : θ.toOrderHom x ≤ i
    · simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
      -- This was not needed before leanprover/lean4#2644
      dsimp
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
          (by simpa [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      erw [Fin.succAbove_below i]
      swap
      · simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
        exact
          lt_of_le_of_lt (Fin.coe_castPred_le_self _)
            (Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
      rw [Fin.castSucc_castPred]
      apply lt_of_le_of_lt h' h
    · simp only [not_le] at h'
      -- The next three tactics used to be a simp only call before leanprover/lean4#2644
      rw [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk, OrderHom.coe_mk]
      erw [OrderHom.coe_mk]
      erw [Fin.predAbove_above (Fin.castPred i) (θ.toOrderHom x)
          (by simpa only [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      

Proof state:
case neg
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : i < Fin.last (n + 1)
x : Fin (len Δ + 1)
h' : i < (Hom.toOrderHom θ) x
⊢ (Hom.toOrderHom θ) x = Fin.succAbove i (Fin.pred ((Hom.toOrderHom θ) x) (_ : (Hom.toOrderHom θ) x ≠ 0))

Next tactic:
rw [Fin.succAbove_above i _]
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
  by_cases h : i < Fin.last (n + 1)
  · use θ ≫ σ (Fin.castPred i)
    ext1
    ext1
    ext1 x
    simp only [Hom.toOrderHom_mk, Function.comp_apply, OrderHom.comp_coe, Hom.comp,
      smallCategory_comp]
    by_cases h' : θ.toOrderHom x ≤ i
    · simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
      -- This was not needed before leanprover/lean4#2644
      dsimp
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
          (by simpa [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      erw [Fin.succAbove_below i]
      swap
      · simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
        exact
          lt_of_le_of_lt (Fin.coe_castPred_le_self _)
            (Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
      rw [Fin.castSucc_castPred]
      apply lt_of_le_of_lt h' h
    · simp only [not_le] at h'
      -- The next three tactics used to be a simp only call before leanprover/lean4#2644
      rw [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk, OrderHom.coe_mk]
      erw [OrderHom.coe_mk]
      erw [Fin.predAbove_above (Fin.castPred i) (θ.toOrderHom x)
          (by simpa only [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      rw [Fin.succAbove_above i _]
      -- This was not needed before leanprover/lean4#2644
      

Proof state:
case neg
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : i < Fin.last (n + 1)
x : Fin (len Δ + 1)
h' : i < (Hom.toOrderHom θ) x
⊢ (Hom.toOrderHom θ) x = Fin.succ (Fin.pred ((Hom.toOrderHom θ) x) (_ : (Hom.toOrderHom θ) x ≠ 0))
case neg
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : i < Fin.last (n + 1)
x : Fin (len Δ + 1)
h' : i < (Hom.toOrderHom θ) x
⊢ i ≤ Fin.castSucc (Fin.pred ((Hom.toOrderHom θ) x) (_ : (Hom.toOrderHom θ) x ≠ 0))

Next tactic:
conv_rhs => dsimp
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
  by_cases h : i < Fin.last (n + 1)
  · use θ ≫ σ (Fin.castPred i)
    ext1
    ext1
    ext1 x
    simp only [Hom.toOrderHom_mk, Function.comp_apply, OrderHom.comp_coe, Hom.comp,
      smallCategory_comp]
    by_cases h' : θ.toOrderHom x ≤ i
    · simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
      -- This was not needed before leanprover/lean4#2644
      dsimp
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
          (by simpa [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      erw [Fin.succAbove_below i]
      swap
      · simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
        exact
          lt_of_le_of_lt (Fin.coe_castPred_le_self _)
            (Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
      rw [Fin.castSucc_castPred]
      apply lt_of_le_of_lt h' h
    · simp only [not_le] at h'
      -- The next three tactics used to be a simp only call before leanprover/lean4#2644
      rw [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk, OrderHom.coe_mk]
      erw [OrderHom.coe_mk]
      erw [Fin.predAbove_above (Fin.castPred i) (θ.toOrderHom x)
          (by simpa only [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      rw [Fin.succAbove_above i _]
      -- This was not needed before leanprover/lean4#2644
      conv_rhs => 

Proof state:
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : i < Fin.last (n + 1)
x : Fin (len Δ + 1)
h' : i < (Hom.toOrderHom θ) x
| Fin.succ (Fin.pred ((Hom.toOrderHom θ) x) (_ : (Hom.toOrderHom θ) x ≠ 0))

Next tactic:
dsimp
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
  by_cases h : i < Fin.last (n + 1)
  · use θ ≫ σ (Fin.castPred i)
    ext1
    ext1
    ext1 x
    simp only [Hom.toOrderHom_mk, Function.comp_apply, OrderHom.comp_coe, Hom.comp,
      smallCategory_comp]
    by_cases h' : θ.toOrderHom x ≤ i
    · simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
      -- This was not needed before leanprover/lean4#2644
      dsimp
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
          (by simpa [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      erw [Fin.succAbove_below i]
      swap
      · simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
        exact
          lt_of_le_of_lt (Fin.coe_castPred_le_self _)
            (Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
      rw [Fin.castSucc_castPred]
      apply lt_of_le_of_lt h' h
    · simp only [not_le] at h'
      -- The next three tactics used to be a simp only call before leanprover/lean4#2644
      rw [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk, OrderHom.coe_mk]
      erw [OrderHom.coe_mk]
      erw [Fin.predAbove_above (Fin.castPred i) (θ.toOrderHom x)
          (by simpa only [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      rw [Fin.succAbove_above i _]
      -- This was not needed before leanprover/lean4#2644
      conv_rhs => dsimp
      

Proof state:
case neg
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : i < Fin.last (n + 1)
x : Fin (len Δ + 1)
h' : i < (Hom.toOrderHom θ) x
⊢ (Hom.toOrderHom θ) x = Fin.succ (Fin.pred ((Hom.toOrderHom θ) x) (_ : (Hom.toOrderHom θ) x ≠ 0))
case neg
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : i < Fin.last (n + 1)
x : Fin (len Δ + 1)
h' : i < (Hom.toOrderHom θ) x
⊢ i ≤ Fin.castSucc (Fin.pred ((Hom.toOrderHom θ) x) (_ : (Hom.toOrderHom θ) x ≠ 0))

Next tactic:
erw [Fin.succ_pred]
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
  by_cases h : i < Fin.last (n + 1)
  · use θ ≫ σ (Fin.castPred i)
    ext1
    ext1
    ext1 x
    simp only [Hom.toOrderHom_mk, Function.comp_apply, OrderHom.comp_coe, Hom.comp,
      smallCategory_comp]
    by_cases h' : θ.toOrderHom x ≤ i
    · simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
      -- This was not needed before leanprover/lean4#2644
      dsimp
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
          (by simpa [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      erw [Fin.succAbove_below i]
      swap
      · simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
        exact
          lt_of_le_of_lt (Fin.coe_castPred_le_self _)
            (Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
      rw [Fin.castSucc_castPred]
      apply lt_of_le_of_lt h' h
    · simp only [not_le] at h'
      -- The next three tactics used to be a simp only call before leanprover/lean4#2644
      rw [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk, OrderHom.coe_mk]
      erw [OrderHom.coe_mk]
      erw [Fin.predAbove_above (Fin.castPred i) (θ.toOrderHom x)
          (by simpa only [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      rw [Fin.succAbove_above i _]
      -- This was not needed before leanprover/lean4#2644
      conv_rhs => dsimp
      erw [Fin.succ_pred]
      

Proof state:
case neg
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : i < Fin.last (n + 1)
x : Fin (len Δ + 1)
h' : i < (Hom.toOrderHom θ) x
⊢ i ≤ Fin.castSucc (Fin.pred ((Hom.toOrderHom θ) x) (_ : (Hom.toOrderHom θ) x ≠ 0))

Next tactic:
simpa only [Fin.le_iff_val_le_val, Fin.coe_castSucc, Fin.coe_pred] using
        Nat.le_sub_one_of_lt (Fin.lt_iff_val_lt_val.mp h')
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
  by_cases h : i < Fin.last (n + 1)
  · use θ ≫ σ (Fin.castPred i)
    ext1
    ext1
    ext1 x
    simp only [Hom.toOrderHom_mk, Function.comp_apply, OrderHom.comp_coe, Hom.comp,
      smallCategory_comp]
    by_cases h' : θ.toOrderHom x ≤ i
    · simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
      -- This was not needed before leanprover/lean4#2644
      dsimp
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
          (by simpa [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      erw [Fin.succAbove_below i]
      swap
      · simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
        exact
          lt_of_le_of_lt (Fin.coe_castPred_le_self _)
            (Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
      rw [Fin.castSucc_castPred]
      apply lt_of_le_of_lt h' h
    · simp only [not_le] at h'
      -- The next three tactics used to be a simp only call before leanprover/lean4#2644
      rw [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk, OrderHom.coe_mk]
      erw [OrderHom.coe_mk]
      erw [Fin.predAbove_above (Fin.castPred i) (θ.toOrderHom x)
          (by simpa only [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      rw [Fin.succAbove_above i _]
      -- This was not needed before leanprover/lean4#2644
      conv_rhs => dsimp
      erw [Fin.succ_pred]
      simpa only [Fin.le_iff_val_le_val, Fin.coe_castSucc, Fin.coe_pred] using
        Nat.le_sub_one_of_lt (Fin.lt_iff_val_lt_val.mp h')
  · 

Proof state:
case neg
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
i : Fin (n + 2)
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ i
h : ¬i < Fin.last (n + 1)
⊢ ∃ θ', θ = θ' ≫ δ i

Next tactic:
obtain rfl := le_antisymm (Fin.le_last i) (not_lt.mp h)
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
  by_cases h : i < Fin.last (n + 1)
  · use θ ≫ σ (Fin.castPred i)
    ext1
    ext1
    ext1 x
    simp only [Hom.toOrderHom_mk, Function.comp_apply, OrderHom.comp_coe, Hom.comp,
      smallCategory_comp]
    by_cases h' : θ.toOrderHom x ≤ i
    · simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
      -- This was not needed before leanprover/lean4#2644
      dsimp
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
          (by simpa [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      erw [Fin.succAbove_below i]
      swap
      · simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
        exact
          lt_of_le_of_lt (Fin.coe_castPred_le_self _)
            (Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
      rw [Fin.castSucc_castPred]
      apply lt_of_le_of_lt h' h
    · simp only [not_le] at h'
      -- The next three tactics used to be a simp only call before leanprover/lean4#2644
      rw [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk, OrderHom.coe_mk]
      erw [OrderHom.coe_mk]
      erw [Fin.predAbove_above (Fin.castPred i) (θ.toOrderHom x)
          (by simpa only [Fin.castSucc_castPred h] using h')]
      dsimp [δ]
      rw [Fin.succAbove_above i _]
      -- This was not needed before leanprover/lean4#2644
      conv_rhs => dsimp
      erw [Fin.succ_pred]
      simpa only [Fin.le_iff_val_le_val, Fin.coe_castSucc, Fin.coe_pred] using
        Nat.le_sub_one_of_lt (Fin.lt_iff_val_lt_val.mp h')
  · obtain rfl := le_antisymm (Fin.le_last i) (not_lt.mp h)
    

Proof state:
case neg
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
hi : ∀ (x : Fin (len Δ + 1)), (Hom.toOrderHom θ) x ≠ Fin.last (n + 1)
h : ¬Fin.last (n + 1) < Fin.last (n + 1)
⊢ ∃ θ', θ = θ' ≫ δ (Fin.last (n + 1))

Next tactic:
use θ ≫ σ (Fin.last _)