l3lab/ntp-mathlib huggingface dataset:
theorem preimage_eq (f : α → β) (s : Set β) : f ⁻¹' s = (Function.graph f).preimage s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : α → β
s : Set β
⊢ f ⁻¹' s = Rel.preimage (Function.graph f) s

Next tactic:
simp [Set.preimage, Rel.preimage, Rel.inv, flip, Rel.image]
theorem preimage_eq_core (f : α → β) (s : Set β) : f ⁻¹' s = (Function.graph f).core s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : α → β
s : Set β
⊢ f ⁻¹' s = Rel.core (Function.graph f) s

Next tactic:
simp [Set.preimage, Rel.core]
@[simp]
theorem lift_succ (a : Ordinal.{v}) : lift.{u} (succ a) = succ (lift.{u} a) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
a : Ordinal.{v}
⊢ lift.{u, v} (succ a) = succ (lift.{u, v} a)

Next tactic:
rw [← add_one_eq_succ, lift_add, lift_one]
@[simp]
theorem lift_succ (a : Ordinal.{v}) : lift.{u} (succ a) = succ (lift.{u} a) := by
  rw [← add_one_eq_succ, lift_add, lift_one]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
a : Ordinal.{v}
⊢ lift.{u, v} a + 1 = succ (lift.{u, v} a)

Next tactic:
rfl
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
  ⟨fun a b c =>
    inductionOn a fun α r hr =>
      inductionOn b fun β₁ s₁ hs₁ =>
        inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
          ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
              

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
r✝ : α✝ → α✝ → Prop
s : β → β → Prop
t : γ → γ → Prop
a✝ b c : Ordinal.{u}
α : Type u
r : α → α → Prop
hr : IsWellOrder α r
β₁ : Type u
s₁ : β₁ → β₁ → Prop
hs₁ : IsWellOrder β₁ s₁
β₂ : Type u
s₂ : β₂ → β₂ → Prop
hs₂ : IsWellOrder β₂ s₂
x✝ : type r + type s₁ ≤ type r + type s₂
f : Sum.Lex r s₁ ≼i Sum.Lex r s₂
a : α
⊢ f (Sum.inl a) = Sum.inl a

Next tactic:
simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
                @InitialSeg.eq _ _ _ _ _
                  ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
  ⟨fun a b c =>
    inductionOn a fun α r hr =>
      inductionOn b fun β₁ s₁ hs₁ =>
        inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
          ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
              simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
                @InitialSeg.eq _ _ _ _ _
                  ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
            have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by
              

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
r✝ : α✝ → α✝ → Prop
s : β → β → Prop
t : γ → γ → Prop
a b c : Ordinal.{u}
α : Type u
r : α → α → Prop
hr : IsWellOrder α r
β₁ : Type u
s₁ : β₁ → β₁ → Prop
hs₁ : IsWellOrder β₁ s₁
β₂ : Type u
s₂ : β₂ → β₂ → Prop
hs₂ : IsWellOrder β₂ s₂
x✝ : type r + type s₁ ≤ type r + type s₂
f : Sum.Lex r s₁ ≼i Sum.Lex r s₂
fl : ∀ (a : α), f (Sum.inl a) = Sum.inl a
⊢ (b : β₁) → { b' // f (Sum.inr b) = Sum.inr b' }

Next tactic:
intro b
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
  ⟨fun a b c =>
    inductionOn a fun α r hr =>
      inductionOn b fun β₁ s₁ hs₁ =>
        inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
          ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
              simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
                @InitialSeg.eq _ _ _ _ _
                  ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
            have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by
              intro b; 

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
r✝ : α✝ → α✝ → Prop
s : β → β → Prop
t : γ → γ → Prop
a b✝ c : Ordinal.{u}
α : Type u
r : α → α → Prop
hr : IsWellOrder α r
β₁ : Type u
s₁ : β₁ → β₁ → Prop
hs₁ : IsWellOrder β₁ s₁
β₂ : Type u
s₂ : β₂ → β₂ → Prop
hs₂ : IsWellOrder β₂ s₂
x✝ : type r + type s₁ ≤ type r + type s₂
f : Sum.Lex r s₁ ≼i Sum.Lex r s₂
fl : ∀ (a : α), f (Sum.inl a) = Sum.inl a
b : β₁
⊢ { b' // f (Sum.inr b) = Sum.inr b' }

