l3lab/ntp-mathlib huggingface dataset:
theorem cof_eq_sInf_lsub (o : Ordinal.{u}) : cof o =
    sInf { a : Cardinal | ∃ (ι : Type u) (f : ι → Ordinal), lsub.{u, u} f = o ∧ #ι = a } := by
  refine' le_antisymm (le_csInf (cof_lsub_def_nonempty o) _) (csInf_le' _)
  · rintro a ⟨ι, f, hf, rfl⟩
    rw [← type_lt o]
    refine'
      (cof_type_le fun a => _).trans
        (@mk_le_of_injective _ _
          (fun s : typein ((· < ·) : o.out.α → o.out.α → Prop) ⁻¹' Set.range f =>
            Classical.choose s.prop)
          fun s t hst => by
          let H := congr_arg f hst
          rwa [Classical.choose_spec s.prop, Classical.choose_spec t.prop, typein_inj,
            Subtype.coe_inj] at H)
    have := typein_lt_self a
    simp_rw [← hf, lt_lsub_iff] at this
    cases' this with i hi
    refine' ⟨enum (· < ·) (f i) _, _, _⟩
    · rw [type_lt, ← hf]
      apply lt_lsub
    · rw [mem_preimage, typein_enum]
      exact mem_range_self i
    · rwa [← typein_le_typein, typein_enum]
  · rcases cof_eq (· < · : (Quotient.out o).α → (Quotient.out o).α → Prop) with ⟨S, hS, hS'⟩
    let f : S → Ordinal := fun s => typein LT.lt s.val
    refine'
      ⟨S, f, le_antisymm (lsub_le fun i => typein_lt_self i) (le_of_forall_lt fun a ha => _), by
        

Proof state:
α : Type u_1
r : α → α → Prop
o : Ordinal.{u}
S : Set (Quotient.out o).α
hS : Unbounded (fun x x_1 => x < x_1) S
hS' : #↑S = cof (type fun x x_1 => x < x_1)
f : ↑S → Ordinal.{u} := fun s => typein LT.lt ↑s
⊢ #↑S = cof o

Next tactic:
rwa [type_lt o] at hS'
theorem cof_eq_sInf_lsub (o : Ordinal.{u}) : cof o =
    sInf { a : Cardinal | ∃ (ι : Type u) (f : ι → Ordinal), lsub.{u, u} f = o ∧ #ι = a } := by
  refine' le_antisymm (le_csInf (cof_lsub_def_nonempty o) _) (csInf_le' _)
  · rintro a ⟨ι, f, hf, rfl⟩
    rw [← type_lt o]
    refine'
      (cof_type_le fun a => _).trans
        (@mk_le_of_injective _ _
          (fun s : typein ((· < ·) : o.out.α → o.out.α → Prop) ⁻¹' Set.range f =>
            Classical.choose s.prop)
          fun s t hst => by
          let H := congr_arg f hst
          rwa [Classical.choose_spec s.prop, Classical.choose_spec t.prop, typein_inj,
            Subtype.coe_inj] at H)
    have := typein_lt_self a
    simp_rw [← hf, lt_lsub_iff] at this
    cases' this with i hi
    refine' ⟨enum (· < ·) (f i) _, _, _⟩
    · rw [type_lt, ← hf]
      apply lt_lsub
    · rw [mem_preimage, typein_enum]
      exact mem_range_self i
    · rwa [← typein_le_typein, typein_enum]
  · rcases cof_eq (· < · : (Quotient.out o).α → (Quotient.out o).α → Prop) with ⟨S, hS, hS'⟩
    let f : S → Ordinal := fun s => typein LT.lt s.val
    refine'
      ⟨S, f, le_antisymm (lsub_le fun i => typein_lt_self i) (le_of_forall_lt fun a ha => _), by
        rwa [type_lt o] at hS'⟩
    

Proof state:
case refine'_2.intro.intro
α : Type u_1
r : α → α → Prop
o : Ordinal.{u}
S : Set (Quotient.out o).α
hS : Unbounded (fun x x_1 => x < x_1) S
hS' : #↑S = cof (type fun x x_1 => x < x_1)
f : ↑S → Ordinal.{u} := fun s => typein LT.lt ↑s
a : Ordinal.{u}
ha : a < o
⊢ a < lsub f

