l3lab/ntp-mathlib huggingface dataset:
/-- Constructs an equivalence between nonempty finite linear orders from an order isomorphism
between them. -/
@[simps]
def Iso.mk {α β : NonemptyFinLinOrd.{u}} (e : α ≃o β) : α ≅ β where
  hom := (e : OrderHom _ _)
  inv := (e.symm : OrderHom _ _)
  hom_inv_id := by
    ext x
    exact e.symm_apply_apply x
  inv_hom_id := by
    

Proof state:
α β : NonemptyFinLinOrd
e : ↑α ≃o ↑β
⊢ ↑(OrderIso.symm e) ≫ ↑e = 𝟙 β

Next tactic:
ext x
/-- Constructs an equivalence between nonempty finite linear orders from an order isomorphism
between them. -/
@[simps]
def Iso.mk {α β : NonemptyFinLinOrd.{u}} (e : α ≃o β) : α ≅ β where
  hom := (e : OrderHom _ _)
  inv := (e.symm : OrderHom _ _)
  hom_inv_id := by
    ext x
    exact e.symm_apply_apply x
  inv_hom_id := by
    ext x
    

Proof state:
case w
α β : NonemptyFinLinOrd
e : ↑α ≃o ↑β
x : (forget NonemptyFinLinOrd).obj β
⊢ (↑(OrderIso.symm e) ≫ ↑e) x = (𝟙 β) x

Next tactic:
exact e.apply_symm_apply x
instance {A B : NonemptyFinLinOrd.{u}} : OrderHomClass (A ⟶ B) A B where
  coe f := ⇑(show OrderHom A B from f)
  coe_injective' _ _ h := by
    

Proof state:
A B : NonemptyFinLinOrd
x✝¹ x✝ : A ⟶ B
h :
  (fun f =>
        ⇑(let_fun this := f;
          this))
      x✝¹ =
    (fun f =>
        ⇑(let_fun this := f;
          this))
      x✝
⊢ x✝¹ = x✝

Next tactic:
ext x
instance {A B : NonemptyFinLinOrd.{u}} : OrderHomClass (A ⟶ B) A B where
  coe f := ⇑(show OrderHom A B from f)
  coe_injective' _ _ h := by
    ext x
    

Proof state:
case w
A B : NonemptyFinLinOrd
x✝¹ x✝ : A ⟶ B
h :
  (fun f =>
        ⇑(let_fun this := f;
          this))
      x✝¹ =
    (fun f =>
        ⇑(let_fun this := f;
          this))
      x✝
x : (forget NonemptyFinLinOrd).obj A
⊢ x✝¹ x = x✝ x

Next tactic:
exact congr_fun h x
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
⊢ Mono f ↔ Function.Injective ⇑f

Next tactic:
refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
  

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
⊢ Mono f → Function.Injective ⇑f

Next tactic:
intro
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
  intro
  

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Mono f
⊢ Function.Injective ⇑f

Next tactic:
intro a₁ a₂ h
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
  intro
  intro a₁ a₂ h
  

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Mono f
a₁ a₂ : ↑A
h : f a₁ = f a₂
⊢ a₁ = a₂

Next tactic:
let X := NonemptyFinLinOrd.of (ULift (Fin 1))
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
  intro
  intro a₁ a₂ h
  let X := NonemptyFinLinOrd.of (ULift (Fin 1))
  

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Mono f
a₁ a₂ : ↑A
h : f a₁ = f a₂
X : NonemptyFinLinOrd := of (ULift.{?u.34441, 0} (Fin 1))
⊢ a₁ = a₂

Next tactic:
let g₁ : X ⟶ A := ⟨fun _ => a₁, fun _ _ _ => by rfl⟩
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
  intro
  intro a₁ a₂ h
  let X := NonemptyFinLinOrd.of (ULift (Fin 1))
  let g₁ : X ⟶ A := ⟨fun _ => a₁, fun _ _ _ => by 

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Mono f
a₁ a₂ : ↑A
h : f a₁ = f a₂
X : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 1))
x✝² x✝¹ : ↑X
x✝ : x✝² ≤ x✝¹
⊢ (fun x => a₁) x✝² ≤ (fun x => a₁) x✝¹

