l3lab/ntp-mathlib huggingface dataset:
theorem le_cof {r : α → α → Prop} [IsRefl α r] (c : Cardinal) :
    c ≤ cof r ↔ ∀ {S : Set α}, (∀ a, ∃ b ∈ S, r a b) → c ≤ #S := by
  rw [cof, le_csInf_iff'' (cof_nonempty r)]
  use fun H S h => H _ ⟨S, h, rfl⟩
  rintro H d ⟨S, h, rfl⟩
  

Proof state:
case mpr.intro.intro
α : Type u_1
r✝ r : α → α → Prop
inst✝ : IsRefl α r
c : Cardinal.{u_1}
H : ∀ {S : Set α}, (∀ (a : α), ∃ b ∈ S, r a b) → c ≤ #↑S
S : Set α
h : ∀ (a : α), ∃ b ∈ S, r a b
⊢ c ≤ #↑S

Next tactic:
exact H h
theorem RelIso.cof_le_lift {α : Type u} {β : Type v} {r : α → α → Prop} {s} [IsRefl β s]
    (f : r ≃r s) : Cardinal.lift.{max u v} (Order.cof r) ≤
    Cardinal.lift.{max u v} (Order.cof s) := by
  

Proof state:
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
α : Type u
β : Type v
r : α → α → Prop
s : β → β → Prop
inst✝ : IsRefl β s
f : r ≃r s
⊢ Cardinal.lift.{max u v, u} (cof r) ≤ Cardinal.lift.{max u v, v} (cof s)

Next tactic:
rw [Order.cof, Order.cof, lift_sInf, lift_sInf,
    le_csInf_iff'' (nonempty_image_iff.2 (Order.cof_nonempty s))]
theorem RelIso.cof_le_lift {α : Type u} {β : Type v} {r : α → α → Prop} {s} [IsRefl β s]
    (f : r ≃r s) : Cardinal.lift.{max u v} (Order.cof r) ≤
    Cardinal.lift.{max u v} (Order.cof s) := by
  rw [Order.cof, Order.cof, lift_sInf, lift_sInf,
    le_csInf_iff'' (nonempty_image_iff.2 (Order.cof_nonempty s))]
  