Next tactic:
cases e : f (Sum.inr b)
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
  ⟨fun a b c =>
    inductionOn a fun α r hr =>
      inductionOn b fun β₁ s₁ hs₁ =>
        inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
          ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
              simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
                @InitialSeg.eq _ _ _ _ _
                  ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
            have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by
              intro b; cases e : f (Sum.inr b)
              · 

Proof state:
case inl
α✝ : Type u_1
β : Type u_2
γ : Type u_3
r✝ : α✝ → α✝ → Prop
s : β → β → Prop
t : γ → γ → Prop
a b✝ c : Ordinal.{u}
α : Type u
r : α → α → Prop
hr : IsWellOrder α r
β₁ : Type u
s₁ : β₁ → β₁ → Prop
hs₁ : IsWellOrder β₁ s₁
β₂ : Type u
s₂ : β₂ → β₂ → Prop
hs₂ : IsWellOrder β₂ s₂
x✝ : type r + type s₁ ≤ type r + type s₂
f : Sum.Lex r s₁ ≼i Sum.Lex r s₂
fl : ∀ (a : α), f (Sum.inl a) = Sum.inl a
b : β₁
val✝ : α
e : f (Sum.inr b) = Sum.inl val✝
⊢ { b' // Sum.inl val✝ = Sum.inr b' }

Next tactic:
rw [← fl] at e
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
  ⟨fun a b c =>
    inductionOn a fun α r hr =>
      inductionOn b fun β₁ s₁ hs₁ =>
        inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
          ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
              simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
                @InitialSeg.eq _ _ _ _ _
                  ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
            have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by
              intro b; cases e : f (Sum.inr b)
              · rw [← fl] at e
                

Proof state:
case inl
α✝ : Type u_1
β : Type u_2
γ : Type u_3
r✝ : α✝ → α✝ → Prop
s : β → β → Prop
t : γ → γ → Prop
a b✝ c : Ordinal.{u}
α : Type u
r : α → α → Prop
hr : IsWellOrder α r
β₁ : Type u
s₁ : β₁ → β₁ → Prop
hs₁ : IsWellOrder β₁ s₁
β₂ : Type u
s₂ : β₂ → β₂ → Prop
hs₂ : IsWellOrder β₂ s₂
x✝ : type r + type s₁ ≤ type r + type s₂
f : Sum.Lex r s₁ ≼i Sum.Lex r s₂
fl : ∀ (a : α), f (Sum.inl a) = Sum.inl a
b : β₁
val✝ : α
e : f (Sum.inr b) = f (Sum.inl val✝)
⊢ { b' // Sum.inl val✝ = Sum.inr b' }

Next tactic:
have := f.inj' e
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
  ⟨fun a b c =>
    inductionOn a fun α r hr =>
      inductionOn b fun β₁ s₁ hs₁ =>
        inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
          ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
              simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
                @InitialSeg.eq _ _ _ _ _
                  ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
            have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by
              intro b; cases e : f (Sum.inr b)
              · rw [← fl] at e
                have := f.inj' e
                

Proof state:
case inl
α✝ : Type u_1
β : Type u_2
γ : Type u_3
r✝ : α✝ → α✝ → Prop
s : β → β → Prop
t : γ → γ → Prop
a b✝ c : Ordinal.{u}
α : Type u
r : α → α → Prop
hr : IsWellOrder α r
β₁ : Type u
s₁ : β₁ → β₁ → Prop
hs₁ : IsWellOrder β₁ s₁
β₂ : Type u
s₂ : β₂ → β₂ → Prop
hs₂ : IsWellOrder β₂ s₂
x✝ : type r + type s₁ ≤ type r + type s₂
f : Sum.Lex r s₁ ≼i Sum.Lex r s₂
fl : ∀ (a : α), f (Sum.inl a) = Sum.inl a
b : β₁
val✝ : α
e : f (Sum.inr b) = f (Sum.inl val✝)
this : Sum.inr b = Sum.inl val✝
⊢ { b' // Sum.inl val✝ = Sum.inr b' }