Next tactic:
rfl
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
  intro
  intro a₁ a₂ h
  let X := NonemptyFinLinOrd.of (ULift (Fin 1))
  let g₁ : X ⟶ A := ⟨fun _ => a₁, fun _ _ _ => by rfl⟩
  

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Mono f
a₁ a₂ : ↑A
h : f a₁ = f a₂
X : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 1))
g₁ : X ⟶ A := { toFun := fun x => a₁, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₁) x ≤ (fun x => a₁) x) }
⊢ a₁ = a₂

Next tactic:
let g₂ : X ⟶ A := ⟨fun _ => a₂, fun _ _ _ => by rfl⟩
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
  intro
  intro a₁ a₂ h
  let X := NonemptyFinLinOrd.of (ULift (Fin 1))
  let g₁ : X ⟶ A := ⟨fun _ => a₁, fun _ _ _ => by rfl⟩
  let g₂ : X ⟶ A := ⟨fun _ => a₂, fun _ _ _ => by 

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Mono f
a₁ a₂ : ↑A
h : f a₁ = f a₂
X : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 1))
g₁ : X ⟶ A := { toFun := fun x => a₁, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₁) x ≤ (fun x => a₁) x) }
x✝² x✝¹ : ↑X
x✝ : x✝² ≤ x✝¹
⊢ (fun x => a₂) x✝² ≤ (fun x => a₂) x✝¹

Next tactic:
rfl
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
  intro
  intro a₁ a₂ h
  let X := NonemptyFinLinOrd.of (ULift (Fin 1))
  let g₁ : X ⟶ A := ⟨fun _ => a₁, fun _ _ _ => by rfl⟩
  let g₂ : X ⟶ A := ⟨fun _ => a₂, fun _ _ _ => by rfl⟩
  

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Mono f
a₁ a₂ : ↑A
h : f a₁ = f a₂
X : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 1))
g₁ : X ⟶ A := { toFun := fun x => a₁, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₁) x ≤ (fun x => a₁) x) }
g₂ : X ⟶ A := { toFun := fun x => a₂, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₂) x ≤ (fun x => a₂) x) }
⊢ a₁ = a₂

Next tactic:
change g₁ (ULift.up (0 : Fin 1)) = g₂ (ULift.up (0 : Fin 1))
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
  intro
  intro a₁ a₂ h
  let X := NonemptyFinLinOrd.of (ULift (Fin 1))
  let g₁ : X ⟶ A := ⟨fun _ => a₁, fun _ _ _ => by rfl⟩
  let g₂ : X ⟶ A := ⟨fun _ => a₂, fun _ _ _ => by rfl⟩
  change g₁ (ULift.up (0 : Fin 1)) = g₂ (ULift.up (0 : Fin 1))
  

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Mono f
a₁ a₂ : ↑A
h : f a₁ = f a₂
X : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 1))
g₁ : X ⟶ A := { toFun := fun x => a₁, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₁) x ≤ (fun x => a₁) x) }
g₂ : X ⟶ A := { toFun := fun x => a₂, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₂) x ≤ (fun x => a₂) x) }
⊢ g₁ { down := 0 } = g₂ { down := 0 }

Next tactic:
have eq : g₁ ≫ f = g₂ ≫ f := by
    ext
    exact h
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
  intro
  intro a₁ a₂ h
  let X := NonemptyFinLinOrd.of (ULift (Fin 1))
  let g₁ : X ⟶ A := ⟨fun _ => a₁, fun _ _ _ => by rfl⟩
  let g₂ : X ⟶ A := ⟨fun _ => a₂, fun _ _ _ => by rfl⟩
  change g₁ (ULift.up (0 : Fin 1)) = g₂ (ULift.up (0 : Fin 1))
  have eq : g₁ ≫ f = g₂ ≫ f := by
    

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Mono f
a₁ a₂ : ↑A
h : f a₁ = f a₂
X : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 1))
g₁ : X ⟶ A := { toFun := fun x => a₁, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₁) x ≤ (fun x => a₁) x) }
g₂ : X ⟶ A := { toFun := fun x => a₂, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₂) x ≤ (fun x => a₂) x) }
⊢ g₁ ≫ f = g₂ ≫ f