Next tactic:
rw [← type_lt o] at ha
theorem cof_eq_sInf_lsub (o : Ordinal.{u}) : cof o =
    sInf { a : Cardinal | ∃ (ι : Type u) (f : ι → Ordinal), lsub.{u, u} f = o ∧ #ι = a } := by
  refine' le_antisymm (le_csInf (cof_lsub_def_nonempty o) _) (csInf_le' _)
  · rintro a ⟨ι, f, hf, rfl⟩
    rw [← type_lt o]
    refine'
      (cof_type_le fun a => _).trans
        (@mk_le_of_injective _ _
          (fun s : typein ((· < ·) : o.out.α → o.out.α → Prop) ⁻¹' Set.range f =>
            Classical.choose s.prop)
          fun s t hst => by
          let H := congr_arg f hst
          rwa [Classical.choose_spec s.prop, Classical.choose_spec t.prop, typein_inj,
            Subtype.coe_inj] at H)
    have := typein_lt_self a
    simp_rw [← hf, lt_lsub_iff] at this
    cases' this with i hi
    refine' ⟨enum (· < ·) (f i) _, _, _⟩
    · rw [type_lt, ← hf]
      apply lt_lsub
    · rw [mem_preimage, typein_enum]
      exact mem_range_self i
    · rwa [← typein_le_typein, typein_enum]
  · rcases cof_eq (· < · : (Quotient.out o).α → (Quotient.out o).α → Prop) with ⟨S, hS, hS'⟩
    let f : S → Ordinal := fun s => typein LT.lt s.val
    refine'
      ⟨S, f, le_antisymm (lsub_le fun i => typein_lt_self i) (le_of_forall_lt fun a ha => _), by
        rwa [type_lt o] at hS'⟩
    rw [← type_lt o] at ha
    

Proof state:
case refine'_2.intro.intro
α : Type u_1
r : α → α → Prop
o : Ordinal.{u}
S : Set (Quotient.out o).α
hS : Unbounded (fun x x_1 => x < x_1) S
hS' : #↑S = cof (type fun x x_1 => x < x_1)
f : ↑S → Ordinal.{u} := fun s => typein LT.lt ↑s
a : Ordinal.{u}
ha : a < type fun x x_1 => x < x_1
⊢ a < lsub f

Next tactic:
rcases hS (enum (· < ·) a ha) with ⟨b, hb, hb'⟩
theorem cof_eq_sInf_lsub (o : Ordinal.{u}) : cof o =
    sInf { a : Cardinal | ∃ (ι : Type u) (f : ι → Ordinal), lsub.{u, u} f = o ∧ #ι = a } := by
  refine' le_antisymm (le_csInf (cof_lsub_def_nonempty o) _) (csInf_le' _)
  · rintro a ⟨ι, f, hf, rfl⟩
    rw [← type_lt o]
    refine'
      (cof_type_le fun a => _).trans
        (@mk_le_of_injective _ _
          (fun s : typein ((· < ·) : o.out.α → o.out.α → Prop) ⁻¹' Set.range f =>
            Classical.choose s.prop)
          fun s t hst => by
          let H := congr_arg f hst
          rwa [Classical.choose_spec s.prop, Classical.choose_spec t.prop, typein_inj,
            Subtype.coe_inj] at H)
    have := typein_lt_self a
    simp_rw [← hf, lt_lsub_iff] at this
    cases' this with i hi
    refine' ⟨enum (· < ·) (f i) _, _, _⟩
    · rw [type_lt, ← hf]
      apply lt_lsub
    · rw [mem_preimage, typein_enum]
      exact mem_range_self i
    · rwa [← typein_le_typein, typein_enum]
  · rcases cof_eq (· < · : (Quotient.out o).α → (Quotient.out o).α → Prop) with ⟨S, hS, hS'⟩
    let f : S → Ordinal := fun s => typein LT.lt s.val
    refine'
      ⟨S, f, le_antisymm (lsub_le fun i => typein_lt_self i) (le_of_forall_lt fun a ha => _), by
        rwa [type_lt o] at hS'⟩
    rw [← type_lt o] at ha
    rcases hS (enum (· < ·) a ha) with ⟨b, hb, hb'⟩
    

