l3lab/ntp-mathlib huggingface dataset:
/-- It suffices to prove `f` is monotone between strict relations
  to show it is a relation embedding. -/
def ofMonotone [IsTrichotomous α r] [IsAsymm β s] (f : α → β) (H : ∀ a b, r a b → s (f a) (f b)) :
    r ↪r s := by
  haveI := @IsAsymm.isIrrefl β s _
  refine' ⟨⟨f, fun a b e => _⟩, @fun a b => ⟨fun h => _, H _ _⟩⟩
  · refine' ((@trichotomous _ r _ a b).resolve_left _).resolve_right _ <;>
      

Proof state:
case refine'_1.refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
inst✝¹ : IsTrichotomous α r
inst✝ : IsAsymm β s
f : α → β
H : ∀ (a b : α), r a b → s (f a) (f b)
this : IsIrrefl β s
a b : α
e : f a = f b
⊢ ¬r b a

Next tactic:
exact fun h => @irrefl _ s _ _ (by simpa [e] using H _ _ h)
/-- It suffices to prove `f` is monotone between strict relations
  to show it is a relation embedding. -/
def ofMonotone [IsTrichotomous α r] [IsAsymm β s] (f : α → β) (H : ∀ a b, r a b → s (f a) (f b)) :
    r ↪r s := by
  haveI := @IsAsymm.isIrrefl β s _
  refine' ⟨⟨f, fun a b e => _⟩, @fun a b => ⟨fun h => _, H _ _⟩⟩
  · refine' ((@trichotomous _ r _ a b).resolve_left _).resolve_right _ <;>
      exact fun h => @irrefl _ s _ _ (by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
inst✝¹ : IsTrichotomous α r
inst✝ : IsAsymm β s
f : α → β
H : ∀ (a b : α), r a b → s (f a) (f b)
this : IsIrrefl β s
a b : α
e : f a = f b
h : r b a
⊢ s (?m.43838 h) (?m.43838 h)

Next tactic:
simpa [e] using H _ _ h
/-- It suffices to prove `f` is monotone between strict relations
  to show it is a relation embedding. -/
def ofMonotone [IsTrichotomous α r] [IsAsymm β s] (f : α → β) (H : ∀ a b, r a b → s (f a) (f b)) :
    r ↪r s := by
  haveI := @IsAsymm.isIrrefl β s _
  refine' ⟨⟨f, fun a b e => _⟩, @fun a b => ⟨fun h => _, H _ _⟩⟩
  · refine' ((@trichotomous _ r _ a b).resolve_left _).resolve_right _ <;>
      exact fun h => @irrefl _ s _ _ (by simpa [e] using H _ _ h)
  · 

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
inst✝¹ : IsTrichotomous α r
inst✝ : IsAsymm β s
f : α → β
H : ∀ (a b : α), r a b → s (f a) (f b)
this : IsIrrefl β s
a b : α
h :
  s ({ toFun := f, inj' := (_ : ∀ (a b : α), f a = f b → a = b) } a)
    ({ toFun := f, inj' := (_ : ∀ (a b : α), f a = f b → a = b) } b)
⊢ r a b

Next tactic:
refine' (@trichotomous _ r _ a b).resolve_right (Or.rec (fun e => _) fun h' => _)
/-- It suffices to prove `f` is monotone between strict relations
  to show it is a relation embedding. -/
def ofMonotone [IsTrichotomous α r] [IsAsymm β s] (f : α → β) (H : ∀ a b, r a b → s (f a) (f b)) :
    r ↪r s := by
  haveI := @IsAsymm.isIrrefl β s _
  refine' ⟨⟨f, fun a b e => _⟩, @fun a b => ⟨fun h => _, H _ _⟩⟩
  · refine' ((@trichotomous _ r _ a b).resolve_left _).resolve_right _ <;>
      exact fun h => @irrefl _ s _ _ (by simpa [e] using H _ _ h)
  · refine' (@trichotomous _ r _ a b).resolve_right (Or.rec (fun e => _) fun h' => _)
    · 

Proof state:
case refine'_2.refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
inst✝¹ : IsTrichotomous α r
inst✝ : IsAsymm β s
f : α → β
H : ∀ (a b : α), r a b → s (f a) (f b)
this : IsIrrefl β s
a b : α
h :
  s ({ toFun := f, inj' := (_ : ∀ (a b : α), f a = f b → a = b) } a)
    ({ toFun := f, inj' := (_ : ∀ (a b : α), f a = f b → a = b) } b)
e : a = b
⊢ False

Next tactic:
subst e
/-- It suffices to prove `f` is monotone between strict relations
  to show it is a relation embedding. -/
def ofMonotone [IsTrichotomous α r] [IsAsymm β s] (f : α → β) (H : ∀ a b, r a b → s (f a) (f b)) :
    r ↪r s := by
  haveI := @IsAsymm.isIrrefl β s _
  refine' ⟨⟨f, fun a b e => _⟩, @fun a b => ⟨fun h => _, H _ _⟩⟩
  · refine' ((@trichotomous _ r _ a b).resolve_left _).resolve_right _ <;>
      exact fun h => @irrefl _ s _ _ (by simpa [e] using H _ _ h)
  · refine' (@trichotomous _ r _ a b).resolve_right (Or.rec (fun e => _) fun h' => _)
    · subst e
      

Proof state:
case refine'_2.refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
inst✝¹ : IsTrichotomous α r
inst✝ : IsAsymm β s
f : α → β
H : ∀ (a b : α), r a b → s (f a) (f b)
this : IsIrrefl β s
a : α
h :
  s ({ toFun := f, inj' := (_ : ∀ (a b : α), f a = f b → a = b) } a)
    ({ toFun := f, inj' := (_ : ∀ (a b : α), f a = f b → a = b) } a)
⊢ False

Next tactic:
exact irrefl _ h
/-- It suffices to prove `f` is monotone between strict relations
  to show it is a relation embedding. -/
def ofMonotone [IsTrichotomous α r] [IsAsymm β s] (f : α → β) (H : ∀ a b, r a b → s (f a) (f b)) :
    r ↪r s := by
  haveI := @IsAsymm.isIrrefl β s _
  refine' ⟨⟨f, fun a b e => _⟩, @fun a b => ⟨fun h => _, H _ _⟩⟩
  · refine' ((@trichotomous _ r _ a b).resolve_left _).resolve_right _ <;>
      exact fun h => @irrefl _ s _ _ (by simpa [e] using H _ _ h)
  · refine' (@trichotomous _ r _ a b).resolve_right (Or.rec (fun e => _) fun h' => _)
    · subst e
      exact irrefl _ h
    · 

Proof state:
case refine'_2.refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
inst✝¹ : IsTrichotomous α r
inst✝ : IsAsymm β s
f : α → β
H : ∀ (a b : α), r a b → s (f a) (f b)
this : IsIrrefl β s
a b : α
h :
  s ({ toFun := f, inj' := (_ : ∀ (a b : α), f a = f b → a = b) } a)
    ({ toFun := f, inj' := (_ : ∀ (a b : α), f a = f b → a = b) } b)
h' : r b a
⊢ False

Next tactic:
exact asymm (H _ _ h') h
/-- `Sum.map` as a relation embedding between `Sum.LiftRel` relations. -/
@[simps]
def sumLiftRelMap (f : r ↪r s) (g : t ↪r u) : Sum.LiftRel r t ↪r Sum.LiftRel s u where
  toFun := Sum.map f g
  inj' := f.injective.sum_map g.injective
  map_rel_iff' := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
f : r ↪r s
g : t ↪r u
⊢ ∀ {a b : α ⊕ γ},
    Sum.LiftRel s u ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } a)
        ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } b) ↔
      Sum.LiftRel r t a b

Next tactic:
rintro (a | b) (c | d)
/-- `Sum.map` as a relation embedding between `Sum.LiftRel` relations. -/
@[simps]
def sumLiftRelMap (f : r ↪r s) (g : t ↪r u) : Sum.LiftRel r t ↪r Sum.LiftRel s u where
  toFun := Sum.map f g
  inj' := f.injective.sum_map g.injective
  map_rel_iff' := by rintro (a | b) (c | d) <;> 

Proof state:
case inl.inl
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
f : r ↪r s
g : t ↪r u
a c : α
⊢ Sum.LiftRel s u ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inl a))
      ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inl c)) ↔
    Sum.LiftRel r t (Sum.inl a) (Sum.inl c)

Next tactic:
simp [f.map_rel_iff, g.map_rel_iff]
/-- `Sum.map` as a relation embedding between `Sum.LiftRel` relations. -/
@[simps]
def sumLiftRelMap (f : r ↪r s) (g : t ↪r u) : Sum.LiftRel r t ↪r Sum.LiftRel s u where
  toFun := Sum.map f g
  inj' := f.injective.sum_map g.injective
  map_rel_iff' := by rintro (a | b) (c | d) <;> 

Proof state:
case inl.inr
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
f : r ↪r s
g : t ↪r u
a : α
d : γ
⊢ Sum.LiftRel s u ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inl a))
      ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inr d)) ↔
    Sum.LiftRel r t (Sum.inl a) (Sum.inr d)

Next tactic:
simp [f.map_rel_iff, g.map_rel_iff]
/-- `Sum.map` as a relation embedding between `Sum.LiftRel` relations. -/
@[simps]
def sumLiftRelMap (f : r ↪r s) (g : t ↪r u) : Sum.LiftRel r t ↪r Sum.LiftRel s u where
  toFun := Sum.map f g
  inj' := f.injective.sum_map g.injective
  map_rel_iff' := by rintro (a | b) (c | d) <;> 

Proof state:
case inr.inl
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
f : r ↪r s
g : t ↪r u
b : γ
c : α
⊢ Sum.LiftRel s u ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inr b))
      ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inl c)) ↔
    Sum.LiftRel r t (Sum.inr b) (Sum.inl c)