Next tactic:
ext
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
  intro
  intro a₁ a₂ h
  let X := NonemptyFinLinOrd.of (ULift (Fin 1))
  let g₁ : X ⟶ A := ⟨fun _ => a₁, fun _ _ _ => by rfl⟩
  let g₂ : X ⟶ A := ⟨fun _ => a₂, fun _ _ _ => by rfl⟩
  change g₁ (ULift.up (0 : Fin 1)) = g₂ (ULift.up (0 : Fin 1))
  have eq : g₁ ≫ f = g₂ ≫ f := by
    ext
    

Proof state:
case w
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Mono f
a₁ a₂ : ↑A
h : f a₁ = f a₂
X : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 1))
g₁ : X ⟶ A := { toFun := fun x => a₁, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₁) x ≤ (fun x => a₁) x) }
g₂ : X ⟶ A := { toFun := fun x => a₂, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₂) x ≤ (fun x => a₂) x) }
x✝ : (forget NonemptyFinLinOrd).obj X
⊢ (g₁ ≫ f) x✝ = (g₂ ≫ f) x✝

Next tactic:
exact h
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
  intro
  intro a₁ a₂ h
  let X := NonemptyFinLinOrd.of (ULift (Fin 1))
  let g₁ : X ⟶ A := ⟨fun _ => a₁, fun _ _ _ => by rfl⟩
  let g₂ : X ⟶ A := ⟨fun _ => a₂, fun _ _ _ => by rfl⟩
  change g₁ (ULift.up (0 : Fin 1)) = g₂ (ULift.up (0 : Fin 1))
  have eq : g₁ ≫ f = g₂ ≫ f := by
    ext
    exact h
  

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Mono f
a₁ a₂ : ↑A
h : f a₁ = f a₂
X : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 1))
g₁ : X ⟶ A := { toFun := fun x => a₁, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₁) x ≤ (fun x => a₁) x) }
g₂ : X ⟶ A := { toFun := fun x => a₂, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₂) x ≤ (fun x => a₂) x) }
eq : g₁ ≫ f = g₂ ≫ f
⊢ g₁ { down := 0 } = g₂ { down := 0 }

Next tactic:
rw [cancel_mono] at eq
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Mono f ↔ Function.Injective f := by
  refine' ⟨_, ConcreteCategory.mono_of_injective f⟩
  intro
  intro a₁ a₂ h
  let X := NonemptyFinLinOrd.of (ULift (Fin 1))
  let g₁ : X ⟶ A := ⟨fun _ => a₁, fun _ _ _ => by rfl⟩
  let g₂ : X ⟶ A := ⟨fun _ => a₂, fun _ _ _ => by rfl⟩
  change g₁ (ULift.up (0 : Fin 1)) = g₂ (ULift.up (0 : Fin 1))
  have eq : g₁ ≫ f = g₂ ≫ f := by
    ext
    exact h
  rw [cancel_mono] at eq
  

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Mono f
a₁ a₂ : ↑A
h : f a₁ = f a₂
X : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 1))
g₁ : X ⟶ A := { toFun := fun x => a₁, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₁) x ≤ (fun x => a₁) x) }
g₂ : X ⟶ A := { toFun := fun x => a₂, monotone' := (_ : ∀ (x x_1 : ↑X), x ≤ x_1 → (fun x => a₂) x ≤ (fun x => a₂) x) }
eq : g₁ = g₂
⊢ g₁ { down := 0 } = g₂ { down := 0 }

Next tactic:
rw [eq]
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
⊢ Epi f ↔ Function.Surjective ⇑f

Next tactic:
constructor
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · 

Proof state:
case mp
A B : NonemptyFinLinOrd
f : A ⟶ B
⊢ Epi f → Function.Surjective ⇑f

Next tactic:
intro
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    

Proof state:
case mp
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
⊢ Function.Surjective ⇑f

Next tactic:
dsimp only [Function.Surjective]
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    

Proof state:
case mp
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
⊢ ∀ (b : ↑B), ∃ a, f a = b

Next tactic:
by_contra! hf'
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    

Proof state:
case mp
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
hf' : ∃ b, ∀ (a : ↑A), f a ≠ b
⊢ False

Next tactic:
rcases hf' with ⟨m, hm⟩
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    

Proof state:
case mp.intro
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
⊢ False

Next tactic:
let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
    

Proof state:
case mp.intro
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{?u.41269, 0} (Fin 2))
⊢ False