Proof state:
case refine'_2.intro.intro.intro.intro
α : Type u_1
r : α → α → Prop
o : Ordinal.{u}
S : Set (Quotient.out o).α
hS : Unbounded (fun x x_1 => x < x_1) S
hS' : #↑S = cof (type fun x x_1 => x < x_1)
f : ↑S → Ordinal.{u} := fun s => typein LT.lt ↑s
a : Ordinal.{u}
ha : a < type fun x x_1 => x < x_1
b : (Quotient.out o).α
hb : b ∈ S
hb' : ¬(fun x x_1 => x < x_1) b (enum (fun x x_1 => x < x_1) a ha)
⊢ a < lsub f

Next tactic:
rw [← typein_le_typein, typein_enum] at hb'
theorem cof_eq_sInf_lsub (o : Ordinal.{u}) : cof o =
    sInf { a : Cardinal | ∃ (ι : Type u) (f : ι → Ordinal), lsub.{u, u} f = o ∧ #ι = a } := by
  refine' le_antisymm (le_csInf (cof_lsub_def_nonempty o) _) (csInf_le' _)
  · rintro a ⟨ι, f, hf, rfl⟩
    rw [← type_lt o]
    refine'
      (cof_type_le fun a => _).trans
        (@mk_le_of_injective _ _
          (fun s : typein ((· < ·) : o.out.α → o.out.α → Prop) ⁻¹' Set.range f =>
            Classical.choose s.prop)
          fun s t hst => by
          let H := congr_arg f hst
          rwa [Classical.choose_spec s.prop, Classical.choose_spec t.prop, typein_inj,
            Subtype.coe_inj] at H)
    have := typein_lt_self a
    simp_rw [← hf, lt_lsub_iff] at this
    cases' this with i hi
    refine' ⟨enum (· < ·) (f i) _, _, _⟩
    · rw [type_lt, ← hf]
      apply lt_lsub
    · rw [mem_preimage, typein_enum]
      exact mem_range_self i
    · rwa [← typein_le_typein, typein_enum]
  · rcases cof_eq (· < · : (Quotient.out o).α → (Quotient.out o).α → Prop) with ⟨S, hS, hS'⟩
    let f : S → Ordinal := fun s => typein LT.lt s.val
    refine'
      ⟨S, f, le_antisymm (lsub_le fun i => typein_lt_self i) (le_of_forall_lt fun a ha => _), by
        rwa [type_lt o] at hS'⟩
    rw [← type_lt o] at ha
    rcases hS (enum (· < ·) a ha) with ⟨b, hb, hb'⟩
    rw [← typein_le_typein, typein_enum] at hb'
    

Proof state:
case refine'_2.intro.intro.intro.intro
α : Type u_1
r : α → α → Prop
o : Ordinal.{u}
S : Set (Quotient.out o).α
hS : Unbounded (fun x x_1 => x < x_1) S
hS' : #↑S = cof (type fun x x_1 => x < x_1)
f : ↑S → Ordinal.{u} := fun s => typein LT.lt ↑s
a : Ordinal.{u}
ha : a < type fun x x_1 => x < x_1
b : (Quotient.out o).α
hb : b ∈ S
hb' : a ≤ typein LT.lt b
⊢ a < lsub f

Next tactic:
exact hb'.trans_lt (lt_lsub.{u, u} f ⟨b, hb⟩)
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  

Proof state:
α : Type u_1
r : α → α → Prop
o : Ordinal.{v}
⊢ Cardinal.lift.{u, v} (cof o) = cof (lift.{u, v} o)

Next tactic:
refine' inductionOn o _
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  

