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
    · 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)
    use θ ≫ σ (Fin.last _)
    

Proof state:
case h
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)) ≫ δ (Fin.last (n + 1))

Next tactic:
ext x : 4
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)
    use θ ≫ σ (Fin.last _)
    ext x : 4
    

Proof state:
case h.a.h.h.h
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)
x : Fin (len Δ + 1)
⊢ ↑((Hom.toOrderHom θ) x) = ↑((Hom.toOrderHom ((θ ≫ σ (Fin.last n)) ≫ δ (Fin.last (n + 1)))) x)

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
      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)
    use θ ≫ σ (Fin.last _)
    ext x : 4
    dsimp [δ, σ]
    

Proof state:
case h.a.h.h.h
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)
x : Fin (len Δ + 1)
⊢ ↑((Hom.toOrderHom θ) x) = ↑(Fin.succAbove (Fin.last (n + 1)) (Fin.castPred ((Hom.toOrderHom θ) x)))

Next tactic:
dsimp only [Fin.castPred]
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)
    use θ ≫ σ (Fin.last _)
    ext x : 4
    dsimp [δ, σ]
    dsimp only [Fin.castPred]
    

Proof state:
case h.a.h.h.h
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)
x : Fin (len Δ + 1)
⊢ ↑((Hom.toOrderHom θ) x) = ↑(Fin.succAbove (Fin.last (n + 1)) (Fin.predAbove (Fin.last n) ((Hom.toOrderHom θ) x)))

Next tactic:
rw [Fin.predAbove_last, Fin.succAbove_last, Fin.castSucc_castPred]
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)
    use θ ≫ σ (Fin.last _)
    ext x : 4
    dsimp [δ, σ]
    dsimp only [Fin.castPred]
    rw [Fin.predAbove_last, Fin.succAbove_last, Fin.castSucc_castPred]
    

Proof state:
case h.a.h.h.h
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)
x : Fin (len Δ + 1)
⊢ (Hom.toOrderHom θ) x < Fin.last (n + 1)