Next tactic:
let p₁ : B ⟶ Y :=
      ⟨fun b => if b < m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        simp only
        split_ifs with h₁ h₂ h₂
        any_goals apply Fin.zero_le
        · exfalso
          exact h₁ (lt_of_le_of_lt h h₂)
        · rfl⟩
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
    let p₁ : B ⟶ Y :=
      ⟨fun b => if b < m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
x₁ x₂ : ↑B
h : x₁ ≤ x₂
⊢ (fun b => if b < m then { down := 0 } else { down := 1 }) x₁ ≤
    (fun b => if b < m then { down := 0 } else { down := 1 }) x₂

Next tactic:
simp only
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
    let p₁ : B ⟶ Y :=
      ⟨fun b => if b < m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        simp only
        

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
x₁ x₂ : ↑B
h : x₁ ≤ x₂
⊢ (if x₁ < m then { down := 0 } else { down := 1 }) ≤ if x₂ < m then { down := 0 } else { down := 1 }

Next tactic:
split_ifs with h₁ h₂ h₂
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
    let p₁ : B ⟶ Y :=
      ⟨fun b => if b < m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        simp only
        split_ifs with h₁ h₂ h₂
        

Proof state:
case pos
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
x₁ x₂ : ↑B
h : x₁ ≤ x₂
h₁ : x₁ < m
h₂ : x₂ < m
⊢ { down := 0 } ≤ { down := 0 }
case neg
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
x₁ x₂ : ↑B
h : x₁ ≤ x₂
h₁ : x₁ < m
h₂ : ¬x₂ < m
⊢ { down := 0 } ≤ { down := 1 }
case pos
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
x₁ x₂ : ↑B
h : x₁ ≤ x₂
h₁ : ¬x₁ < m
h₂ : x₂ < m
⊢ { down := 1 } ≤ { down := 0 }
case neg
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
x₁ x₂ : ↑B
h : x₁ ≤ x₂
h₁ : ¬x₁ < m
h₂ : ¬x₂ < m
⊢ { down := 1 } ≤ { down := 1 }

Next tactic:
any_goals apply Fin.zero_le
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
    let p₁ : B ⟶ Y :=
      ⟨fun b => if b < m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        simp only
        split_ifs with h₁ h₂ h₂
        any_goals 

Proof state:
case pos
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
x₁ x₂ : ↑B
h : x₁ ≤ x₂
h₁ : x₁ < m
h₂ : x₂ < m
⊢ { down := 0 } ≤ { down := 0 }

Next tactic:
apply Fin.zero_le
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
    let p₁ : B ⟶ Y :=
      ⟨fun b => if b < m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        simp only
        split_ifs with h₁ h₂ h₂
        any_goals 

Proof state:
case neg
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
x₁ x₂ : ↑B
h : x₁ ≤ x₂
h₁ : x₁ < m
h₂ : ¬x₂ < m
⊢ { down := 0 } ≤ { down := 1 }

Next tactic:
apply Fin.zero_le
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
    let p₁ : B ⟶ Y :=
      ⟨fun b => if b < m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        simp only
        split_ifs with h₁ h₂ h₂
        any_goals 

Proof state:
case pos
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
x₁ x₂ : ↑B
h : x₁ ≤ x₂
h₁ : ¬x₁ < m
h₂ : x₂ < m
⊢ { down := 1 } ≤ { down := 0 }

Next tactic:
apply Fin.zero_le
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
    let p₁ : B ⟶ Y :=
      ⟨fun b => if b < m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        simp only
        split_ifs with h₁ h₂ h₂
        any_goals 

Proof state:
case neg
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
x₁ x₂ : ↑B
h : x₁ ≤ x₂
h₁ : ¬x₁ < m
h₂ : ¬x₂ < m
⊢ { down := 1 } ≤ { down := 1 }