Next tactic:
simp [f.map_rel_iff, g.map_rel_iff]
/-- `Sum.map` as a relation embedding between `Sum.LiftRel` relations. -/
@[simps]
def sumLiftRelMap (f : r ↪r s) (g : t ↪r u) : Sum.LiftRel r t ↪r Sum.LiftRel s u where
  toFun := Sum.map f g
  inj' := f.injective.sum_map g.injective
  map_rel_iff' := by rintro (a | b) (c | d) <;> 

Proof state:
case inr.inr
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
f : r ↪r s
g : t ↪r u
b d : γ
⊢ Sum.LiftRel s u ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inr b))
      ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inr d)) ↔
    Sum.LiftRel r t (Sum.inr b) (Sum.inr d)

Next tactic:
simp [f.map_rel_iff, g.map_rel_iff]
/-- `Sum.map` as a relation embedding between `Sum.Lex` relations. -/
@[simps]
def sumLexMap (f : r ↪r s) (g : t ↪r u) : Sum.Lex r t ↪r Sum.Lex s u where
  toFun := Sum.map f g
  inj' := f.injective.sum_map g.injective
  map_rel_iff' := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
f : r ↪r s
g : t ↪r u
⊢ ∀ {a b : α ⊕ γ},
    Sum.Lex s u ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } a)
        ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } b) ↔
      Sum.Lex r t a b