Next tactic:
contradiction
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
  ⟨fun a b c =>
    inductionOn a fun α r hr =>
      inductionOn b fun β₁ s₁ hs₁ =>
        inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
          ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
              simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
                @InitialSeg.eq _ _ _ _ _
                  ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
            have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by
              intro b; cases e : f (Sum.inr b)
              · rw [← fl] at e
                have := f.inj' e
                contradiction
              · 

Proof state:
case inr
α✝ : Type u_1
β : Type u_2
γ : Type u_3
r✝ : α✝ → α✝ → Prop
s : β → β → Prop
t : γ → γ → Prop
a b✝ c : Ordinal.{u}
α : Type u
r : α → α → Prop
hr : IsWellOrder α r
β₁ : Type u
s₁ : β₁ → β₁ → Prop
hs₁ : IsWellOrder β₁ s₁
β₂ : Type u
s₂ : β₂ → β₂ → Prop
hs₂ : IsWellOrder β₂ s₂
x✝ : type r + type s₁ ≤ type r + type s₂
f : Sum.Lex r s₁ ≼i Sum.Lex r s₂
fl : ∀ (a : α), f (Sum.inl a) = Sum.inl a
b : β₁
val✝ : β₂
e : f (Sum.inr b) = Sum.inr val✝
⊢ { b' // Sum.inr val✝ = Sum.inr b' }

Next tactic:
exact ⟨_, rfl⟩
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
  ⟨fun a b c =>
    inductionOn a fun α r hr =>
      inductionOn b fun β₁ s₁ hs₁ =>
        inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
          ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
              simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
                @InitialSeg.eq _ _ _ _ _
                  ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
            have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by
              intro b; cases e : f (Sum.inr b)
              · rw [← fl] at e
                have := f.inj' e
                contradiction
              · exact ⟨_, rfl⟩
            let g (b) := (this b).1
            have fr : ∀ b, f (Sum.inr b) = Sum.inr (g b) := fun b => (this b).2
            ⟨⟨⟨g, fun x y h => by
                  

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
r✝ : α✝ → α✝ → Prop
s : β → β → Prop
t : γ → γ → Prop
a b c : Ordinal.{u}
α : Type u
r : α → α → Prop
hr : IsWellOrder α r
β₁ : Type u
s₁ : β₁ → β₁ → Prop
hs₁ : IsWellOrder β₁ s₁
β₂ : Type u
s₂ : β₂ → β₂ → Prop
hs₂ : IsWellOrder β₂ s₂
x✝ : type r + type s₁ ≤ type r + type s₂
f : Sum.Lex r s₁ ≼i Sum.Lex r s₂
fl : ∀ (a : α), f (Sum.inl a) = Sum.inl a
this : (b : β₁) → { b' // f (Sum.inr b) = Sum.inr b' }
g : β₁ → β₂ := fun b => ↑(this b)
fr : ∀ (b : β₁), f (Sum.inr b) = Sum.inr (g b)
x y : β₁
h : g x = g y
⊢ x = y