Proof state:
α : Type u_1
r : α → α → Prop
o : Ordinal.{v}
⊢ ∀ (α : Type v) (r : α → α → Prop) [inst : IsWellOrder α r],
    Cardinal.lift.{u, v} (cof (type r)) = cof (lift.{u, v} (type r))

Next tactic:
intro α r _
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  

Proof state:
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
⊢ Cardinal.lift.{u, v} (cof (type r)) = cof (lift.{u, v} (type r))

Next tactic:
apply le_antisymm
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  apply le_antisymm
  · 

Proof state:
case a
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
⊢ Cardinal.lift.{u, v} (cof (type r)) ≤ cof (lift.{u, v} (type r))

Next tactic:
refine' le_cof_type.2 fun S H => _
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  apply le_antisymm
  · refine' le_cof_type.2 fun S H => _
    

Proof state:
case a
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set (ULift.{u, v} { α := α, r := r, wo := inst✝ }.α)
H : Unbounded (ULift.down ⁻¹'o { α := α, r := r, wo := inst✝ }.r) S
⊢ Cardinal.lift.{u, v} (cof (type r)) ≤ #↑S

Next tactic:
have : Cardinal.lift.{u, v} #(ULift.up ⁻¹' S) ≤ #(S : Type (max u v)) := by
      rw [← Cardinal.lift_umax.{v, u}, ← Cardinal.lift_id'.{v, u} #S]
      refine mk_preimage_of_injective_lift.{v, max u v} ULift.up S (ULift.up_injective.{u, v})
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  apply le_antisymm
  · refine' le_cof_type.2 fun S H => _
    have : Cardinal.lift.{u, v} #(ULift.up ⁻¹' S) ≤ #(S : Type (max u v)) := by
      

Proof state:
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set (ULift.{u, v} { α := α, r := r, wo := inst✝ }.α)
H : Unbounded (ULift.down ⁻¹'o { α := α, r := r, wo := inst✝ }.r) S
⊢ Cardinal.lift.{u, v} #↑(ULift.up ⁻¹' S) ≤ #↑S

Next tactic:
rw [← Cardinal.lift_umax.{v, u}, ← Cardinal.lift_id'.{v, u} #S]
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  apply le_antisymm
  · refine' le_cof_type.2 fun S H => _
    have : Cardinal.lift.{u, v} #(ULift.up ⁻¹' S) ≤ #(S : Type (max u v)) := by
      rw [← Cardinal.lift_umax.{v, u}, ← Cardinal.lift_id'.{v, u} #S]
      

Proof state:
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set (ULift.{u, v} { α := α, r := r, wo := inst✝ }.α)
H : Unbounded (ULift.down ⁻¹'o { α := α, r := r, wo := inst✝ }.r) S
⊢ Cardinal.lift.{max v u, v} #↑(ULift.up ⁻¹' S) ≤ Cardinal.lift.{v, max v u} #↑S

Next tactic:
refine mk_preimage_of_injective_lift.{v, max u v} ULift.up S (ULift.up_injective.{u, v})
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  apply le_antisymm
  · refine' le_cof_type.2 fun S H => _
    have : Cardinal.lift.{u, v} #(ULift.up ⁻¹' S) ≤ #(S : Type (max u v)) := by
      rw [← Cardinal.lift_umax.{v, u}, ← Cardinal.lift_id'.{v, u} #S]
      refine mk_preimage_of_injective_lift.{v, max u v} ULift.up S (ULift.up_injective.{u, v})
    

Proof state:
case a
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set (ULift.{u, v} { α := α, r := r, wo := inst✝ }.α)
H : Unbounded (ULift.down ⁻¹'o { α := α, r := r, wo := inst✝ }.r) S
this : Cardinal.lift.{u, v} #↑(ULift.up ⁻¹' S) ≤ #↑S
⊢ Cardinal.lift.{u, v} (cof (type r)) ≤ #↑S

Next tactic:
refine' (Cardinal.lift_le.2 <| cof_type_le _).trans this
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  apply le_antisymm
  · refine' le_cof_type.2 fun S H => _
    have : Cardinal.lift.{u, v} #(ULift.up ⁻¹' S) ≤ #(S : Type (max u v)) := by
      rw [← Cardinal.lift_umax.{v, u}, ← Cardinal.lift_id'.{v, u} #S]
      refine mk_preimage_of_injective_lift.{v, max u v} ULift.up S (ULift.up_injective.{u, v})
    refine' (Cardinal.lift_le.2 <| cof_type_le _).trans this
    

Proof state:
case a
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set (ULift.{u, v} { α := α, r := r, wo := inst✝ }.α)
H : Unbounded (ULift.down ⁻¹'o { α := α, r := r, wo := inst✝ }.r) S
this : Cardinal.lift.{u, v} #↑(ULift.up ⁻¹' S) ≤ #↑S
⊢ Unbounded r (ULift.up ⁻¹' S)

Next tactic:
exact fun a =>
      let ⟨⟨b⟩, bs, br⟩ := H ⟨a⟩
      ⟨b, bs, br⟩
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  apply le_antisymm
  · refine' le_cof_type.2 fun S H => _
    have : Cardinal.lift.{u, v} #(ULift.up ⁻¹' S) ≤ #(S : Type (max u v)) := by
      rw [← Cardinal.lift_umax.{v, u}, ← Cardinal.lift_id'.{v, u} #S]
      refine mk_preimage_of_injective_lift.{v, max u v} ULift.up S (ULift.up_injective.{u, v})
    refine' (Cardinal.lift_le.2 <| cof_type_le _).trans this
    exact fun a =>
      let ⟨⟨b⟩, bs, br⟩ := H ⟨a⟩
      ⟨b, bs, br⟩
  · 

Proof state:
case a
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
⊢ cof (lift.{u, v} (type r)) ≤ Cardinal.lift.{u, v} (cof (type r))

Next tactic:
rcases cof_eq r with ⟨S, H, e'⟩
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  apply le_antisymm
  · refine' le_cof_type.2 fun S H => _
    have : Cardinal.lift.{u, v} #(ULift.up ⁻¹' S) ≤ #(S : Type (max u v)) := by
      rw [← Cardinal.lift_umax.{v, u}, ← Cardinal.lift_id'.{v, u} #S]
      refine mk_preimage_of_injective_lift.{v, max u v} ULift.up S (ULift.up_injective.{u, v})
    refine' (Cardinal.lift_le.2 <| cof_type_le _).trans this
    exact fun a =>
      let ⟨⟨b⟩, bs, br⟩ := H ⟨a⟩
      ⟨b, bs, br⟩
  · rcases cof_eq r with ⟨S, H, e'⟩
    

Proof state:
case a.intro.intro
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
H : Unbounded r S
e' : #↑S = cof (type r)
⊢ cof (lift.{u, v} (type r)) ≤ Cardinal.lift.{u, v} (cof (type r))

Next tactic:
have : #(ULift.down.{u, v} ⁻¹' S) ≤ Cardinal.lift.{u, v} #S :=
      ⟨⟨fun ⟨⟨x⟩, h⟩ => ⟨⟨x, h⟩⟩, fun ⟨⟨x⟩, h₁⟩ ⟨⟨y⟩, h₂⟩ e => by
          simp at e; congr⟩⟩
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  apply le_antisymm
  · refine' le_cof_type.2 fun S H => _
    have : Cardinal.lift.{u, v} #(ULift.up ⁻¹' S) ≤ #(S : Type (max u v)) := by
      rw [← Cardinal.lift_umax.{v, u}, ← Cardinal.lift_id'.{v, u} #S]
      refine mk_preimage_of_injective_lift.{v, max u v} ULift.up S (ULift.up_injective.{u, v})
    refine' (Cardinal.lift_le.2 <| cof_type_le _).trans this
    exact fun a =>
      let ⟨⟨b⟩, bs, br⟩ := H ⟨a⟩
      ⟨b, bs, br⟩
  · rcases cof_eq r with ⟨S, H, e'⟩
    have : #(ULift.down.{u, v} ⁻¹' S) ≤ Cardinal.lift.{u, v} #S :=
      ⟨⟨fun ⟨⟨x⟩, h⟩ => ⟨⟨x, h⟩⟩, fun ⟨⟨x⟩, h₁⟩ ⟨⟨y⟩, h₂⟩ e => by
          

Proof state:
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
H : Unbounded r S
e' : #↑S = cof (type r)
x✝¹ x✝ : ↑(ULift.down ⁻¹' S)
x : α
h₁ : { down := x } ∈ ULift.down ⁻¹' S
y : α
h₂ : { down := y } ∈ ULift.down ⁻¹' S
e :
  (fun x =>
        match x with
        | { val := { down := x }, property := h } => { down := { val := x, property := h } })
      { val := { down := x }, property := h₁ } =
    (fun x =>
        match x with
        | { val := { down := x }, property := h } => { down := { val := x, property := h } })
      { val := { down := y }, property := h₂ }
⊢ { val := { down := x }, property := h₁ } = { val := { down := y }, property := h₂ }

Next tactic:
simp at e
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  apply le_antisymm
  · refine' le_cof_type.2 fun S H => _
    have : Cardinal.lift.{u, v} #(ULift.up ⁻¹' S) ≤ #(S : Type (max u v)) := by
      rw [← Cardinal.lift_umax.{v, u}, ← Cardinal.lift_id'.{v, u} #S]
      refine mk_preimage_of_injective_lift.{v, max u v} ULift.up S (ULift.up_injective.{u, v})
    refine' (Cardinal.lift_le.2 <| cof_type_le _).trans this
    exact fun a =>
      let ⟨⟨b⟩, bs, br⟩ := H ⟨a⟩
      ⟨b, bs, br⟩
  · rcases cof_eq r with ⟨S, H, e'⟩
    have : #(ULift.down.{u, v} ⁻¹' S) ≤ Cardinal.lift.{u, v} #S :=
      ⟨⟨fun ⟨⟨x⟩, h⟩ => ⟨⟨x, h⟩⟩, fun ⟨⟨x⟩, h₁⟩ ⟨⟨y⟩, h₂⟩ e => by
          simp at e; 

Proof state:
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
H : Unbounded r S
e' : #↑S = cof (type r)
x✝¹ x✝ : ↑(ULift.down ⁻¹' S)
x : α
h₁ : { down := x } ∈ ULift.down ⁻¹' S
y : α
h₂ : { down := y } ∈ ULift.down ⁻¹' S
e : x = y
⊢ { val := { down := x }, property := h₁ } = { val := { down := y }, property := h₂ }

Next tactic:
congr
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  apply le_antisymm
  · refine' le_cof_type.2 fun S H => _
    have : Cardinal.lift.{u, v} #(ULift.up ⁻¹' S) ≤ #(S : Type (max u v)) := by
      rw [← Cardinal.lift_umax.{v, u}, ← Cardinal.lift_id'.{v, u} #S]
      refine mk_preimage_of_injective_lift.{v, max u v} ULift.up S (ULift.up_injective.{u, v})
    refine' (Cardinal.lift_le.2 <| cof_type_le _).trans this
    exact fun a =>
      let ⟨⟨b⟩, bs, br⟩ := H ⟨a⟩
      ⟨b, bs, br⟩
  · rcases cof_eq r with ⟨S, H, e'⟩
    have : #(ULift.down.{u, v} ⁻¹' S) ≤ Cardinal.lift.{u, v} #S :=
      ⟨⟨fun ⟨⟨x⟩, h⟩ => ⟨⟨x, h⟩⟩, fun ⟨⟨x⟩, h₁⟩ ⟨⟨y⟩, h₂⟩ e => by
          simp at e; congr⟩⟩
    

Proof state:
case a.intro.intro
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
H : Unbounded r S
e' : #↑S = cof (type r)
this : #↑(ULift.down ⁻¹' S) ≤ Cardinal.lift.{u, v} #↑S
⊢ cof (lift.{u, v} (type r)) ≤ Cardinal.lift.{u, v} (cof (type r))

Next tactic:
rw [e'] at this
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  apply le_antisymm
  · refine' le_cof_type.2 fun S H => _
    have : Cardinal.lift.{u, v} #(ULift.up ⁻¹' S) ≤ #(S : Type (max u v)) := by
      rw [← Cardinal.lift_umax.{v, u}, ← Cardinal.lift_id'.{v, u} #S]
      refine mk_preimage_of_injective_lift.{v, max u v} ULift.up S (ULift.up_injective.{u, v})
    refine' (Cardinal.lift_le.2 <| cof_type_le _).trans this
    exact fun a =>
      let ⟨⟨b⟩, bs, br⟩ := H ⟨a⟩
      ⟨b, bs, br⟩
  · rcases cof_eq r with ⟨S, H, e'⟩
    have : #(ULift.down.{u, v} ⁻¹' S) ≤ Cardinal.lift.{u, v} #S :=
      ⟨⟨fun ⟨⟨x⟩, h⟩ => ⟨⟨x, h⟩⟩, fun ⟨⟨x⟩, h₁⟩ ⟨⟨y⟩, h₂⟩ e => by
          simp at e; congr⟩⟩
    rw [e'] at this
    

Proof state:
case a.intro.intro
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
H : Unbounded r S
e' : #↑S = cof (type r)
this : #↑(ULift.down ⁻¹' S) ≤ Cardinal.lift.{u, v} (cof (type r))
⊢ cof (lift.{u, v} (type r)) ≤ Cardinal.lift.{u, v} (cof (type r))

Next tactic:
refine' (cof_type_le _).trans this
@[simp]
theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by
  refine' inductionOn o _
  intro α r _
  apply le_antisymm
  · refine' le_cof_type.2 fun S H => _
    have : Cardinal.lift.{u, v} #(ULift.up ⁻¹' S) ≤ #(S : Type (max u v)) := by
      rw [← Cardinal.lift_umax.{v, u}, ← Cardinal.lift_id'.{v, u} #S]
      refine mk_preimage_of_injective_lift.{v, max u v} ULift.up S (ULift.up_injective.{u, v})
    refine' (Cardinal.lift_le.2 <| cof_type_le _).trans this
    exact fun a =>
      let ⟨⟨b⟩, bs, br⟩ := H ⟨a⟩
      ⟨b, bs, br⟩
  · rcases cof_eq r with ⟨S, H, e'⟩
    have : #(ULift.down.{u, v} ⁻¹' S) ≤ Cardinal.lift.{u, v} #S :=
      ⟨⟨fun ⟨⟨x⟩, h⟩ => ⟨⟨x, h⟩⟩, fun ⟨⟨x⟩, h₁⟩ ⟨⟨y⟩, h₂⟩ e => by
          simp at e; congr⟩⟩
    rw [e'] at this
    refine' (cof_type_le _).trans this
    

Proof state:
case a.intro.intro
α✝ : Type u_1
r✝ : α✝ → α✝ → Prop
o : Ordinal.{v}
α : Type v
r : α → α → Prop
inst✝ : IsWellOrder α r
S : Set α
H : Unbounded r S
e' : #↑S = cof (type r)
this : #↑(ULift.down ⁻¹' S) ≤ Cardinal.lift.{u, v} (cof (type r))
⊢ Unbounded (ULift.down ⁻¹'o { α := α, r := r, wo := inst✝ }.r) (ULift.down ⁻¹' S)

Next tactic:
exact fun ⟨a⟩ =>
      let ⟨b, bs, br⟩ := H a
      ⟨⟨b⟩, bs, br⟩
theorem cof_le_card (o) : cof o ≤ card o := by
  

Proof state:
α : Type u_1
r : α → α → Prop
o : Ordinal.{u_2}
⊢ cof o ≤ card o

Next tactic:
rw [cof_eq_sInf_lsub]
theorem cof_le_card (o) : cof o ≤ card o := by
  rw [cof_eq_sInf_lsub]
  

Proof state:
α : Type u_1
r : α → α → Prop
o : Ordinal.{u_2}
⊢ sInf {a | ∃ ι f, lsub f = o ∧ #ι = a} ≤ card o

Next tactic:
exact csInf_le' card_mem_cof
theorem cof_ord_le (c : Cardinal) : c.ord.cof ≤ c := by 

Proof state:
α : Type u_1
r : α → α → Prop
c : Cardinal.{u_2}
⊢ cof (ord c) ≤ c

Next tactic:
simpa using cof_le_card c.ord
theorem exists_lsub_cof (o : Ordinal) :
    ∃ (ι : _) (f : ι → Ordinal), lsub.{u, u} f = o ∧ #ι = cof o := by
  

Proof state:
α : Type u_1
r : α → α → Prop
o : Ordinal.{u}
⊢ ∃ ι f, lsub f = o ∧ #ι = cof o

Next tactic:
rw [cof_eq_sInf_lsub]
theorem exists_lsub_cof (o : Ordinal) :
    ∃ (ι : _) (f : ι → Ordinal), lsub.{u, u} f = o ∧ #ι = cof o := by
  rw [cof_eq_sInf_lsub]
  

Proof state:
α : Type u_1
r : α → α → Prop
o : Ordinal.{u}
⊢ ∃ ι f, lsub f = o ∧ #ι = sInf {a | ∃ ι f, lsub f = o ∧ #ι = a}

Next tactic:
exact csInf_mem (cof_lsub_def_nonempty o)
theorem cof_lsub_le {ι} (f : ι → Ordinal) : cof (lsub.{u, u} f) ≤ #ι := by
  

Proof state:
α : Type u_1
r : α → α → Prop
ι : Type u
f : ι → Ordinal.{u}
⊢ cof (lsub f) ≤ #ι

Next tactic:
rw [cof_eq_sInf_lsub]
theorem cof_lsub_le {ι} (f : ι → Ordinal) : cof (lsub.{u, u} f) ≤ #ι := by
  rw [cof_eq_sInf_lsub]
  

Proof state:
α : Type u_1
r : α → α → Prop
ι : Type u
f : ι → Ordinal.{u}
⊢ sInf {a | ∃ ι_1 f_1, lsub f_1 = lsub f ∧ #ι_1 = a} ≤ #ι

Next tactic:
exact csInf_le' ⟨ι, f, rfl, rfl⟩
theorem cof_lsub_le_lift {ι} (f : ι → Ordinal) :
    cof (lsub.{u, v} f) ≤ Cardinal.lift.{v, u} #ι := by
  

Proof state:
α : Type u_1
r : α → α → Prop
ι : Type u
f : ι → Ordinal.{max u v}
⊢ cof (lsub f) ≤ Cardinal.lift.{v, u} #ι

Next tactic:
rw [← mk_uLift.{u, v}]
theorem cof_lsub_le_lift {ι} (f : ι → Ordinal) :
    cof (lsub.{u, v} f) ≤ Cardinal.lift.{v, u} #ι := by
  rw [← mk_uLift.{u, v}]
  

Proof state:
α : Type u_1
r : α → α → Prop
ι : Type u
f : ι → Ordinal.{max u v}
⊢ cof (lsub f) ≤ #(ULift.{v, u} ι)

Next tactic:
convert cof_lsub_le.{max u v} fun i : ULift.{v, u} ι => f i.down
theorem cof_lsub_le_lift {ι} (f : ι → Ordinal) :
    cof (lsub.{u, v} f) ≤ Cardinal.lift.{v, u} #ι := by
  rw [← mk_uLift.{u, v}]
  convert cof_lsub_le.{max u v} fun i : ULift.{v, u} ι => f i.down
  

Proof state:
case h.e'_3.h.e'_1
α : Type u_1
r : α → α → Prop
ι : Type u
f : ι → Ordinal.{max u v}
⊢ lsub f = lsub fun i => f i.down

Next tactic:
exact
    lsub_eq_of_range_eq.{u, max u v, max u v}
      (Set.ext fun x => ⟨fun ⟨i, hi⟩ => ⟨ULift.up.{v, u} i, hi⟩, fun ⟨i, hi⟩ => ⟨_, hi⟩⟩)