Proof state:
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
α : Type u
β : Type v
r : α → α → Prop
s : β → β → Prop
inst✝ : IsRefl β s
f : r ≃r s
⊢ ∀ b ∈ Cardinal.lift.{max u v, v} '' {c | ∃ S, (∀ (a : β), ∃ b ∈ S, s a b) ∧ #↑S = c},
    sInf (Cardinal.lift.{max u v, u} '' {c | ∃ S, (∀ (a : α), ∃ b ∈ S, r a b) ∧ #↑S = c}) ≤ b

Next tactic:
rintro - ⟨-, ⟨u, H, rfl⟩, rfl⟩
theorem RelIso.cof_le_lift {α : Type u} {β : Type v} {r : α → α → Prop} {s} [IsRefl β s]
    (f : r ≃r s) : Cardinal.lift.{max u v} (Order.cof r) ≤
    Cardinal.lift.{max u v} (Order.cof s) := by
  rw [Order.cof, Order.cof, lift_sInf, lift_sInf,
    le_csInf_iff'' (nonempty_image_iff.2 (Order.cof_nonempty s))]
  rintro - ⟨-, ⟨u, H, rfl⟩, rfl⟩
  

Proof state:
case intro.intro.intro.intro
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
α : Type u
β : Type v
r : α → α → Prop
s : β → β → Prop
inst✝ : IsRefl β s
f : r ≃r s
u : Set β
H : ∀ (a : β), ∃ b ∈ u, s a b
⊢ sInf (Cardinal.lift.{max u v, u} '' {c | ∃ S, (∀ (a : α), ∃ b ∈ S, r a b) ∧ #↑S = c}) ≤ Cardinal.lift.{max u v, v} #↑u

Next tactic:
apply csInf_le'
theorem RelIso.cof_le_lift {α : Type u} {β : Type v} {r : α → α → Prop} {s} [IsRefl β s]
    (f : r ≃r s) : Cardinal.lift.{max u v} (Order.cof r) ≤
    Cardinal.lift.{max u v} (Order.cof s) := by
  rw [Order.cof, Order.cof, lift_sInf, lift_sInf,
    le_csInf_iff'' (nonempty_image_iff.2 (Order.cof_nonempty s))]
  rintro - ⟨-, ⟨u, H, rfl⟩, rfl⟩
  apply csInf_le'
  

Proof state:
case intro.intro.intro.intro.h
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
α : Type u
β : Type v
r : α → α → Prop
s : β → β → Prop
inst✝ : IsRefl β s
f : r ≃r s
u : Set β
H : ∀ (a : β), ∃ b ∈ u, s a b
⊢ Cardinal.lift.{max u v, v} #↑u ∈ Cardinal.lift.{max u v, u} '' {c | ∃ S, (∀ (a : α), ∃ b ∈ S, r a b) ∧ #↑S = c}

Next tactic:
refine'
    ⟨_, ⟨f.symm '' u, fun a => _, rfl⟩,
      lift_mk_eq.{u, v, max u v}.2 ⟨(f.symm.toEquiv.image u).symm⟩⟩
theorem RelIso.cof_le_lift {α : Type u} {β : Type v} {r : α → α → Prop} {s} [IsRefl β s]
    (f : r ≃r s) : Cardinal.lift.{max u v} (Order.cof r) ≤
    Cardinal.lift.{max u v} (Order.cof s) := by
  rw [Order.cof, Order.cof, lift_sInf, lift_sInf,
    le_csInf_iff'' (nonempty_image_iff.2 (Order.cof_nonempty s))]
  rintro - ⟨-, ⟨u, H, rfl⟩, rfl⟩
  apply csInf_le'
  refine'
    ⟨_, ⟨f.symm '' u, fun a => _, rfl⟩,
      lift_mk_eq.{u, v, max u v}.2 ⟨(f.symm.toEquiv.image u).symm⟩⟩
  

Proof state:
case intro.intro.intro.intro.h
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
α : Type u
β : Type v
r : α → α → Prop
s : β → β → Prop
inst✝ : IsRefl β s
f : r ≃r s
u : Set β
H : ∀ (a : β), ∃ b ∈ u, s a b
a : α
⊢ ∃ b ∈ ⇑(RelIso.symm f) '' u, r a b

Next tactic:
rcases H (f a) with ⟨b, hb, hb'⟩
theorem RelIso.cof_le_lift {α : Type u} {β : Type v} {r : α → α → Prop} {s} [IsRefl β s]
    (f : r ≃r s) : Cardinal.lift.{max u v} (Order.cof r) ≤
    Cardinal.lift.{max u v} (Order.cof s) := by
  rw [Order.cof, Order.cof, lift_sInf, lift_sInf,
    le_csInf_iff'' (nonempty_image_iff.2 (Order.cof_nonempty s))]
  rintro - ⟨-, ⟨u, H, rfl⟩, rfl⟩
  apply csInf_le'
  refine'
    ⟨_, ⟨f.symm '' u, fun a => _, rfl⟩,
      lift_mk_eq.{u, v, max u v}.2 ⟨(f.symm.toEquiv.image u).symm⟩⟩
  rcases H (f a) with ⟨b, hb, hb'⟩
  

Proof state:
case intro.intro.intro.intro.h.intro.intro
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
α : Type u
β : Type v
r : α → α → Prop
s : β → β → Prop
inst✝ : IsRefl β s
f : r ≃r s
u : Set β
H : ∀ (a : β), ∃ b ∈ u, s a b
a : α
b : β
hb : b ∈ u
hb' : s (f a) b
⊢ ∃ b ∈ ⇑(RelIso.symm f) '' u, r a b

Next tactic:
refine' ⟨f.symm b, mem_image_of_mem _ hb, f.map_rel_iff.1 _⟩
theorem RelIso.cof_le_lift {α : Type u} {β : Type v} {r : α → α → Prop} {s} [IsRefl β s]
    (f : r ≃r s) : Cardinal.lift.{max u v} (Order.cof r) ≤
    Cardinal.lift.{max u v} (Order.cof s) := by
  rw [Order.cof, Order.cof, lift_sInf, lift_sInf,
    le_csInf_iff'' (nonempty_image_iff.2 (Order.cof_nonempty s))]
  rintro - ⟨-, ⟨u, H, rfl⟩, rfl⟩
  apply csInf_le'
  refine'
    ⟨_, ⟨f.symm '' u, fun a => _, rfl⟩,
      lift_mk_eq.{u, v, max u v}.2 ⟨(f.symm.toEquiv.image u).symm⟩⟩
  rcases H (f a) with ⟨b, hb, hb'⟩
  refine' ⟨f.symm b, mem_image_of_mem _ hb, f.map_rel_iff.1 _⟩
  

Proof state:
case intro.intro.intro.intro.h.intro.intro
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
α : Type u
β : Type v
r : α → α → Prop
s : β → β → Prop
inst✝ : IsRefl β s
f : r ≃r s
u : Set β
H : ∀ (a : β), ∃ b ∈ u, s a b
a : α
b : β
hb : b ∈ u
hb' : s (f a) b
⊢ s (f a) (f ((RelIso.symm f) b))

Next tactic:
rwa [RelIso.apply_symm_apply]
/-- Cofinality of an ordinal. This is the smallest cardinal of a
  subset `S` of the ordinal which is unbounded, in the sense
  `∀ a, ∃ b ∈ S, a ≤ b`. It is defined for all ordinals, but
  `cof 0 = 0` and `cof (succ o) = 1`, so it is only really
  interesting on limit ordinals (when it is an infinite cardinal). -/
def cof (o : Ordinal.{u}) : Cardinal.{u} :=
  o.liftOn (fun a => StrictOrder.cof a.r)
    (by
      

Proof state:
α : Type u_1
r : α → α → Prop
o : Ordinal.{u}
⊢ ∀ (a b : WellOrder), a ≈ b → (fun a => StrictOrder.cof a.r) a = (fun a => StrictOrder.cof a.r) b

Next tactic:
rintro ⟨α, r, wo₁⟩ ⟨β, s, wo₂⟩ ⟨⟨f, hf⟩⟩
/-- Cofinality of an ordinal. This is the smallest cardinal of a
  subset `S` of the ordinal which is unbounded, in the sense
  `∀ a, ∃ b ∈ S, a ≤ b`. It is defined for all ordinals, but
  `cof 0 = 0` and `cof (succ o) = 1`, so it is only really
  interesting on limit ordinals (when it is an infinite cardinal). -/
def cof (o : Ordinal.{u}) : Cardinal.{u} :=
  o.liftOn (fun a => StrictOrder.cof a.r)
    (by
      rintro ⟨α, r, wo₁⟩ ⟨β, s, wo₂⟩ ⟨⟨f, hf⟩⟩
      

Proof state:
case mk.mk.intro.mk
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{u}
α : Type u
r : α → α → Prop
wo₁ : IsWellOrder α r
β : Type u
s : β → β → Prop
wo₂ : IsWellOrder β s
f : α ≃ β
hf : ∀ {a b : α}, s (f a) (f b) ↔ r a b
⊢ (fun a => StrictOrder.cof a.r) { α := α, r := r, wo := wo₁ } =
    (fun a => StrictOrder.cof a.r) { α := β, r := s, wo := wo₂ }

Next tactic:
haveI := wo₁
/-- Cofinality of an ordinal. This is the smallest cardinal of a
  subset `S` of the ordinal which is unbounded, in the sense
  `∀ a, ∃ b ∈ S, a ≤ b`. It is defined for all ordinals, but
  `cof 0 = 0` and `cof (succ o) = 1`, so it is only really
  interesting on limit ordinals (when it is an infinite cardinal). -/
def cof (o : Ordinal.{u}) : Cardinal.{u} :=
  o.liftOn (fun a => StrictOrder.cof a.r)
    (by
      rintro ⟨α, r, wo₁⟩ ⟨β, s, wo₂⟩ ⟨⟨f, hf⟩⟩
      haveI := wo₁; 

Proof state:
case mk.mk.intro.mk
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{u}
α : Type u
r : α → α → Prop
wo₁ : IsWellOrder α r
β : Type u
s : β → β → Prop
wo₂ : IsWellOrder β s
f : α ≃ β
hf : ∀ {a b : α}, s (f a) (f b) ↔ r a b
this : IsWellOrder α r
⊢ (fun a => StrictOrder.cof a.r) { α := α, r := r, wo := wo₁ } =
    (fun a => StrictOrder.cof a.r) { α := β, r := s, wo := wo₂ }

Next tactic:
haveI := wo₂
/-- Cofinality of an ordinal. This is the smallest cardinal of a
  subset `S` of the ordinal which is unbounded, in the sense
  `∀ a, ∃ b ∈ S, a ≤ b`. It is defined for all ordinals, but
  `cof 0 = 0` and `cof (succ o) = 1`, so it is only really
  interesting on limit ordinals (when it is an infinite cardinal). -/
def cof (o : Ordinal.{u}) : Cardinal.{u} :=
  o.liftOn (fun a => StrictOrder.cof a.r)
    (by
      rintro ⟨α, r, wo₁⟩ ⟨β, s, wo₂⟩ ⟨⟨f, hf⟩⟩
      haveI := wo₁; haveI := wo₂
      

Proof state:
case mk.mk.intro.mk
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{u}
α : Type u
r : α → α → Prop
wo₁ : IsWellOrder α r
β : Type u
s : β → β → Prop
wo₂ : IsWellOrder β s
f : α ≃ β
hf : ∀ {a b : α}, s (f a) (f b) ↔ r a b
this✝ : IsWellOrder α r
this : IsWellOrder β s
⊢ (fun a => StrictOrder.cof a.r) { α := α, r := r, wo := wo₁ } =
    (fun a => StrictOrder.cof a.r) { α := β, r := s, wo := wo₂ }

Next tactic:
dsimp only
/-- Cofinality of an ordinal. This is the smallest cardinal of a
  subset `S` of the ordinal which is unbounded, in the sense
  `∀ a, ∃ b ∈ S, a ≤ b`. It is defined for all ordinals, but
  `cof 0 = 0` and `cof (succ o) = 1`, so it is only really
  interesting on limit ordinals (when it is an infinite cardinal). -/
def cof (o : Ordinal.{u}) : Cardinal.{u} :=
  o.liftOn (fun a => StrictOrder.cof a.r)
    (by
      rintro ⟨α, r, wo₁⟩ ⟨β, s, wo₂⟩ ⟨⟨f, hf⟩⟩
      haveI := wo₁; haveI := wo₂
      dsimp only
      

Proof state:
case mk.mk.intro.mk
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{u}
α : Type u
r : α → α → Prop
wo₁ : IsWellOrder α r
β : Type u
s : β → β → Prop
wo₂ : IsWellOrder β s
f : α ≃ β
hf : ∀ {a b : α}, s (f a) (f b) ↔ r a b
this✝ : IsWellOrder α r
this : IsWellOrder β s
⊢ StrictOrder.cof r = StrictOrder.cof s

Next tactic:
apply @RelIso.cof_eq _ _ _ _ ?_ ?_
/-- Cofinality of an ordinal. This is the smallest cardinal of a
  subset `S` of the ordinal which is unbounded, in the sense
  `∀ a, ∃ b ∈ S, a ≤ b`. It is defined for all ordinals, but
  `cof 0 = 0` and `cof (succ o) = 1`, so it is only really
  interesting on limit ordinals (when it is an infinite cardinal). -/
def cof (o : Ordinal.{u}) : Cardinal.{u} :=
  o.liftOn (fun a => StrictOrder.cof a.r)
    (by
      rintro ⟨α, r, wo₁⟩ ⟨β, s, wo₂⟩ ⟨⟨f, hf⟩⟩
      haveI := wo₁; haveI := wo₂
      dsimp only
      apply @RelIso.cof_eq _ _ _ _ ?_ ?_
      · 

Proof state:
case mk.mk.intro.mk
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{u}
α : Type u
r : α → α → Prop
wo₁ : IsWellOrder α r
β : Type u
s : β → β → Prop
wo₂ : IsWellOrder β s
f : α ≃ β
hf : ∀ {a b : α}, s (f a) (f b) ↔ r a b
this✝ : IsWellOrder α r
this : IsWellOrder β s
⊢ swap rᶜ ≃r swap sᶜ

Next tactic:
constructor
/-- Cofinality of an ordinal. This is the smallest cardinal of a
  subset `S` of the ordinal which is unbounded, in the sense
  `∀ a, ∃ b ∈ S, a ≤ b`. It is defined for all ordinals, but
  `cof 0 = 0` and `cof (succ o) = 1`, so it is only really
  interesting on limit ordinals (when it is an infinite cardinal). -/
def cof (o : Ordinal.{u}) : Cardinal.{u} :=
  o.liftOn (fun a => StrictOrder.cof a.r)
    (by
      rintro ⟨α, r, wo₁⟩ ⟨β, s, wo₂⟩ ⟨⟨f, hf⟩⟩
      haveI := wo₁; haveI := wo₂
      dsimp only
      apply @RelIso.cof_eq _ _ _ _ ?_ ?_
      · constructor
        

Proof state:
case mk.mk.intro.mk.map_rel_iff'
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{u}
α : Type u
r : α → α → Prop
wo₁ : IsWellOrder α r
β : Type u
s : β → β → Prop
wo₂ : IsWellOrder β s
f : α ≃ β
hf : ∀ {a b : α}, s (f a) (f b) ↔ r a b
this✝ : IsWellOrder α r
this : IsWellOrder β s
⊢ ∀ {a b : α}, swap sᶜ (?mk.mk.intro.mk.toEquiv a) (?mk.mk.intro.mk.toEquiv b) ↔ swap rᶜ a b
case mk.mk.intro.mk.toEquiv
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{u}
α : Type u
r : α → α → Prop
wo₁ : IsWellOrder α r
β : Type u
s : β → β → Prop
wo₂ : IsWellOrder β s
f : α ≃ β
hf : ∀ {a b : α}, s (f a) (f b) ↔ r a b
this✝ : IsWellOrder α r
this : IsWellOrder β s
⊢ α ≃ β

Next tactic:
exact @fun a b => not_iff_not.2 hf
/-- Cofinality of an ordinal. This is the smallest cardinal of a
  subset `S` of the ordinal which is unbounded, in the sense
  `∀ a, ∃ b ∈ S, a ≤ b`. It is defined for all ordinals, but
  `cof 0 = 0` and `cof (succ o) = 1`, so it is only really
  interesting on limit ordinals (when it is an infinite cardinal). -/
def cof (o : Ordinal.{u}) : Cardinal.{u} :=
  o.liftOn (fun a => StrictOrder.cof a.r)
    (by
      rintro ⟨α, r, wo₁⟩ ⟨β, s, wo₂⟩ ⟨⟨f, hf⟩⟩
      haveI := wo₁; haveI := wo₂
      dsimp only
      apply @RelIso.cof_eq _ _ _ _ ?_ ?_
      · constructor
        exact @fun a b => not_iff_not.2 hf
      · 

Proof state:
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{u}
α : Type u
r : α → α → Prop
wo₁ : IsWellOrder α r
β : Type u
s : β → β → Prop
wo₂ : IsWellOrder β s
f : α ≃ β
hf : ∀ {a b : α}, s (f a) (f b) ↔ r a b
this✝ : IsWellOrder α r
this : IsWellOrder β s
⊢ IsRefl α (swap rᶜ)

Next tactic:
dsimp only [swap]
/-- Cofinality of an ordinal. This is the smallest cardinal of a
  subset `S` of the ordinal which is unbounded, in the sense
  `∀ a, ∃ b ∈ S, a ≤ b`. It is defined for all ordinals, but
  `cof 0 = 0` and `cof (succ o) = 1`, so it is only really
  interesting on limit ordinals (when it is an infinite cardinal). -/
def cof (o : Ordinal.{u}) : Cardinal.{u} :=
  o.liftOn (fun a => StrictOrder.cof a.r)
    (by
      rintro ⟨α, r, wo₁⟩ ⟨β, s, wo₂⟩ ⟨⟨f, hf⟩⟩
      haveI := wo₁; haveI := wo₂
      dsimp only
      apply @RelIso.cof_eq _ _ _ _ ?_ ?_
      · constructor
        exact @fun a b => not_iff_not.2 hf
      · dsimp only [swap]
        

Proof state:
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{u}
α : Type u
r : α → α → Prop
wo₁ : IsWellOrder α r
β : Type u
s : β → β → Prop
wo₂ : IsWellOrder β s
f : α ≃ β
hf : ∀ {a b : α}, s (f a) (f b) ↔ r a b
this✝ : IsWellOrder α r
this : IsWellOrder β s
⊢ IsRefl α (swap rᶜ)

Next tactic:
exact ⟨fun _ => irrefl _⟩
/-- Cofinality of an ordinal. This is the smallest cardinal of a
  subset `S` of the ordinal which is unbounded, in the sense
  `∀ a, ∃ b ∈ S, a ≤ b`. It is defined for all ordinals, but
  `cof 0 = 0` and `cof (succ o) = 1`, so it is only really
  interesting on limit ordinals (when it is an infinite cardinal). -/
def cof (o : Ordinal.{u}) : Cardinal.{u} :=
  o.liftOn (fun a => StrictOrder.cof a.r)
    (by
      rintro ⟨α, r, wo₁⟩ ⟨β, s, wo₂⟩ ⟨⟨f, hf⟩⟩
      haveI := wo₁; haveI := wo₂
      dsimp only
      apply @RelIso.cof_eq _ _ _ _ ?_ ?_
      · constructor
        exact @fun a b => not_iff_not.2 hf
      · dsimp only [swap]
        exact ⟨fun _ => irrefl _⟩
      · 

Proof state:
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{u}
α : Type u
r : α → α → Prop
wo₁ : IsWellOrder α r
β : Type u
s : β → β → Prop
wo₂ : IsWellOrder β s
f : α ≃ β
hf : ∀ {a b : α}, s (f a) (f b) ↔ r a b
this✝ : IsWellOrder α r
this : IsWellOrder β s
⊢ IsRefl β (swap sᶜ)

Next tactic:
dsimp only [swap]
/-- Cofinality of an ordinal. This is the smallest cardinal of a
  subset `S` of the ordinal which is unbounded, in the sense
  `∀ a, ∃ b ∈ S, a ≤ b`. It is defined for all ordinals, but
  `cof 0 = 0` and `cof (succ o) = 1`, so it is only really
  interesting on limit ordinals (when it is an infinite cardinal). -/
def cof (o : Ordinal.{u}) : Cardinal.{u} :=
  o.liftOn (fun a => StrictOrder.cof a.r)
    (by
      rintro ⟨α, r, wo₁⟩ ⟨β, s, wo₂⟩ ⟨⟨f, hf⟩⟩
      haveI := wo₁; haveI := wo₂
      dsimp only
      apply @RelIso.cof_eq _ _ _ _ ?_ ?_
      · constructor
        exact @fun a b => not_iff_not.2 hf
      · dsimp only [swap]
        exact ⟨fun _ => irrefl _⟩
      · dsimp only [swap]
        

Proof state:
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{u}
α : Type u
r : α → α → Prop
wo₁ : IsWellOrder α r
β : Type u
s : β → β → Prop
wo₂ : IsWellOrder β s
f : α ≃ β
hf : ∀ {a b : α}, s (f a) (f b) ↔ r a b
this✝ : IsWellOrder α r
this : IsWellOrder β s
⊢ IsRefl β (swap sᶜ)

Next tactic:
exact ⟨fun _ => irrefl _⟩
theorem le_cof_type [IsWellOrder α r] {c} : c ≤ cof (type r) ↔ ∀ S, Unbounded r S → c ≤ #S :=
  (le_csInf_iff'' (StrictOrder.cof_nonempty r)).trans
    ⟨fun H S h => H _ ⟨S, h, rfl⟩, by
      

Proof state:
α : Type u_1
r : α → α → Prop
inst✝ : IsWellOrder α r
c : Cardinal.{u_1}
⊢ (∀ (S : Set α), Unbounded r S → c ≤ #↑S) → ∀ b ∈ {c | ∃ S, Unbounded r S ∧ #↑S = c}, c ≤ b

Next tactic:
rintro H d ⟨S, h, rfl⟩
theorem le_cof_type [IsWellOrder α r] {c} : c ≤ cof (type r) ↔ ∀ S, Unbounded r S → c ≤ #S :=
  (le_csInf_iff'' (StrictOrder.cof_nonempty r)).trans
    ⟨fun H S h => H _ ⟨S, h, rfl⟩, by
      rintro H d ⟨S, h, rfl⟩
      

Proof state:
case intro.intro
α : Type u_1
r : α → α → Prop
inst✝ : IsWellOrder α r
c : Cardinal.{u_1}
H : ∀ (S : Set α), Unbounded r S → c ≤ #↑S
S : Set α
h : Unbounded r S
⊢ c ≤ #↑S

Next tactic:
exact H _ h
theorem lt_cof_type [IsWellOrder α r] {S : Set α} : #S < cof (type r) → Bounded r S := by
  

Proof state:
α : Type u_1
r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
⊢ #↑S < cof (type r) → Bounded r S

Next tactic:
simpa using not_imp_not.2 cof_type_le
theorem ord_cof_eq (r : α → α → Prop) [IsWellOrder α r] :
    ∃ S, Unbounded r S ∧ type (Subrel r S) = (cof (type r)).ord := by
  

Proof state:
α : Type u_1
r✝ r : α → α → Prop
inst✝ : IsWellOrder α r
⊢ ∃ S, Unbounded r S ∧ type (Subrel r S) = ord (cof (type r))

Next tactic:
let ⟨S, hS, e⟩ := cof_eq r
theorem ord_cof_eq (r : α → α → Prop) [IsWellOrder α r] :
    ∃ S, Unbounded r S ∧ type (Subrel r S) = (cof (type r)).ord := by
  let ⟨S, hS, e⟩ := cof_eq r
  

Proof state:
α : Type u_1
r✝ r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
hS : Unbounded r S
e : #↑S = cof (type r)
⊢ ∃ S, Unbounded r S ∧ type (Subrel r S) = ord (cof (type r))

Next tactic:
let ⟨s, _, e'⟩ := Cardinal.ord_eq S
theorem ord_cof_eq (r : α → α → Prop) [IsWellOrder α r] :
    ∃ S, Unbounded r S ∧ type (Subrel r S) = (cof (type r)).ord := by
  let ⟨S, hS, e⟩ := cof_eq r
  let ⟨s, _, e'⟩ := Cardinal.ord_eq S
  

Proof state:
α : Type u_1
r✝ r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
hS : Unbounded r S
e : #↑S = cof (type r)
s : ↑S → ↑S → Prop
w✝ : IsWellOrder (↑S) s
e' : ord #↑S = type s
⊢ ∃ S, Unbounded r S ∧ type (Subrel r S) = ord (cof (type r))

Next tactic:
let T : Set α := { a | ∃ aS : a ∈ S, ∀ b : S, s b ⟨_, aS⟩ → r b a }
theorem ord_cof_eq (r : α → α → Prop) [IsWellOrder α r] :
    ∃ S, Unbounded r S ∧ type (Subrel r S) = (cof (type r)).ord := by
  let ⟨S, hS, e⟩ := cof_eq r
  let ⟨s, _, e'⟩ := Cardinal.ord_eq S
  let T : Set α := { a | ∃ aS : a ∈ S, ∀ b : S, s b ⟨_, aS⟩ → r b a }
  

Proof state:
α : Type u_1
r✝ r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
hS : Unbounded r S
e : #↑S = cof (type r)
s : ↑S → ↑S → Prop
w✝ : IsWellOrder (↑S) s
e' : ord #↑S = type s
T : Set α := {a | ∃ (aS : a ∈ S), ∀ (b : ↑S), s b { val := a, property := aS } → r (↑b) a}
⊢ ∃ S, Unbounded r S ∧ type (Subrel r S) = ord (cof (type r))

Next tactic:
suffices : Unbounded r T
theorem ord_cof_eq (r : α → α → Prop) [IsWellOrder α r] :
    ∃ S, Unbounded r S ∧ type (Subrel r S) = (cof (type r)).ord := by
  let ⟨S, hS, e⟩ := cof_eq r
  let ⟨s, _, e'⟩ := Cardinal.ord_eq S
  let T : Set α := { a | ∃ aS : a ∈ S, ∀ b : S, s b ⟨_, aS⟩ → r b a }
  suffices : Unbounded r T
  · 

Proof state:
α : Type u_1
r✝ r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
hS : Unbounded r S
e : #↑S = cof (type r)
s : ↑S → ↑S → Prop
w✝ : IsWellOrder (↑S) s
e' : ord #↑S = type s
T : Set α := {a | ∃ (aS : a ∈ S), ∀ (b : ↑S), s b { val := a, property := aS } → r (↑b) a}
this : Unbounded r T
⊢ ∃ S, Unbounded r S ∧ type (Subrel r S) = ord (cof (type r))

Next tactic:
refine' ⟨T, this, le_antisymm _ (Cardinal.ord_le.2 <| cof_type_le this)⟩
theorem ord_cof_eq (r : α → α → Prop) [IsWellOrder α r] :
    ∃ S, Unbounded r S ∧ type (Subrel r S) = (cof (type r)).ord := by
  let ⟨S, hS, e⟩ := cof_eq r
  let ⟨s, _, e'⟩ := Cardinal.ord_eq S
  let T : Set α := { a | ∃ aS : a ∈ S, ∀ b : S, s b ⟨_, aS⟩ → r b a }
  suffices : Unbounded r T
  · refine' ⟨T, this, le_antisymm _ (Cardinal.ord_le.2 <| cof_type_le this)⟩
    

Proof state:
α : Type u_1
r✝ r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
hS : Unbounded r S
e : #↑S = cof (type r)
s : ↑S → ↑S → Prop
w✝ : IsWellOrder (↑S) s
e' : ord #↑S = type s
T : Set α := {a | ∃ (aS : a ∈ S), ∀ (b : ↑S), s b { val := a, property := aS } → r (↑b) a}
this : Unbounded r T
⊢ type (Subrel r T) ≤ ord (cof (type r))

Next tactic:
rw [← e, e']
theorem ord_cof_eq (r : α → α → Prop) [IsWellOrder α r] :
    ∃ S, Unbounded r S ∧ type (Subrel r S) = (cof (type r)).ord := by
  let ⟨S, hS, e⟩ := cof_eq r
  let ⟨s, _, e'⟩ := Cardinal.ord_eq S
  let T : Set α := { a | ∃ aS : a ∈ S, ∀ b : S, s b ⟨_, aS⟩ → r b a }
  suffices : Unbounded r T
  · refine' ⟨T, this, le_antisymm _ (Cardinal.ord_le.2 <| cof_type_le this)⟩
    rw [← e, e']
    

Proof state:
α : Type u_1
r✝ r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
hS : Unbounded r S
e : #↑S = cof (type r)
s : ↑S → ↑S → Prop
w✝ : IsWellOrder (↑S) s
e' : ord #↑S = type s
T : Set α := {a | ∃ (aS : a ∈ S), ∀ (b : ↑S), s b { val := a, property := aS } → r (↑b) a}
this : Unbounded r T
⊢ type (Subrel r T) ≤ type s

Next tactic:
refine'
      (RelEmbedding.ofMonotone
          (fun a : T =>
            (⟨a,
                let ⟨aS, _⟩ := a.2
                aS⟩ :
              S))
          fun a b h => _).ordinal_type_le
theorem ord_cof_eq (r : α → α → Prop) [IsWellOrder α r] :
    ∃ S, Unbounded r S ∧ type (Subrel r S) = (cof (type r)).ord := by
  let ⟨S, hS, e⟩ := cof_eq r
  let ⟨s, _, e'⟩ := Cardinal.ord_eq S
  let T : Set α := { a | ∃ aS : a ∈ S, ∀ b : S, s b ⟨_, aS⟩ → r b a }
  suffices : Unbounded r T
  · refine' ⟨T, this, le_antisymm _ (Cardinal.ord_le.2 <| cof_type_le this)⟩
    rw [← e, e']
    refine'
      (RelEmbedding.ofMonotone
          (fun a : T =>
            (⟨a,
                let ⟨aS, _⟩ := a.2
                aS⟩ :
              S))
          fun a b h => _).ordinal_type_le
    

Proof state:
α : Type u_1
r✝ r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
hS : Unbounded r S
e : #↑S = cof (type r)
s : ↑S → ↑S → Prop
w✝ : IsWellOrder (↑S) s
e' : ord #↑S = type s
T : Set α := {a | ∃ (aS : a ∈ S), ∀ (b : ↑S), s b { val := a, property := aS } → r (↑b) a}
this : Unbounded r T
a b : ↑T
h : Subrel r T a b
⊢ s ((fun a => { val := ↑a, property := (_ : ↑a ∈ S) }) a) ((fun a => { val := ↑a, property := (_ : ↑a ∈ S) }) b)

Next tactic:
rcases a with ⟨a, aS, ha⟩
theorem ord_cof_eq (r : α → α → Prop) [IsWellOrder α r] :
    ∃ S, Unbounded r S ∧ type (Subrel r S) = (cof (type r)).ord := by
  let ⟨S, hS, e⟩ := cof_eq r
  let ⟨s, _, e'⟩ := Cardinal.ord_eq S
  let T : Set α := { a | ∃ aS : a ∈ S, ∀ b : S, s b ⟨_, aS⟩ → r b a }
  suffices : Unbounded r T
  · refine' ⟨T, this, le_antisymm _ (Cardinal.ord_le.2 <| cof_type_le this)⟩
    rw [← e, e']
    refine'
      (RelEmbedding.ofMonotone
          (fun a : T =>
            (⟨a,
                let ⟨aS, _⟩ := a.2
                aS⟩ :
              S))
          fun a b h => _).ordinal_type_le
    rcases a with ⟨a, aS, ha⟩
    

Proof state:
case mk.intro
α : Type u_1
r✝ r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
hS : Unbounded r S
e : #↑S = cof (type r)
s : ↑S → ↑S → Prop
w✝ : IsWellOrder (↑S) s
e' : ord #↑S = type s
T : Set α := {a | ∃ (aS : a ∈ S), ∀ (b : ↑S), s b { val := a, property := aS } → r (↑b) a}
this : Unbounded r T
b : ↑T
a : α
aS : a ∈ S
ha : ∀ (b : ↑S), s b { val := a, property := aS } → r (↑b) a
h : Subrel r T { val := a, property := (_ : ∃ (aS : a ∈ S), ∀ (b : ↑S), s b { val := a, property := aS } → r (↑b) a) } b
⊢ s
    ((fun a => { val := ↑a, property := (_ : ↑a ∈ S) })
      { val := a, property := (_ : ∃ (aS : a ∈ S), ∀ (b : ↑S), s b { val := a, property := aS } → r (↑b) a) })
    ((fun a => { val := ↑a, property := (_ : ↑a ∈ S) }) b)

Next tactic:
rcases b with ⟨b, bS, hb⟩