Next tactic:
injection f.inj' (by rw [fr, fr, h] : f (Sum.inr x) = f (Sum.inr y))
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
  ⟨fun a b c =>
    inductionOn a fun α r hr =>
      inductionOn b fun β₁ s₁ hs₁ =>
        inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
          ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
              simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
                @InitialSeg.eq _ _ _ _ _
                  ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
            have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by
              intro b; cases e : f (Sum.inr b)
              · rw [← fl] at e
                have := f.inj' e
                contradiction
              · exact ⟨_, rfl⟩
            let g (b) := (this b).1
            have fr : ∀ b, f (Sum.inr b) = Sum.inr (g b) := fun b => (this b).2
            ⟨⟨⟨g, fun x y h => by
                  injection f.inj' (by 

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
r✝ : α✝ → α✝ → Prop
s : β → β → Prop
t : γ → γ → Prop
a b c : Ordinal.{u}
α : Type u
r : α → α → Prop
hr : IsWellOrder α r
β₁ : Type u
s₁ : β₁ → β₁ → Prop
hs₁ : IsWellOrder β₁ s₁
β₂ : Type u
s₂ : β₂ → β₂ → Prop
hs₂ : IsWellOrder β₂ s₂
x✝ : type r + type s₁ ≤ type r + type s₂
f : Sum.Lex r s₁ ≼i Sum.Lex r s₂
fl : ∀ (a : α), f (Sum.inl a) = Sum.inl a
this : (b : β₁) → { b' // f (Sum.inr b) = Sum.inr b' }
g : β₁ → β₂ := fun b => ↑(this b)
fr : ∀ (b : β₁), f (Sum.inr b) = Sum.inr (g b)
x y : β₁
h : g x = g y
⊢ f (Sum.inr x) = f (Sum.inr y)

Next tactic:
rw [fr, fr, h]
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
  ⟨fun a b c =>
    inductionOn a fun α r hr =>
      inductionOn b fun β₁ s₁ hs₁ =>
        inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
          ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
              simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
                @InitialSeg.eq _ _ _ _ _
                  ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
            have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by
              intro b; cases e : f (Sum.inr b)
              · rw [← fl] at e
                have := f.inj' e
                contradiction
              · exact ⟨_, rfl⟩
            let g (b) := (this b).1
            have fr : ∀ b, f (Sum.inr b) = Sum.inr (g b) := fun b => (this b).2
            ⟨⟨⟨g, fun x y h => by
                  injection f.inj' (by rw [fr, fr, h] : f (Sum.inr x) = f (Sum.inr y))⟩,
                @fun a b => by
                  -- Porting note:
                  --  `relEmbedding.coe_fn_to_embedding` & `initial_seg.coe_fn_to_rel_embedding`
                  --  → `InitialSeg.coe_coe_fn`
                  

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
r✝ : α✝ → α✝ → Prop
s : β → β → Prop
t : γ → γ → Prop
a✝ b✝ c : Ordinal.{u}
α : Type u
r : α → α → Prop
hr : IsWellOrder α r
β₁ : Type u
s₁ : β₁ → β₁ → Prop
hs₁ : IsWellOrder β₁ s₁
β₂ : Type u
s₂ : β₂ → β₂ → Prop
hs₂ : IsWellOrder β₂ s₂
x✝ : type r + type s₁ ≤ type r + type s₂
f : Sum.Lex r s₁ ≼i Sum.Lex r s₂
fl : ∀ (a : α), f (Sum.inl a) = Sum.inl a
this : (b : β₁) → { b' // f (Sum.inr b) = Sum.inr b' }
g : β₁ → β₂ := fun b => ↑(this b)
fr : ∀ (b : β₁), f (Sum.inr b) = Sum.inr (g b)
a b : β₁
⊢ s₂ ({ toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) } a)
      ({ toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) } b) ↔
    s₁ a b