Next tactic:
rintro (a | b) (c | d)
/-- `Sum.map` as a relation embedding between `Sum.Lex` relations. -/
@[simps]
def sumLexMap (f : r ↪r s) (g : t ↪r u) : Sum.Lex r t ↪r Sum.Lex s u where
  toFun := Sum.map f g
  inj' := f.injective.sum_map g.injective
  map_rel_iff' := by rintro (a | b) (c | d) <;> 

Proof state:
case inl.inl
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
f : r ↪r s
g : t ↪r u
a c : α
⊢ Sum.Lex s u ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inl a))
      ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inl c)) ↔
    Sum.Lex r t (Sum.inl a) (Sum.inl c)

Next tactic:
simp [f.map_rel_iff, g.map_rel_iff]
/-- `Sum.map` as a relation embedding between `Sum.Lex` relations. -/
@[simps]
def sumLexMap (f : r ↪r s) (g : t ↪r u) : Sum.Lex r t ↪r Sum.Lex s u where
  toFun := Sum.map f g
  inj' := f.injective.sum_map g.injective
  map_rel_iff' := by rintro (a | b) (c | d) <;> 

Proof state:
case inl.inr
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
f : r ↪r s
g : t ↪r u
a : α
d : γ
⊢ Sum.Lex s u ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inl a))
      ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inr d)) ↔
    Sum.Lex r t (Sum.inl a) (Sum.inr d)