Next tactic:
apply Fin.zero_le
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
    let p₁ : B ⟶ Y :=
      ⟨fun b => if b < m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        simp only
        split_ifs with h₁ h₂ h₂
        any_goals apply Fin.zero_le
        · 

Proof state:
case pos
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
x₁ x₂ : ↑B
h : x₁ ≤ x₂
h₁ : ¬x₁ < m
h₂ : x₂ < m
⊢ { down := 1 } ≤ { down := 0 }

Next tactic:
exfalso
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
    let p₁ : B ⟶ Y :=
      ⟨fun b => if b < m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        simp only
        split_ifs with h₁ h₂ h₂
        any_goals apply Fin.zero_le
        · exfalso
          

Proof state:
case pos.h
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
x₁ x₂ : ↑B
h : x₁ ≤ x₂
h₁ : ¬x₁ < m
h₂ : x₂ < m
⊢ False

Next tactic:
exact h₁ (lt_of_le_of_lt h h₂)
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
    let p₁ : B ⟶ Y :=
      ⟨fun b => if b < m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        simp only
        split_ifs with h₁ h₂ h₂
        any_goals apply Fin.zero_le
        · exfalso
          exact h₁ (lt_of_le_of_lt h h₂)
        · 

Proof state:
case neg
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
x₁ x₂ : ↑B
h : x₁ ≤ x₂
h₁ : ¬x₁ < m
h₂ : ¬x₂ < m
⊢ { down := 1 } ≤ { down := 1 }

Next tactic:
rfl
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
    let p₁ : B ⟶ Y :=
      ⟨fun b => if b < m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        simp only
        split_ifs with h₁ h₂ h₂
        any_goals apply Fin.zero_le
        · exfalso
          exact h₁ (lt_of_le_of_lt h h₂)
        · rfl⟩
    

Proof state:
case mp.intro
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
p₁ : B ⟶ Y :=
  { toFun := fun b => if b < m then { down := 0 } else { down := 1 },
    monotone' :=
      (_ :
        ∀ (x₁ x₂ : ↑B),
          x₁ ≤ x₂ →
            (fun b => if b < m then { down := 0 } else { down := 1 }) x₁ ≤
              (fun b => if b < m then { down := 0 } else { down := 1 }) x₂) }
⊢ False

Next tactic:
let p₂ : B ⟶ Y :=
      ⟨fun b => if b ≤ m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        simp only
        split_ifs with h₁ h₂ h₂
        any_goals apply Fin.zero_le
        · exfalso
          exact h₁ (h.trans h₂)
        · rfl⟩
theorem epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :
    Epi f ↔ Function.Surjective f := by
  constructor
  · intro
    dsimp only [Function.Surjective]
    by_contra! hf'
    rcases hf' with ⟨m, hm⟩
    let Y := NonemptyFinLinOrd.of (ULift (Fin 2))
    let p₁ : B ⟶ Y :=
      ⟨fun b => if b < m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        simp only
        split_ifs with h₁ h₂ h₂
        any_goals apply Fin.zero_le
        · exfalso
          exact h₁ (lt_of_le_of_lt h h₂)
        · rfl⟩
    let p₂ : B ⟶ Y :=
      ⟨fun b => if b ≤ m then ULift.up 0 else ULift.up 1, fun x₁ x₂ h => by
        

Proof state:
A B : NonemptyFinLinOrd
f : A ⟶ B
a✝ : Epi f
m : ↑B
hm : ∀ (a : ↑A), f a ≠ m
Y : NonemptyFinLinOrd := of (ULift.{u, 0} (Fin 2))
p₁ : B ⟶ Y :=
  { toFun := fun b => if b < m then { down := 0 } else { down := 1 },
    monotone' :=
      (_ :
        ∀ (x₁ x₂ : ↑B),
          x₁ ≤ x₂ →
            (fun b => if b < m then { down := 0 } else { down := 1 }) x₁ ≤
              (fun b => if b < m then { down := 0 } else { down := 1 }) x₂) }
x₁ x₂ : ↑B
h : x₁ ≤ x₂
⊢ (fun b => if b ≤ m then { down := 0 } else { down := 1 }) x₁ ≤
    (fun b => if b ≤ m then { down := 0 } else { down := 1 }) x₂

Next tactic:
simp only