Next tactic:
simpa only [Sum.lex_inr_inr, fr, InitialSeg.coe_coe_fn, Embedding.coeFn_mk] using
                    @RelEmbedding.map_rel_iff _ _ _ _ f.toRelEmbedding (Sum.inr a) (Sum.inr b)
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
  ⟨fun a b c =>
    inductionOn a fun α r hr =>
      inductionOn b fun β₁ s₁ hs₁ =>
        inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
          ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
              simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
                @InitialSeg.eq _ _ _ _ _
                  ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
            have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by
              intro b; cases e : f (Sum.inr b)
              · rw [← fl] at e
                have := f.inj' e
                contradiction
              · exact ⟨_, rfl⟩
            let g (b) := (this b).1
            have fr : ∀ b, f (Sum.inr b) = Sum.inr (g b) := fun b => (this b).2
            ⟨⟨⟨g, fun x y h => by
                  injection f.inj' (by rw [fr, fr, h] : f (Sum.inr x) = f (Sum.inr y))⟩,
                @fun a b => by
                  -- Porting note:
                  --  `relEmbedding.coe_fn_to_embedding` & `initial_seg.coe_fn_to_rel_embedding`
                  --  → `InitialSeg.coe_coe_fn`
                  simpa only [Sum.lex_inr_inr, fr, InitialSeg.coe_coe_fn, Embedding.coeFn_mk] using
                    @RelEmbedding.map_rel_iff _ _ _ _ f.toRelEmbedding (Sum.inr a) (Sum.inr b)⟩,
              fun a b H => by
                

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
r✝ : α✝ → α✝ → Prop
s : β → β → Prop
t : γ → γ → Prop
a✝ b✝ c : Ordinal.{u}
α : Type u
r : α → α → Prop
hr : IsWellOrder α r
β₁ : Type u
s₁ : β₁ → β₁ → Prop
hs₁ : IsWellOrder β₁ s₁
β₂ : Type u
s₂ : β₂ → β₂ → Prop
hs₂ : IsWellOrder β₂ s₂
x✝ : type r + type s₁ ≤ type r + type s₂
f : Sum.Lex r s₁ ≼i Sum.Lex r s₂
fl : ∀ (a : α), f (Sum.inl a) = Sum.inl a
this : (b : β₁) → { b' // f (Sum.inr b) = Sum.inr b' }
g : β₁ → β₂ := fun b => ↑(this b)
fr : ∀ (b : β₁), f (Sum.inr b) = Sum.inr (g b)
a : β₁
b : β₂
H :
  s₂ b
    ({ toEmbedding := { toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) },
        map_rel_iff' :=
          (_ :
            ∀ (a b : β₁),
              s₂ ({ toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) } a)
                  ({ toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) } b) ↔
                s₁ a b) }
      a)
⊢ ∃ a',
    { toEmbedding := { toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) },
          map_rel_iff' :=
            (_ :
              ∀ (a b : β₁),
                s₂ ({ toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) } a)
                    ({ toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) } b) ↔
                  s₁ a b) }
        a' =
      b

Next tactic:
rcases f.init (by rw [fr] <;> exact Sum.lex_inr_inr.2 H) with ⟨a' | a', h⟩
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
  ⟨fun a b c =>
    inductionOn a fun α r hr =>
      inductionOn b fun β₁ s₁ hs₁ =>
        inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
          ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
              simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
                @InitialSeg.eq _ _ _ _ _
                  ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
            have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by
              intro b; cases e : f (Sum.inr b)
              · rw [← fl] at e
                have := f.inj' e
                contradiction
              · exact ⟨_, rfl⟩
            let g (b) := (this b).1
            have fr : ∀ b, f (Sum.inr b) = Sum.inr (g b) := fun b => (this b).2
            ⟨⟨⟨g, fun x y h => by
                  injection f.inj' (by rw [fr, fr, h] : f (Sum.inr x) = f (Sum.inr y))⟩,
                @fun a b => by
                  -- Porting note:
                  --  `relEmbedding.coe_fn_to_embedding` & `initial_seg.coe_fn_to_rel_embedding`
                  --  → `InitialSeg.coe_coe_fn`
                  simpa only [Sum.lex_inr_inr, fr, InitialSeg.coe_coe_fn, Embedding.coeFn_mk] using
                    @RelEmbedding.map_rel_iff _ _ _ _ f.toRelEmbedding (Sum.inr a) (Sum.inr b)⟩,
              fun a b H => by
                rcases f.init (by 

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
r✝ : α✝ → α✝ → Prop
s : β → β → Prop
t : γ → γ → Prop
a✝ b✝ c : Ordinal.{u}
α : Type u
r : α → α → Prop
hr : IsWellOrder α r
β₁ : Type u
s₁ : β₁ → β₁ → Prop
hs₁ : IsWellOrder β₁ s₁
β₂ : Type u
s₂ : β₂ → β₂ → Prop
hs₂ : IsWellOrder β₂ s₂
x✝ : type r + type s₁ ≤ type r + type s₂
f : Sum.Lex r s₁ ≼i Sum.Lex r s₂
fl : ∀ (a : α), f (Sum.inl a) = Sum.inl a
this : (b : β₁) → { b' // f (Sum.inr b) = Sum.inr b' }
g : β₁ → β₂ := fun b => ↑(this b)
fr : ∀ (b : β₁), f (Sum.inr b) = Sum.inr (g b)
a : β₁
b : β₂
H :
  s₂ b
    ({ toEmbedding := { toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) },
        map_rel_iff' :=
          (_ :
            ∀ (a b : β₁),
              s₂ ({ toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) } a)
                  ({ toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) } b) ↔
                s₁ a b) }
      a)