Next tactic:
simp [f.map_rel_iff, g.map_rel_iff]
/-- `Sum.map` as a relation embedding between `Sum.Lex` relations. -/
@[simps]
def sumLexMap (f : r ↪r s) (g : t ↪r u) : Sum.Lex r t ↪r Sum.Lex s u where
  toFun := Sum.map f g
  inj' := f.injective.sum_map g.injective
  map_rel_iff' := by rintro (a | b) (c | d) <;> 

Proof state:
case inr.inl
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
f : r ↪r s
g : t ↪r u
b : γ
c : α
⊢ Sum.Lex s u ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inr b))
      ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inl c)) ↔
    Sum.Lex r t (Sum.inr b) (Sum.inl c)

Next tactic:
simp [f.map_rel_iff, g.map_rel_iff]
/-- `Sum.map` as a relation embedding between `Sum.Lex` relations. -/
@[simps]
def sumLexMap (f : r ↪r s) (g : t ↪r u) : Sum.Lex r t ↪r Sum.Lex s u where
  toFun := Sum.map f g
  inj' := f.injective.sum_map g.injective
  map_rel_iff' := by rintro (a | b) (c | d) <;> 

Proof state:
case inr.inr
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
f : r ↪r s
g : t ↪r u
b d : γ
⊢ Sum.Lex s u ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inr b))
      ({ toFun := Sum.map ⇑f ⇑g, inj' := (_ : Injective (Sum.map ⇑f ⇑g)) } (Sum.inr d)) ↔
    Sum.Lex r t (Sum.inr b) (Sum.inr d)

Next tactic:
simp [f.map_rel_iff, g.map_rel_iff]
/-- `fun b ↦ Prod.mk a b` as a relation embedding. -/
@[simps]
def prodLexMkLeft (s : β → β → Prop) {a : α} (h : ¬r a a) : s ↪r Prod.Lex r s where
  toFun := Prod.mk a
  inj' := Prod.mk.inj_left a
  map_rel_iff' := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s✝ : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
s : β → β → Prop
a : α
h : ¬r a a
⊢ ∀ {a_1 b : β},
    Prod.Lex r s ({ toFun := Prod.mk a, inj' := (_ : Injective (Prod.mk a)) } a_1)
        ({ toFun := Prod.mk a, inj' := (_ : Injective (Prod.mk a)) } b) ↔
      s a_1 b

Next tactic:
simp [Prod.lex_def, h]
/-- `fun a ↦ Prod.mk a b` as a relation embedding. -/
@[simps]
def prodLexMkRight (r : α → α → Prop) {b : β} (h : ¬s b b) : r ↪r Prod.Lex r s where
  toFun a := (a, b)
  inj' := Prod.mk.inj_right b
  map_rel_iff' := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r✝ : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
r : α → α → Prop
b : β
h : ¬s b b
⊢ ∀ {a b_1 : α},
    Prod.Lex r s ({ toFun := fun a => (a, b), inj' := (_ : Injective fun a => (a, b)) } a)
        ({ toFun := fun a => (a, b), inj' := (_ : Injective fun a => (a, b)) } b_1) ↔
      r a b_1

Next tactic:
simp [Prod.lex_def, h]
/-- `Prod.map` as a relation embedding. -/
@[simps]
def prodLexMap (f : r ↪r s) (g : t ↪r u) : Prod.Lex r t ↪r Prod.Lex s u where
  toFun := Prod.map f g
  inj' := f.injective.Prod_map g.injective
  map_rel_iff' := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
f : r ↪r s
g : t ↪r u
⊢ ∀ {a b : α × γ},
    Prod.Lex s u ({ toFun := Prod.map ⇑f ⇑g, inj' := (_ : Injective (Prod.map ⇑f ⇑g)) } a)
        ({ toFun := Prod.map ⇑f ⇑g, inj' := (_ : Injective (Prod.map ⇑f ⇑g)) } b) ↔
      Prod.Lex r t a b

Next tactic:
simp [Prod.lex_def, f.map_rel_iff, g.map_rel_iff, f.inj]
theorem toEquiv_injective : Injective (toEquiv : r ≃r s → α ≃ β)
  | ⟨e₁, o₁⟩, ⟨e₂, _⟩, h => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
e₁ : α ≃ β
o₁ : ∀ {a b : α}, s (e₁ a) (e₁ b) ↔ r a b
e₂ : α ≃ β
map_rel_iff'✝ : ∀ {a b : α}, s (e₂ a) (e₂ b) ↔ r a b
h : { toEquiv := e₁, map_rel_iff' := o₁ }.toEquiv = { toEquiv := e₂, map_rel_iff' := map_rel_iff'✝ }.toEquiv
⊢ { toEquiv := e₁, map_rel_iff' := o₁ } = { toEquiv := e₂, map_rel_iff' := map_rel_iff'✝ }

Next tactic:
congr
/-- Inverse map of a relation isomorphism is a relation isomorphism. -/
protected def symm (f : r ≃r s) : s ≃r r :=
  ⟨f.toEquiv.symm, @fun a b => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
f : r ≃r s
a b : β
⊢ r (f.symm a) (f.symm b) ↔ s a b

Next tactic:
erw [← f.map_rel_iff, f.1.apply_symm_apply, f.1.apply_symm_apply]
/-- A relation isomorphism between equal relations on equal types. -/
@[simps! toEquiv apply]
protected def cast {α β : Type u} {r : α → α → Prop} {s : β → β → Prop} (h₁ : α = β)
    (h₂ : HEq r s) : r ≃r s :=
  ⟨Equiv.cast h₁, @fun a b => by
    

Proof state:
α✝ : Type u_1
β✝ : Type u_2
γ : Type u_3
δ : Type u_4
r✝ : α✝ → α✝ → Prop
s✝ : β✝ → β✝ → Prop
t : γ → γ → Prop
u : δ → δ → Prop
α β : Type u
r : α → α → Prop
s : β → β → Prop
h₁ : α = β
h₂ : HEq r s
a b : α
⊢ s ((Equiv.cast h₁) a) ((Equiv.cast h₁) b) ↔ r a b

Next tactic:
subst h₁
/-- A relation isomorphism between equal relations on equal types. -/
@[simps! toEquiv apply]
protected def cast {α β : Type u} {r : α → α → Prop} {s : β → β → Prop} (h₁ : α = β)
    (h₂ : HEq r s) : r ≃r s :=
  ⟨Equiv.cast h₁, @fun a b => by
    subst h₁
    

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r✝ : α✝ → α✝ → Prop
s✝ : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
α : Type u
r : α → α → Prop
a b : α
s : α → α → Prop
h₂ : HEq r s
⊢ s ((Equiv.cast (_ : α = α)) a) ((Equiv.cast (_ : α = α)) b) ↔ r a b

Next tactic:
rw [eq_of_heq h₂]
/-- A relation isomorphism between equal relations on equal types. -/
@[simps! toEquiv apply]
protected def cast {α β : Type u} {r : α → α → Prop} {s : β → β → Prop} (h₁ : α = β)
    (h₂ : HEq r s) : r ≃r s :=
  ⟨Equiv.cast h₁, @fun a b => by
    subst h₁
    rw [eq_of_heq h₂]
    

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r✝ : α✝ → α✝ → Prop
s✝ : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
α : Type u
r : α → α → Prop
a b : α
s : α → α → Prop
h₂ : HEq r s
⊢ s ((Equiv.cast (_ : α = α)) a) ((Equiv.cast (_ : α = α)) b) ↔ s a b

Next tactic:
rfl
@[simp]
protected theorem cast_trans {α β γ : Type u} {r : α → α → Prop} {s : β → β → Prop}
    {t : γ → γ → Prop} (h₁ : α = β) (h₁' : β = γ) (h₂ : HEq r s) (h₂' : HEq s t) :
    (RelIso.cast h₁ h₂).trans (RelIso.cast h₁' h₂') = RelIso.cast (h₁.trans h₁') (h₂.trans h₂') :=
  ext fun x => by 

Proof state:
α✝ : Type u_1
β✝ : Type u_2
γ✝ : Type u_3
δ : Type u_4
r✝ : α✝ → α✝ → Prop
s✝ : β✝ → β✝ → Prop
t✝ : γ✝ → γ✝ → Prop
u : δ → δ → Prop
α β γ : Type u
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
h₁ : α = β
h₁' : β = γ
h₂ : HEq r s
h₂' : HEq s t
x : α
⊢ (RelIso.trans (RelIso.cast h₁ h₂) (RelIso.cast h₁' h₂')) x = (RelIso.cast (_ : α = γ) (_ : HEq r t)) x

Next tactic:
subst h₁
@[simp]
protected theorem cast_trans {α β γ : Type u} {r : α → α → Prop} {s : β → β → Prop}
    {t : γ → γ → Prop} (h₁ : α = β) (h₁' : β = γ) (h₂ : HEq r s) (h₂' : HEq s t) :
    (RelIso.cast h₁ h₂).trans (RelIso.cast h₁' h₂') = RelIso.cast (h₁.trans h₁') (h₂.trans h₂') :=
  ext fun x => by subst h₁; 

Proof state:
α✝ : Type u_1
β : Type u_2
γ✝ : Type u_3
δ : Type u_4
r✝ : α✝ → α✝ → Prop
s✝ : β → β → Prop
t✝ : γ✝ → γ✝ → Prop
u : δ → δ → Prop
α γ : Type u
r : α → α → Prop
t : γ → γ → Prop
x : α
s : α → α → Prop
h₁' : α = γ
h₂ : HEq r s
h₂' : HEq s t
⊢ (RelIso.trans (RelIso.cast (_ : α = α) h₂) (RelIso.cast h₁' h₂')) x = (RelIso.cast (_ : α = γ) (_ : HEq r t)) x

Next tactic:
rfl
theorem rel_symm_apply (e : r ≃r s) {x y} : r x (e.symm y) ↔ s (e x) y := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
e : r ≃r s
x : α
y : β
⊢ r x ((RelIso.symm e) y) ↔ s (e x) y

Next tactic:
rw [← e.map_rel_iff, e.apply_symm_apply]
theorem symm_apply_rel (e : r ≃r s) {x y} : r (e.symm x) y ↔ s x (e y) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
e : r ≃r s
x : β
y : α
⊢ r ((RelIso.symm e) x) y ↔ s x (e y)

Next tactic:
rw [← e.map_rel_iff, e.apply_symm_apply]
/-- Given relation isomorphisms `r₁ ≃r s₁` and `r₂ ≃r s₂`, construct a relation isomorphism for the
lexicographic orders on the sum.
-/
def sumLexCongr {α₁ α₂ β₁ β₂ r₁ r₂ s₁ s₂} (e₁ : @RelIso α₁ β₁ r₁ s₁) (e₂ : @RelIso α₂ β₂ r₂ s₂) :
    Sum.Lex r₁ r₂ ≃r Sum.Lex s₁ s₂ :=
  ⟨Equiv.sumCongr e₁.toEquiv e₂.toEquiv, @fun a b => by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
α₁ : Type ?u.77965
α₂ : Type ?u.77973
β₁ : Type ?u.77966
β₂ : Type ?u.77974
r₁ : α₁ → α₁ → Prop
r₂ : α₂ → α₂ → Prop
s₁ : β₁ → β₁ → Prop
s₂ : β₂ → β₂ → Prop
e₁ : r₁ ≃r s₁
e₂ : r₂ ≃r s₂
a b : α₁ ⊕ α₂
⊢ Sum.Lex s₁ s₂ ((Equiv.sumCongr e₁.toEquiv e₂.toEquiv) a) ((Equiv.sumCongr e₁.toEquiv e₂.toEquiv) b) ↔
    Sum.Lex r₁ r₂ a b

Next tactic:
cases' e₁ with f hf
/-- Given relation isomorphisms `r₁ ≃r s₁` and `r₂ ≃r s₂`, construct a relation isomorphism for the
lexicographic orders on the sum.
-/
def sumLexCongr {α₁ α₂ β₁ β₂ r₁ r₂ s₁ s₂} (e₁ : @RelIso α₁ β₁ r₁ s₁) (e₂ : @RelIso α₂ β₂ r₂ s₂) :
    Sum.Lex r₁ r₂ ≃r Sum.Lex s₁ s₂ :=
  ⟨Equiv.sumCongr e₁.toEquiv e₂.toEquiv, @fun a b => by
    cases' e₁ with f hf; 

Proof state:
case mk
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
α₁ : Type ?u.77965
α₂ : Type ?u.77973
β₁ : Type ?u.77966
β₂ : Type ?u.77974
r₁ : α₁ → α₁ → Prop
r₂ : α₂ → α₂ → Prop
s₁ : β₁ → β₁ → Prop
s₂ : β₂ → β₂ → Prop
e₂ : r₂ ≃r s₂
a b : α₁ ⊕ α₂
f : α₁ ≃ β₁
hf : ∀ {a b : α₁}, s₁ (f a) (f b) ↔ r₁ a b
⊢ Sum.Lex s₁ s₂ ((Equiv.sumCongr { toEquiv := f, map_rel_iff' := hf }.toEquiv e₂.toEquiv) a)
      ((Equiv.sumCongr { toEquiv := f, map_rel_iff' := hf }.toEquiv e₂.toEquiv) b) ↔
    Sum.Lex r₁ r₂ a b

Next tactic:
cases' e₂ with g hg
/-- Given relation isomorphisms `r₁ ≃r s₁` and `r₂ ≃r s₂`, construct a relation isomorphism for the
lexicographic orders on the sum.
-/
def sumLexCongr {α₁ α₂ β₁ β₂ r₁ r₂ s₁ s₂} (e₁ : @RelIso α₁ β₁ r₁ s₁) (e₂ : @RelIso α₂ β₂ r₂ s₂) :
    Sum.Lex r₁ r₂ ≃r Sum.Lex s₁ s₂ :=
  ⟨Equiv.sumCongr e₁.toEquiv e₂.toEquiv, @fun a b => by
    cases' e₁ with f hf; cases' e₂ with g hg; 

Proof state:
case mk.mk
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
α₁ : Type ?u.77965
α₂ : Type ?u.77973
β₁ : Type ?u.77966
β₂ : Type ?u.77974
r₁ : α₁ → α₁ → Prop
r₂ : α₂ → α₂ → Prop
s₁ : β₁ → β₁ → Prop
s₂ : β₂ → β₂ → Prop
a b : α₁ ⊕ α₂
f : α₁ ≃ β₁
hf : ∀ {a b : α₁}, s₁ (f a) (f b) ↔ r₁ a b
g : α₂ ≃ β₂
hg : ∀ {a b : α₂}, s₂ (g a) (g b) ↔ r₂ a b
⊢ Sum.Lex s₁ s₂
      ((Equiv.sumCongr { toEquiv := f, map_rel_iff' := hf }.toEquiv { toEquiv := g, map_rel_iff' := hg }.toEquiv) a)
      ((Equiv.sumCongr { toEquiv := f, map_rel_iff' := hf }.toEquiv { toEquiv := g, map_rel_iff' := hg }.toEquiv) b) ↔
    Sum.Lex r₁ r₂ a b

Next tactic:
cases a
/-- Given relation isomorphisms `r₁ ≃r s₁` and `r₂ ≃r s₂`, construct a relation isomorphism for the
lexicographic orders on the sum.
-/
def sumLexCongr {α₁ α₂ β₁ β₂ r₁ r₂ s₁ s₂} (e₁ : @RelIso α₁ β₁ r₁ s₁) (e₂ : @RelIso α₂ β₂ r₂ s₂) :
    Sum.Lex r₁ r₂ ≃r Sum.Lex s₁ s₂ :=
  ⟨Equiv.sumCongr e₁.toEquiv e₂.toEquiv, @fun a b => by
    cases' e₁ with f hf; cases' e₂ with g hg; cases a <;> 

Proof state:
case mk.mk.inl
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
u : δ → δ → Prop
α₁ : Type ?u.77965
α₂ : Type ?u.77973
β₁ : Type ?u.77966
β₂ : Type ?u.77974
r₁ : α₁ → α₁ → Prop
r₂ : α₂ → α₂ → Prop
s₁ : β₁ → β₁ → Prop
s₂ : β₂ → β₂ → Prop
b : α₁ ⊕ α₂
f : α₁ ≃ β₁
hf : ∀ {a b : α₁}, s₁ (f a) (f b) ↔ r₁ a b
g : α₂ ≃ β₂
hg : ∀ {a b : α₂}, s₂ (g a) (g b) ↔ r₂ a b
val✝ : α₁
⊢ Sum.Lex s₁ s₂
      ((Equiv.sumCongr { toEquiv := f, map_rel_iff' := hf }.toEquiv { toEquiv := g, map_rel_iff' := hg }.toEquiv)
        (Sum.inl val✝))
      ((Equiv.sumCongr { toEquiv := f, map_rel_iff' := hf }.toEquiv { toEquiv := g, map_rel_iff' := hg }.toEquiv) b) ↔
    Sum.Lex r₁ r₂ (Sum.inl val✝) b

Next tactic:
cases b