Next tactic:
exact (Ne.le_iff_lt (hi x)).mp (Fin.le_last _)
theorem eq_comp_δ_of_not_surjective {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (hθ : ¬Function.Surjective θ.toOrderHom) :
    ∃ (i : Fin (n + 2)) (θ' : Δ ⟶ mk n), θ = θ' ≫ δ i := by
  

Proof state:
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
hθ : ¬Function.Surjective ⇑(Hom.toOrderHom θ)
⊢ ∃ i θ', θ = θ' ≫ δ i

Next tactic:
cases' not_forall.mp hθ with i hi
theorem eq_comp_δ_of_not_surjective {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (hθ : ¬Function.Surjective θ.toOrderHom) :
    ∃ (i : Fin (n + 2)) (θ' : Δ ⟶ mk n), θ = θ' ≫ δ i := by
  cases' not_forall.mp hθ with i hi
  

Proof state:
case intro
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
hθ : ¬Function.Surjective ⇑(Hom.toOrderHom θ)
i : Fin (len [n + 1] + 1)
hi : ¬∃ a, (Hom.toOrderHom θ) a = i
⊢ ∃ i θ', θ = θ' ≫ δ i

Next tactic:
use i
theorem eq_comp_δ_of_not_surjective {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
    (hθ : ¬Function.Surjective θ.toOrderHom) :
    ∃ (i : Fin (n + 2)) (θ' : Δ ⟶ mk n), θ = θ' ≫ δ i := by
  cases' not_forall.mp hθ with i hi
  use i
  

Proof state:
case h
n : ℕ
Δ : SimplexCategory
θ : Δ ⟶ [n + 1]
hθ : ¬Function.Surjective ⇑(Hom.toOrderHom θ)
i : Fin (len [n + 1] + 1)
hi : ¬∃ a, (Hom.toOrderHom θ) a = i
⊢ ∃ θ', θ = θ' ≫ δ i

Next tactic:
exact eq_comp_δ_of_not_surjective' θ i (not_exists.mp hi)
theorem eq_id_of_mono {x : SimplexCategory} (i : x ⟶ x) [Mono i] : i = 𝟙 _ := by
  

Proof state:
x : SimplexCategory
i : x ⟶ x
inst✝ : Mono i
⊢ i = 𝟙 x

Next tactic:
suffices IsIso i by
    apply eq_id_of_isIso
theorem eq_id_of_mono {x : SimplexCategory} (i : x ⟶ x) [Mono i] : i = 𝟙 _ := by
  suffices IsIso i by
    

Proof state:
x : SimplexCategory
i : x ⟶ x
inst✝ : Mono i
this : IsIso i
⊢ i = 𝟙 x

Next tactic:
apply eq_id_of_isIso
theorem eq_id_of_mono {x : SimplexCategory} (i : x ⟶ x) [Mono i] : i = 𝟙 _ := by
  suffices IsIso i by
    apply eq_id_of_isIso
  

Proof state:
x : SimplexCategory
i : x ⟶ x
inst✝ : Mono i
⊢ IsIso i

Next tactic:
apply isIso_of_bijective
theorem eq_id_of_mono {x : SimplexCategory} (i : x ⟶ x) [Mono i] : i = 𝟙 _ := by
  suffices IsIso i by
    apply eq_id_of_isIso
  apply isIso_of_bijective
  

Proof state:
case hf
x : SimplexCategory
i : x ⟶ x
inst✝ : Mono i
⊢ Function.Bijective (Hom.toOrderHom i).toFun

Next tactic:
dsimp
theorem eq_id_of_mono {x : SimplexCategory} (i : x ⟶ x) [Mono i] : i = 𝟙 _ := by
  suffices IsIso i by
    apply eq_id_of_isIso
  apply isIso_of_bijective
  dsimp
  

Proof state:
case hf
x : SimplexCategory
i : x ⟶ x
inst✝ : Mono i
⊢ Function.Bijective ⇑(Hom.toOrderHom i)

Next tactic:
rw [Fintype.bijective_iff_injective_and_card i.toOrderHom, ← mono_iff_injective,
    eq_self_iff_true, and_true_iff]
theorem eq_id_of_mono {x : SimplexCategory} (i : x ⟶ x) [Mono i] : i = 𝟙 _ := by
  suffices IsIso i by
    apply eq_id_of_isIso
  apply isIso_of_bijective
  dsimp
  rw [Fintype.bijective_iff_injective_and_card i.toOrderHom, ← mono_iff_injective,
    eq_self_iff_true, and_true_iff]
  

Proof state:
case hf
x : SimplexCategory
i : x ⟶ x
inst✝ : Mono i
⊢ Mono i

Next tactic:
infer_instance
theorem eq_id_of_epi {x : SimplexCategory} (i : x ⟶ x) [Epi i] : i = 𝟙 _ := by
  

Proof state:
x : SimplexCategory
i : x ⟶ x
inst✝ : Epi i
⊢ i = 𝟙 x

Next tactic:
suffices IsIso i by
    haveI := this
    apply eq_id_of_isIso
theorem eq_id_of_epi {x : SimplexCategory} (i : x ⟶ x) [Epi i] : i = 𝟙 _ := by
  suffices IsIso i by
    

Proof state:
x : SimplexCategory
i : x ⟶ x
inst✝ : Epi i
this : IsIso i
⊢ i = 𝟙 x

Next tactic:
haveI := this
theorem eq_id_of_epi {x : SimplexCategory} (i : x ⟶ x) [Epi i] : i = 𝟙 _ := by
  suffices IsIso i by
    haveI := this
    

Proof state:
x : SimplexCategory
i : x ⟶ x
inst✝ : Epi i
this✝ this : IsIso i
⊢ i = 𝟙 x

Next tactic:
apply eq_id_of_isIso
theorem eq_id_of_epi {x : SimplexCategory} (i : x ⟶ x) [Epi i] : i = 𝟙 _ := by
  suffices IsIso i by
    haveI := this
    apply eq_id_of_isIso
  

Proof state:
x : SimplexCategory
i : x ⟶ x
inst✝ : Epi i
⊢ IsIso i

Next tactic:
apply isIso_of_bijective
theorem eq_id_of_epi {x : SimplexCategory} (i : x ⟶ x) [Epi i] : i = 𝟙 _ := by
  suffices IsIso i by
    haveI := this
    apply eq_id_of_isIso
  apply isIso_of_bijective
  

Proof state:
case hf
x : SimplexCategory
i : x ⟶ x
inst✝ : Epi i
⊢ Function.Bijective (Hom.toOrderHom i).toFun

Next tactic:
dsimp
theorem eq_id_of_epi {x : SimplexCategory} (i : x ⟶ x) [Epi i] : i = 𝟙 _ := by
  suffices IsIso i by
    haveI := this
    apply eq_id_of_isIso
  apply isIso_of_bijective
  dsimp
  

Proof state:
case hf
x : SimplexCategory
i : x ⟶ x
inst✝ : Epi i
⊢ Function.Bijective ⇑(Hom.toOrderHom i)

Next tactic:
rw [Fintype.bijective_iff_surjective_and_card i.toOrderHom, ← epi_iff_surjective,
    eq_self_iff_true, and_true_iff]
theorem eq_id_of_epi {x : SimplexCategory} (i : x ⟶ x) [Epi i] : i = 𝟙 _ := by
  suffices IsIso i by
    haveI := this
    apply eq_id_of_isIso
  apply isIso_of_bijective
  dsimp
  rw [Fintype.bijective_iff_surjective_and_card i.toOrderHom, ← epi_iff_surjective,
    eq_self_iff_true, and_true_iff]
  

Proof state:
case hf
x : SimplexCategory
i : x ⟶ x
inst✝ : Epi i
⊢ Epi i

Next tactic:
infer_instance
theorem eq_σ_of_epi {n : ℕ} (θ : mk (n + 1) ⟶ mk n) [Epi θ] : ∃ i : Fin (n + 1), θ = σ i := by
  

Proof state:
n : ℕ
θ : [n + 1] ⟶ [n]
inst✝ : Epi θ
⊢ ∃ i, θ = σ i

Next tactic:
rcases eq_σ_comp_of_not_injective θ (by
    by_contra h
    simpa using le_of_mono (mono_iff_injective.mpr h)) with ⟨i, θ', h⟩
theorem eq_σ_of_epi {n : ℕ} (θ : mk (n + 1) ⟶ mk n) [Epi θ] : ∃ i : Fin (n + 1), θ = σ i := by
  rcases eq_σ_comp_of_not_injective θ (by
    

Proof state:
n : ℕ
θ : [n + 1] ⟶ [n]
inst✝ : Epi θ
⊢ ¬Function.Injective ⇑(Hom.toOrderHom θ)

Next tactic:
by_contra h
theorem eq_σ_of_epi {n : ℕ} (θ : mk (n + 1) ⟶ mk n) [Epi θ] : ∃ i : Fin (n + 1), θ = σ i := by
  rcases eq_σ_comp_of_not_injective θ (by
    by_contra h
    

Proof state:
n : ℕ
θ : [n + 1] ⟶ [n]
inst✝ : Epi θ
h : Function.Injective ⇑(Hom.toOrderHom θ)
⊢ False

Next tactic:
simpa using le_of_mono (mono_iff_injective.mpr h)
theorem eq_σ_of_epi {n : ℕ} (θ : mk (n + 1) ⟶ mk n) [Epi θ] : ∃ i : Fin (n + 1), θ = σ i := by
  rcases eq_σ_comp_of_not_injective θ (by
    by_contra h
    simpa using le_of_mono (mono_iff_injective.mpr h)) with ⟨i, θ', h⟩
  

Proof state:
case intro.intro
n : ℕ
θ : [n + 1] ⟶ [n]
inst✝ : Epi θ
i : Fin (n + 1)
θ' : [n] ⟶ [n]
h : θ = σ i ≫ θ'
⊢ ∃ i, θ = σ i

Next tactic:
use i
theorem eq_σ_of_epi {n : ℕ} (θ : mk (n + 1) ⟶ mk n) [Epi θ] : ∃ i : Fin (n + 1), θ = σ i := by
  rcases eq_σ_comp_of_not_injective θ (by
    by_contra h
    simpa using le_of_mono (mono_iff_injective.mpr h)) with ⟨i, θ', h⟩
  use i
  

Proof state:
case h
n : ℕ
θ : [n + 1] ⟶ [n]
inst✝ : Epi θ
i : Fin (n + 1)
θ' : [n] ⟶ [n]
h : θ = σ i ≫ θ'
⊢ θ = σ i

Next tactic:
haveI : Epi (σ i ≫ θ') := by
    rw [← h]
    infer_instance
theorem eq_σ_of_epi {n : ℕ} (θ : mk (n + 1) ⟶ mk n) [Epi θ] : ∃ i : Fin (n + 1), θ = σ i := by
  rcases eq_σ_comp_of_not_injective θ (by
    by_contra h
    simpa using le_of_mono (mono_iff_injective.mpr h)) with ⟨i, θ', h⟩
  use i
  haveI : Epi (σ i ≫ θ') := by
    

Proof state:
n : ℕ
θ : [n + 1] ⟶ [n]
inst✝ : Epi θ
i : Fin (n + 1)
θ' : [n] ⟶ [n]
h : θ = σ i ≫ θ'
⊢ Epi (σ i ≫ θ')

Next tactic:
rw [← h]
theorem eq_σ_of_epi {n : ℕ} (θ : mk (n + 1) ⟶ mk n) [Epi θ] : ∃ i : Fin (n + 1), θ = σ i := by
  rcases eq_σ_comp_of_not_injective θ (by
    by_contra h
    simpa using le_of_mono (mono_iff_injective.mpr h)) with ⟨i, θ', h⟩
  use i
  haveI : Epi (σ i ≫ θ') := by
    rw [← h]
    

Proof state:
n : ℕ
θ : [n + 1] ⟶ [n]
inst✝ : Epi θ
i : Fin (n + 1)
θ' : [n] ⟶ [n]
h : θ = σ i ≫ θ'
⊢ Epi θ

Next tactic:
infer_instance
theorem eq_σ_of_epi {n : ℕ} (θ : mk (n + 1) ⟶ mk n) [Epi θ] : ∃ i : Fin (n + 1), θ = σ i := by
  rcases eq_σ_comp_of_not_injective θ (by
    by_contra h
    simpa using le_of_mono (mono_iff_injective.mpr h)) with ⟨i, θ', h⟩
  use i
  haveI : Epi (σ i ≫ θ') := by
    rw [← h]
    infer_instance
  

Proof state:
case h
n : ℕ
θ : [n + 1] ⟶ [n]
inst✝ : Epi θ
i : Fin (n + 1)
θ' : [n] ⟶ [n]
h : θ = σ i ≫ θ'
this : Epi (σ i ≫ θ')
⊢ θ = σ i

Next tactic:
haveI := CategoryTheory.epi_of_epi (σ i) θ'
theorem eq_σ_of_epi {n : ℕ} (θ : mk (n + 1) ⟶ mk n) [Epi θ] : ∃ i : Fin (n + 1), θ = σ i := by
  rcases eq_σ_comp_of_not_injective θ (by
    by_contra h
    simpa using le_of_mono (mono_iff_injective.mpr h)) with ⟨i, θ', h⟩
  use i
  haveI : Epi (σ i ≫ θ') := by
    rw [← h]
    infer_instance
  haveI := CategoryTheory.epi_of_epi (σ i) θ'
  

Proof state:
case h
n : ℕ
θ : [n + 1] ⟶ [n]
inst✝ : Epi θ
i : Fin (n + 1)
θ' : [n] ⟶ [n]
h : θ = σ i ≫ θ'
this✝ : Epi (σ i ≫ θ')
this : Epi θ'
⊢ θ = σ i

Next tactic:
rw [h, eq_id_of_epi θ', Category.comp_id]
theorem eq_δ_of_mono {n : ℕ} (θ : mk n ⟶ mk (n + 1)) [Mono θ] : ∃ i : Fin (n + 2), θ = δ i := by
  

Proof state:
n : ℕ
θ : [n] ⟶ [n + 1]
inst✝ : Mono θ
⊢ ∃ i, θ = δ i

Next tactic:
rcases eq_comp_δ_of_not_surjective θ (by
    by_contra h
    simpa using le_of_epi (epi_iff_surjective.mpr h)) with ⟨i, θ', h⟩
theorem eq_δ_of_mono {n : ℕ} (θ : mk n ⟶ mk (n + 1)) [Mono θ] : ∃ i : Fin (n + 2), θ = δ i := by
  rcases eq_comp_δ_of_not_surjective θ (by
    

Proof state:
n : ℕ
θ : [n] ⟶ [n + 1]
inst✝ : Mono θ
⊢ ¬Function.Surjective ⇑(Hom.toOrderHom θ)

Next tactic:
by_contra h
theorem eq_δ_of_mono {n : ℕ} (θ : mk n ⟶ mk (n + 1)) [Mono θ] : ∃ i : Fin (n + 2), θ = δ i := by
  rcases eq_comp_δ_of_not_surjective θ (by
    by_contra h
    

Proof state:
n : ℕ
θ : [n] ⟶ [n + 1]
inst✝ : Mono θ
h : Function.Surjective ⇑(Hom.toOrderHom θ)
⊢ False

Next tactic:
simpa using le_of_epi (epi_iff_surjective.mpr h)
theorem eq_δ_of_mono {n : ℕ} (θ : mk n ⟶ mk (n + 1)) [Mono θ] : ∃ i : Fin (n + 2), θ = δ i := by
  rcases eq_comp_δ_of_not_surjective θ (by
    by_contra h
    simpa using le_of_epi (epi_iff_surjective.mpr h)) with ⟨i, θ', h⟩
  

Proof state:
case intro.intro
n : ℕ
θ : [n] ⟶ [n + 1]
inst✝ : Mono θ
i : Fin (n + 2)
θ' : [n] ⟶ [n]
h : θ = θ' ≫ δ i
⊢ ∃ i, θ = δ i

Next tactic:
use i
theorem eq_δ_of_mono {n : ℕ} (θ : mk n ⟶ mk (n + 1)) [Mono θ] : ∃ i : Fin (n + 2), θ = δ i := by
  rcases eq_comp_δ_of_not_surjective θ (by
    by_contra h
    simpa using le_of_epi (epi_iff_surjective.mpr h)) with ⟨i, θ', h⟩
  use i
  

Proof state:
case h
n : ℕ
θ : [n] ⟶ [n + 1]
inst✝ : Mono θ
i : Fin (n + 2)
θ' : [n] ⟶ [n]
h : θ = θ' ≫ δ i
⊢ θ = δ i

Next tactic:
haveI : Mono (θ' ≫ δ i) := by
    rw [← h]
    infer_instance
theorem eq_δ_of_mono {n : ℕ} (θ : mk n ⟶ mk (n + 1)) [Mono θ] : ∃ i : Fin (n + 2), θ = δ i := by
  rcases eq_comp_δ_of_not_surjective θ (by
    by_contra h
    simpa using le_of_epi (epi_iff_surjective.mpr h)) with ⟨i, θ', h⟩
  use i
  haveI : Mono (θ' ≫ δ i) := by
    

Proof state:
n : ℕ
θ : [n] ⟶ [n + 1]
inst✝ : Mono θ
i : Fin (n + 2)
θ' : [n] ⟶ [n]
h : θ = θ' ≫ δ i
⊢ Mono (θ' ≫ δ i)

Next tactic:
rw [← h]
theorem eq_δ_of_mono {n : ℕ} (θ : mk n ⟶ mk (n + 1)) [Mono θ] : ∃ i : Fin (n + 2), θ = δ i := by
  rcases eq_comp_δ_of_not_surjective θ (by
    by_contra h
    simpa using le_of_epi (epi_iff_surjective.mpr h)) with ⟨i, θ', h⟩
  use i
  haveI : Mono (θ' ≫ δ i) := by
    rw [← h]
    

Proof state:
n : ℕ
θ : [n] ⟶ [n + 1]
inst✝ : Mono θ
i : Fin (n + 2)
θ' : [n] ⟶ [n]
h : θ = θ' ≫ δ i
⊢ Mono θ

Next tactic:
infer_instance
theorem eq_δ_of_mono {n : ℕ} (θ : mk n ⟶ mk (n + 1)) [Mono θ] : ∃ i : Fin (n + 2), θ = δ i := by
  rcases eq_comp_δ_of_not_surjective θ (by
    by_contra h
    simpa using le_of_epi (epi_iff_surjective.mpr h)) with ⟨i, θ', h⟩
  use i
  haveI : Mono (θ' ≫ δ i) := by
    rw [← h]
    infer_instance
  

Proof state:
case h
n : ℕ
θ : [n] ⟶ [n + 1]
inst✝ : Mono θ
i : Fin (n + 2)
θ' : [n] ⟶ [n]
h : θ = θ' ≫ δ i
this : Mono (θ' ≫ δ i)
⊢ θ = δ i

Next tactic:
haveI := CategoryTheory.mono_of_mono θ' (δ i)
theorem eq_δ_of_mono {n : ℕ} (θ : mk n ⟶ mk (n + 1)) [Mono θ] : ∃ i : Fin (n + 2), θ = δ i := by
  rcases eq_comp_δ_of_not_surjective θ (by
    by_contra h
    simpa using le_of_epi (epi_iff_surjective.mpr h)) with ⟨i, θ', h⟩
  use i
  haveI : Mono (θ' ≫ δ i) := by
    rw [← h]
    infer_instance
  haveI := CategoryTheory.mono_of_mono θ' (δ i)
  

Proof state:
case h
n : ℕ
θ : [n] ⟶ [n + 1]
inst✝ : Mono θ
i : Fin (n + 2)
θ' : [n] ⟶ [n]
h : θ = θ' ≫ δ i
this✝ : Mono (θ' ≫ δ i)
this : Mono θ'
⊢ θ = δ i

Next tactic:
rw [h, eq_id_of_mono θ', Category.id_comp]
theorem len_lt_of_mono {Δ' Δ : SimplexCategory} (i : Δ' ⟶ Δ) [hi : Mono i] (hi' : Δ ≠ Δ') :
    Δ'.len < Δ.len := by
  

Proof state:
Δ' Δ : SimplexCategory
i : Δ' ⟶ Δ
hi : Mono i
hi' : Δ ≠ Δ'
⊢ len Δ' < len Δ

Next tactic:
rcases lt_or_eq_of_le (len_le_of_mono hi) with (h | h)
theorem len_lt_of_mono {Δ' Δ : SimplexCategory} (i : Δ' ⟶ Δ) [hi : Mono i] (hi' : Δ ≠ Δ') :
    Δ'.len < Δ.len := by
  rcases lt_or_eq_of_le (len_le_of_mono hi) with (h | h)
  · 

Proof state:
case inl
Δ' Δ : SimplexCategory
i : Δ' ⟶ Δ
hi : Mono i
hi' : Δ ≠ Δ'
h : len Δ' < len Δ
⊢ len Δ' < len Δ

Next tactic:
exact h
theorem len_lt_of_mono {Δ' Δ : SimplexCategory} (i : Δ' ⟶ Δ) [hi : Mono i] (hi' : Δ ≠ Δ') :
    Δ'.len < Δ.len := by
  rcases lt_or_eq_of_le (len_le_of_mono hi) with (h | h)
  · exact h
  · 

Proof state:
case inr
Δ' Δ : SimplexCategory
i : Δ' ⟶ Δ
hi : Mono i
hi' : Δ ≠ Δ'
h : len Δ' = len Δ
⊢ len Δ' < len Δ

Next tactic:
exfalso