⊢ Sum.Lex r s₂ ?m.57677 (f ?m.57676)

Next tactic:
rw [fr]
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
  ⟨fun a b c =>
    inductionOn a fun α r hr =>
      inductionOn b fun β₁ s₁ hs₁ =>
        inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
          ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
              simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
                @InitialSeg.eq _ _ _ _ _
                  ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
            have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by
              intro b; cases e : f (Sum.inr b)
              · rw [← fl] at e
                have := f.inj' e
                contradiction
              · exact ⟨_, rfl⟩
            let g (b) := (this b).1
            have fr : ∀ b, f (Sum.inr b) = Sum.inr (g b) := fun b => (this b).2
            ⟨⟨⟨g, fun x y h => by
                  injection f.inj' (by rw [fr, fr, h] : f (Sum.inr x) = f (Sum.inr y))⟩,
                @fun a b => by
                  -- Porting note:
                  --  `relEmbedding.coe_fn_to_embedding` & `initial_seg.coe_fn_to_rel_embedding`
                  --  → `InitialSeg.coe_coe_fn`
                  simpa only [Sum.lex_inr_inr, fr, InitialSeg.coe_coe_fn, Embedding.coeFn_mk] using
                    @RelEmbedding.map_rel_iff _ _ _ _ f.toRelEmbedding (Sum.inr a) (Sum.inr b)⟩,
              fun a b H => by
                rcases f.init (by rw [fr] <;> 

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
r✝ : α✝ → α✝ → Prop
s : β → β → Prop
t : γ → γ → Prop
a✝ b✝ c : Ordinal.{u}
α : Type u
r : α → α → Prop
hr : IsWellOrder α r
β₁ : Type u
s₁ : β₁ → β₁ → Prop
hs₁ : IsWellOrder β₁ s₁
β₂ : Type u
s₂ : β₂ → β₂ → Prop
hs₂ : IsWellOrder β₂ s₂
x✝ : type r + type s₁ ≤ type r + type s₂
f : Sum.Lex r s₁ ≼i Sum.Lex r s₂
fl : ∀ (a : α), f (Sum.inl a) = Sum.inl a
this : (b : β₁) → { b' // f (Sum.inr b) = Sum.inr b' }
g : β₁ → β₂ := fun b => ↑(this b)
fr : ∀ (b : β₁), f (Sum.inr b) = Sum.inr (g b)
a : β₁
b : β₂
H :
  s₂ b
    ({ toEmbedding := { toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) },
        map_rel_iff' :=
          (_ :
            ∀ (a b : β₁),
              s₂ ({ toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) } a)
                  ({ toFun := g, inj' := (_ : ∀ (x y : β₁), g x = g y → x = y) } b) ↔
                s₁ a b) }
      a)
⊢ Sum.Lex r s₂ ?m.57677 (Sum.inr (g ?m.57740))

Next tactic:
exact Sum.lex_inr_inr.2 H