l3lab/ntp-mathlib huggingface dataset:
/-- `Subtype.impEmbedding` as an order embedding. -/
@[simps!]
def _root_.Subtype.orderEmbedding {p q : α → Prop} (h : ∀ a, p a → q a) :
    {x // p x} ↪o {x // q x} :=
  { Subtype.impEmbedding _ _ h with
    map_rel_iff' := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α
inst✝³ : Preorder β
inst✝² : Preorder γ
inst✝¹ : Preorder δ
ι : Type u_6
π : ι → Type u_7
inst✝ : (i : ι) → Preorder (π i)
p q : α → Prop
h : ∀ (a : α), p a → q a
src✝ : { x // p x } ↪ { x // q x } := Subtype.impEmbedding (fun x => p x) (fun x => q x) h
⊢ ∀ {a b : { x // p x }},
    { toFun := src✝.toFun, inj' := (_ : Function.Injective src✝.toFun) } a ≤
        { toFun := src✝.toFun, inj' := (_ : Function.Injective src✝.toFun) } b ↔
      a ≤ b

Next tactic:
aesop
/-- Embeddings of partial orders that preserve `<` also preserve `≤`. -/
def RelEmbedding.orderEmbeddingOfLTEmbedding [PartialOrder α] [PartialOrder β]
    (f : ((· < ·) : α → α → Prop) ↪r ((· < ·) : β → β → Prop)) : α ↪o β :=
  { f with
    map_rel_iff' := by
      

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝¹ : PartialOrder α
inst✝ : PartialOrder β
f : (fun x x_1 => x < x_1) ↪r fun x x_1 => x < x_1
⊢ ∀ {a b : α}, f.toEmbedding a ≤ f.toEmbedding b ↔ a ≤ b

Next tactic:
intros
/-- Embeddings of partial orders that preserve `<` also preserve `≤`. -/
def RelEmbedding.orderEmbeddingOfLTEmbedding [PartialOrder α] [PartialOrder β]
    (f : ((· < ·) : α → α → Prop) ↪r ((· < ·) : β → β → Prop)) : α ↪o β :=
  { f with
    map_rel_iff' := by
      intros
      

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝¹ : PartialOrder α
inst✝ : PartialOrder β
f : (fun x x_1 => x < x_1) ↪r fun x x_1 => x < x_1
a✝ b✝ : α
⊢ f.toEmbedding a✝ ≤ f.toEmbedding b✝ ↔ a✝ ≤ b✝

Next tactic:
simp [le_iff_lt_or_eq, f.map_rel_iff, f.injective.eq_iff]
/-- `<` is preserved by order embeddings of preorders. -/
def ltEmbedding : ((· < ·) : α → α → Prop) ↪r ((· < ·) : β → β → Prop) :=
  { f with map_rel_iff' := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝¹ : Preorder α
inst✝ : Preorder β
f : α ↪o β
⊢ ∀ {a b : α}, f.toEmbedding a < f.toEmbedding b ↔ a < b

Next tactic:
intros
/-- `<` is preserved by order embeddings of preorders. -/
def ltEmbedding : ((· < ·) : α → α → Prop) ↪r ((· < ·) : β → β → Prop) :=
  { f with map_rel_iff' := by intros; 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝¹ : Preorder α
inst✝ : Preorder β
f : α ↪o β
a✝ b✝ : α
⊢ f.toEmbedding a✝ < f.toEmbedding b✝ ↔ a✝ < b✝

Next tactic:
simp [lt_iff_le_not_le, f.map_rel_iff]
instance : OrderIsoClass (α ≃o β) α β where
  coe f := f.toFun
  inv f := f.invFun
  left_inv f := f.left_inv
  right_inv f := f.right_inv
  coe_injective' f g h₁ h₂ := by
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝² : LE α
inst✝¹ : LE β
inst✝ : LE γ
f g : α ≃o β
h₁ : (fun f => f.toFun) f = (fun f => f.toFun) g
h₂ : (fun f => f.invFun) f = (fun f => f.invFun) g
⊢ f = g

Next tactic:
obtain ⟨⟨_, _⟩, _⟩ := f
instance : OrderIsoClass (α ≃o β) α β where
  coe f := f.toFun
  inv f := f.invFun
  left_inv f := f.left_inv
  right_inv f := f.right_inv
  coe_injective' f g h₁ h₂ := by
    obtain ⟨⟨_, _⟩, _⟩ := f
    

Proof state:
case mk.mk
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝² : LE α
inst✝¹ : LE β
inst✝ : LE γ
g : α ≃o β
toFun✝ : α → β
invFun✝ : β → α
left_inv✝ : Function.LeftInverse invFun✝ toFun✝
right_inv✝ : Function.RightInverse invFun✝ toFun✝
map_rel_iff'✝ :
  ∀ {a b : α},
    { toFun := toFun✝, invFun := invFun✝, left_inv := left_inv✝, right_inv := right_inv✝ } a ≤
        { toFun := toFun✝, invFun := invFun✝, left_inv := left_inv✝, right_inv := right_inv✝ } b ↔
      a ≤ b
h₁ :
  (fun f => f.toFun)
      { toEquiv := { toFun := toFun✝, invFun := invFun✝, left_inv := left_inv✝, right_inv := right_inv✝ },
        map_rel_iff' := map_rel_iff'✝ } =
    (fun f => f.toFun) g
h₂ :
  (fun f => f.invFun)
      { toEquiv := { toFun := toFun✝, invFun := invFun✝, left_inv := left_inv✝, right_inv := right_inv✝ },
        map_rel_iff' := map_rel_iff'✝ } =
    (fun f => f.invFun) g
⊢ { toEquiv := { toFun := toFun✝, invFun := invFun✝, left_inv := left_inv✝, right_inv := right_inv✝ },
      map_rel_iff' := map_rel_iff'✝ } =
    g

Next tactic:
obtain ⟨⟨_, _⟩, _⟩ := g
instance : OrderIsoClass (α ≃o β) α β where
  coe f := f.toFun
  inv f := f.invFun
  left_inv f := f.left_inv
  right_inv f := f.right_inv
  coe_injective' f g h₁ h₂ := by
    obtain ⟨⟨_, _⟩, _⟩ := f
    obtain ⟨⟨_, _⟩, _⟩ := g
    

Proof state:
case mk.mk.mk.mk
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝² : LE α
inst✝¹ : LE β
inst✝ : LE γ
toFun✝¹ : α → β
invFun✝¹ : β → α
left_inv✝¹ : Function.LeftInverse invFun✝¹ toFun✝¹
right_inv✝¹ : Function.RightInverse invFun✝¹ toFun✝¹
map_rel_iff'✝¹ :
  ∀ {a b : α},
    { toFun := toFun✝¹, invFun := invFun✝¹, left_inv := left_inv✝¹, right_inv := right_inv✝¹ } a ≤
        { toFun := toFun✝¹, invFun := invFun✝¹, left_inv := left_inv✝¹, right_inv := right_inv✝¹ } b ↔
      a ≤ b
toFun✝ : α → β
invFun✝ : β → α
left_inv✝ : Function.LeftInverse invFun✝ toFun✝
right_inv✝ : Function.RightInverse invFun✝ toFun✝
map_rel_iff'✝ :
  ∀ {a b : α},
    { toFun := toFun✝, invFun := invFun✝, left_inv := left_inv✝, right_inv := right_inv✝ } a ≤
        { toFun := toFun✝, invFun := invFun✝, left_inv := left_inv✝, right_inv := right_inv✝ } b ↔
      a ≤ b
h₁ :
  (fun f => f.toFun)
      { toEquiv := { toFun := toFun✝¹, invFun := invFun✝¹, left_inv := left_inv✝¹, right_inv := right_inv✝¹ },
        map_rel_iff' := map_rel_iff'✝¹ } =
    (fun f => f.toFun)
      { toEquiv := { toFun := toFun✝, invFun := invFun✝, left_inv := left_inv✝, right_inv := right_inv✝ },
        map_rel_iff' := map_rel_iff'✝ }
h₂ :
  (fun f => f.invFun)
      { toEquiv := { toFun := toFun✝¹, invFun := invFun✝¹, left_inv := left_inv✝¹, right_inv := right_inv✝¹ },
        map_rel_iff' := map_rel_iff'✝¹ } =
    (fun f => f.invFun)
      { toEquiv := { toFun := toFun✝, invFun := invFun✝, left_inv := left_inv✝, right_inv := right_inv✝ },
        map_rel_iff' := map_rel_iff'✝ }
⊢ { toEquiv := { toFun := toFun✝¹, invFun := invFun✝¹, left_inv := left_inv✝¹, right_inv := right_inv✝¹ },
      map_rel_iff' := map_rel_iff'✝¹ } =
    { toEquiv := { toFun := toFun✝, invFun := invFun✝, left_inv := left_inv✝, right_inv := right_inv✝ },
      map_rel_iff' := map_rel_iff'✝ }

Next tactic:
congr
@[simp]
theorem symm_symm (e : α ≃o β) : e.symm.symm = e := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝² : LE α
inst✝¹ : LE β
inst✝ : LE γ
e : α ≃o β
⊢ symm (symm e) = e

Next tactic:
ext
@[simp]
theorem symm_symm (e : α ≃o β) : e.symm.symm = e := by
  ext
  

Proof state:
case h.h
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝² : LE α
inst✝¹ : LE β
inst✝ : LE γ
e : α ≃o β
x✝ : α
⊢ (symm (symm e)) x✝ = e x✝

Next tactic:
rfl
@[simp]
theorem refl_trans (e : α ≃o β) : (refl α).trans e = e := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝² : LE α
inst✝¹ : LE β
inst✝ : LE γ
e : α ≃o β
⊢ trans (refl α) e = e

Next tactic:
ext x
@[simp]
theorem refl_trans (e : α ≃o β) : (refl α).trans e = e := by
  ext x
  

Proof state:
case h.h
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝² : LE α
inst✝¹ : LE β
inst✝ : LE γ
e : α ≃o β
x : α
⊢ (trans (refl α) e) x = e x

Next tactic:
rfl
@[simp]
theorem trans_refl (e : α ≃o β) : e.trans (refl β) = e := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝² : LE α
inst✝¹ : LE β
inst✝ : LE γ
e : α ≃o β
⊢ trans e (refl β) = e

Next tactic:
ext x
@[simp]
theorem trans_refl (e : α ≃o β) : e.trans (refl β) = e := by
  ext x
  

Proof state:
case h.h
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝² : LE α
inst✝¹ : LE β
inst✝ : LE γ
e : α ≃o β
x : α
⊢ (trans e (refl β)) x = e x

Next tactic:
rfl
/-- Converts a `RelIso (<) (<)` into an `OrderIso`. -/
def ofRelIsoLT {α β} [PartialOrder α] [PartialOrder β]
    (e : ((· < ·) : α → α → Prop) ≃r ((· < ·) : β → β → Prop)) : α ≃o β :=
  ⟨e.toEquiv, by 

Proof state:
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type ?u.89639
β : Type ?u.89642
inst✝¹ : PartialOrder α
inst✝ : PartialOrder β
e : (fun x x_1 => x < x_1) ≃r fun x x_1 => x < x_1
⊢ ∀ {a b : α}, e.toEquiv a ≤ e.toEquiv b ↔ a ≤ b

Next tactic:
simp [le_iff_eq_or_lt, e.map_rel_iff, e.injective.eq_iff]
@[simp]
theorem ofRelIsoLT_toRelIsoLT {α β} [PartialOrder α] [PartialOrder β] (e : α ≃o β) :
    ofRelIsoLT (toRelIsoLT e) = e := by
  

Proof state:
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type u_6
β : Type u_7
inst✝¹ : PartialOrder α
inst✝ : PartialOrder β
e : α ≃o β
⊢ ofRelIsoLT (toRelIsoLT e) = e

Next tactic:
ext
@[simp]
theorem ofRelIsoLT_toRelIsoLT {α β} [PartialOrder α] [PartialOrder β] (e : α ≃o β) :
    ofRelIsoLT (toRelIsoLT e) = e := by
  ext
  

Proof state:
case h.h
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type u_6
β : Type u_7
inst✝¹ : PartialOrder α
inst✝ : PartialOrder β
e : α ≃o β
x✝ : α
⊢ (ofRelIsoLT (toRelIsoLT e)) x✝ = e x✝

Next tactic:
simp
@[simp]
theorem toRelIsoLT_ofRelIsoLT {α β} [PartialOrder α] [PartialOrder β]
    (e : ((· < ·) : α → α → Prop) ≃r ((· < ·) : β → β → Prop)) : toRelIsoLT (ofRelIsoLT e) = e := by
  

Proof state:
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type u_6
β : Type u_7
inst✝¹ : PartialOrder α
inst✝ : PartialOrder β
e : (fun x x_1 => x < x_1) ≃r fun x x_1 => x < x_1
⊢ toRelIsoLT (ofRelIsoLT e) = e

Next tactic:
ext
@[simp]
theorem toRelIsoLT_ofRelIsoLT {α β} [PartialOrder α] [PartialOrder β]
    (e : ((· < ·) : α → α → Prop) ≃r ((· < ·) : β → β → Prop)) : toRelIsoLT (ofRelIsoLT e) = e := by
  ext
  

Proof state:
case h
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type u_6
β : Type u_7
inst✝¹ : PartialOrder α
inst✝ : PartialOrder β
e : (fun x x_1 => x < x_1) ≃r fun x x_1 => x < x_1
x✝ : α
⊢ (toRelIsoLT (ofRelIsoLT e)) x✝ = e x✝

Next tactic:
simp
/-- To show that `f : α → β`, `g : β → α` make up an order isomorphism of linear orders,
    it suffices to prove `cmp a (g b) = cmp (f a) b`. -/
def ofCmpEqCmp {α β} [LinearOrder α] [LinearOrder β] (f : α → β) (g : β → α)
    (h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b) : α ≃o β :=
  have gf : ∀ a : α, a = g (f a) := by
    

Proof state:
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type ?u.93189
β : Type ?u.93192
inst✝¹ : LinearOrder α
inst✝ : LinearOrder β
f : α → β
g : β → α
h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b
⊢ ∀ (a : α), a = g (f a)

Next tactic:
intro
/-- To show that `f : α → β`, `g : β → α` make up an order isomorphism of linear orders,
    it suffices to prove `cmp a (g b) = cmp (f a) b`. -/
def ofCmpEqCmp {α β} [LinearOrder α] [LinearOrder β] (f : α → β) (g : β → α)
    (h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b) : α ≃o β :=
  have gf : ∀ a : α, a = g (f a) := by
    intro
    

Proof state:
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type ?u.93189
β : Type ?u.93192
inst✝¹ : LinearOrder α
inst✝ : LinearOrder β
f : α → β
g : β → α
h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b
a✝ : α
⊢ a✝ = g (f a✝)

Next tactic:
rw [← cmp_eq_eq_iff, h, cmp_self_eq_eq]
/-- To show that `f : α → β`, `g : β → α` make up an order isomorphism of linear orders,
    it suffices to prove `cmp a (g b) = cmp (f a) b`. -/
def ofCmpEqCmp {α β} [LinearOrder α] [LinearOrder β] (f : α → β) (g : β → α)
    (h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b) : α ≃o β :=
  have gf : ∀ a : α, a = g (f a) := by
    intro
    rw [← cmp_eq_eq_iff, h, cmp_self_eq_eq]
  { toFun := f, invFun := g, left_inv := fun a => (gf a).symm,
    right_inv := by
      

Proof state:
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type ?u.93189
β : Type ?u.93192
inst✝¹ : LinearOrder α
inst✝ : LinearOrder β
f : α → β
g : β → α
h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b
gf : ∀ (a : α), a = g (f a)
⊢ Function.RightInverse g f

Next tactic:
intro
/-- To show that `f : α → β`, `g : β → α` make up an order isomorphism of linear orders,
    it suffices to prove `cmp a (g b) = cmp (f a) b`. -/
def ofCmpEqCmp {α β} [LinearOrder α] [LinearOrder β] (f : α → β) (g : β → α)
    (h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b) : α ≃o β :=
  have gf : ∀ a : α, a = g (f a) := by
    intro
    rw [← cmp_eq_eq_iff, h, cmp_self_eq_eq]
  { toFun := f, invFun := g, left_inv := fun a => (gf a).symm,
    right_inv := by
      intro
      

Proof state:
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type ?u.93189
β : Type ?u.93192
inst✝¹ : LinearOrder α
inst✝ : LinearOrder β
f : α → β
g : β → α
h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b
gf : ∀ (a : α), a = g (f a)
x✝ : β
⊢ f (g x✝) = x✝

Next tactic:
rw [← cmp_eq_eq_iff, ← h, cmp_self_eq_eq]
/-- To show that `f : α → β`, `g : β → α` make up an order isomorphism of linear orders,
    it suffices to prove `cmp a (g b) = cmp (f a) b`. -/
def ofCmpEqCmp {α β} [LinearOrder α] [LinearOrder β] (f : α → β) (g : β → α)
    (h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b) : α ≃o β :=
  have gf : ∀ a : α, a = g (f a) := by
    intro
    rw [← cmp_eq_eq_iff, h, cmp_self_eq_eq]
  { toFun := f, invFun := g, left_inv := fun a => (gf a).symm,
    right_inv := by
      intro
      rw [← cmp_eq_eq_iff, ← h, cmp_self_eq_eq],
    map_rel_iff' := by
      

Proof state:
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type ?u.93189
β : Type ?u.93192
inst✝¹ : LinearOrder α
inst✝ : LinearOrder β
f : α → β
g : β → α
h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b
gf : ∀ (a : α), a = g (f a)
⊢ ∀ {a b : α},
    { toFun := f, invFun := g, left_inv := (_ : ∀ (a : α), g (f a) = a), right_inv := (_ : ∀ (x : β), f (g x) = x) } a ≤
        { toFun := f, invFun := g, left_inv := (_ : ∀ (a : α), g (f a) = a), right_inv := (_ : ∀ (x : β), f (g x) = x) }
          b ↔
      a ≤ b

Next tactic:
intros a b
/-- To show that `f : α → β`, `g : β → α` make up an order isomorphism of linear orders,
    it suffices to prove `cmp a (g b) = cmp (f a) b`. -/
def ofCmpEqCmp {α β} [LinearOrder α] [LinearOrder β] (f : α → β) (g : β → α)
    (h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b) : α ≃o β :=
  have gf : ∀ a : α, a = g (f a) := by
    intro
    rw [← cmp_eq_eq_iff, h, cmp_self_eq_eq]
  { toFun := f, invFun := g, left_inv := fun a => (gf a).symm,
    right_inv := by
      intro
      rw [← cmp_eq_eq_iff, ← h, cmp_self_eq_eq],
    map_rel_iff' := by
      intros a b
      

Proof state:
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type ?u.93189
β : Type ?u.93192
inst✝¹ : LinearOrder α
inst✝ : LinearOrder β
f : α → β
g : β → α
h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b
gf : ∀ (a : α), a = g (f a)
a b : α
⊢ { toFun := f, invFun := g, left_inv := (_ : ∀ (a : α), g (f a) = a), right_inv := (_ : ∀ (x : β), f (g x) = x) } a ≤
      { toFun := f, invFun := g, left_inv := (_ : ∀ (a : α), g (f a) = a), right_inv := (_ : ∀ (x : β), f (g x) = x) }
        b ↔
    a ≤ b

Next tactic:
apply le_iff_le_of_cmp_eq_cmp
/-- To show that `f : α → β`, `g : β → α` make up an order isomorphism of linear orders,
    it suffices to prove `cmp a (g b) = cmp (f a) b`. -/
def ofCmpEqCmp {α β} [LinearOrder α] [LinearOrder β] (f : α → β) (g : β → α)
    (h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b) : α ≃o β :=
  have gf : ∀ a : α, a = g (f a) := by
    intro
    rw [← cmp_eq_eq_iff, h, cmp_self_eq_eq]
  { toFun := f, invFun := g, left_inv := fun a => (gf a).symm,
    right_inv := by
      intro
      rw [← cmp_eq_eq_iff, ← h, cmp_self_eq_eq],
    map_rel_iff' := by
      intros a b
      apply le_iff_le_of_cmp_eq_cmp
      

Proof state:
case h
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type ?u.93189
β : Type ?u.93192
inst✝¹ : LinearOrder α
inst✝ : LinearOrder β
f : α → β
g : β → α
h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b
gf : ∀ (a : α), a = g (f a)
a b : α
⊢ cmp
      ({ toFun := f, invFun := g, left_inv := (_ : ∀ (a : α), g (f a) = a), right_inv := (_ : ∀ (x : β), f (g x) = x) }
        a)
      ({ toFun := f, invFun := g, left_inv := (_ : ∀ (a : α), g (f a) = a), right_inv := (_ : ∀ (x : β), f (g x) = x) }
        b) =
    cmp a b

Next tactic:
convert (h a (f b)).symm
/-- To show that `f : α → β`, `g : β → α` make up an order isomorphism of linear orders,
    it suffices to prove `cmp a (g b) = cmp (f a) b`. -/
def ofCmpEqCmp {α β} [LinearOrder α] [LinearOrder β] (f : α → β) (g : β → α)
    (h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b) : α ≃o β :=
  have gf : ∀ a : α, a = g (f a) := by
    intro
    rw [← cmp_eq_eq_iff, h, cmp_self_eq_eq]
  { toFun := f, invFun := g, left_inv := fun a => (gf a).symm,
    right_inv := by
      intro
      rw [← cmp_eq_eq_iff, ← h, cmp_self_eq_eq],
    map_rel_iff' := by
      intros a b
      apply le_iff_le_of_cmp_eq_cmp
      convert (h a (f b)).symm
      

Proof state:
case h.e'_3.h.e'_5
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type ?u.93189
β : Type ?u.93192
inst✝¹ : LinearOrder α
inst✝ : LinearOrder β
f : α → β
g : β → α
h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b
gf : ∀ (a : α), a = g (f a)
a b : α
⊢ b = g (f b)

Next tactic:
apply gf
/-- To show that `f : α →o β` and `g : β →o α` make up an order isomorphism it is enough to show
    that `g` is the inverse of `f`-/
def ofHomInv {F G : Type*} [OrderHomClass F α β] [OrderHomClass G β α] (f : F) (g : G)
    (h₁ : (f : α →o β).comp (g : β →o α) = OrderHom.id)
    (h₂ : (g : β →o α).comp (f : α →o β) = OrderHom.id) :
    α ≃o β where
  toFun := f
  invFun := g
  left_inv := FunLike.congr_fun h₂
  right_inv := FunLike.congr_fun h₁
  map_rel_iff' := @fun a b =>
    ⟨fun h => by
      

Proof state:
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α
inst✝³ : Preorder β
inst✝² : Preorder γ
F : Type u_6
G : Type u_7
inst✝¹ : OrderHomClass F α β
inst✝ : OrderHomClass G β α
f : F
g : G
h₁ : OrderHom.comp ↑f ↑g = OrderHom.id
h₂ : OrderHom.comp ↑g ↑f = OrderHom.id
a b : α
h :
  { toFun := ⇑f, invFun := ⇑g, left_inv := (_ : ∀ (x : α), (OrderHom.comp ↑g ↑f) x = OrderHom.id x),
        right_inv := (_ : ∀ (x : β), (OrderHom.comp ↑f ↑g) x = OrderHom.id x) }
      a ≤
    { toFun := ⇑f, invFun := ⇑g, left_inv := (_ : ∀ (x : α), (OrderHom.comp ↑g ↑f) x = OrderHom.id x),
        right_inv := (_ : ∀ (x : β), (OrderHom.comp ↑f ↑g) x = OrderHom.id x) }
      b
⊢ a ≤ b

Next tactic:
replace h := map_rel g h
/-- To show that `f : α →o β` and `g : β →o α` make up an order isomorphism it is enough to show
    that `g` is the inverse of `f`-/
def ofHomInv {F G : Type*} [OrderHomClass F α β] [OrderHomClass G β α] (f : F) (g : G)
    (h₁ : (f : α →o β).comp (g : β →o α) = OrderHom.id)
    (h₂ : (g : β →o α).comp (f : α →o β) = OrderHom.id) :
    α ≃o β where
  toFun := f
  invFun := g
  left_inv := FunLike.congr_fun h₂
  right_inv := FunLike.congr_fun h₁
  map_rel_iff' := @fun a b =>
    ⟨fun h => by
      replace h := map_rel g h
      

Proof state:
F✝ : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α
inst✝³ : Preorder β
inst✝² : Preorder γ
F : Type u_6
G : Type u_7
inst✝¹ : OrderHomClass F α β
inst✝ : OrderHomClass G β α
f : F
g : G
h₁ : OrderHom.comp ↑f ↑g = OrderHom.id
h₂ : OrderHom.comp ↑g ↑f = OrderHom.id
a b : α
h :
  g
      ({ toFun := ⇑f, invFun := ⇑g, left_inv := (_ : ∀ (x : α), (OrderHom.comp ↑g ↑f) x = OrderHom.id x),
          right_inv := (_ : ∀ (x : β), (OrderHom.comp ↑f ↑g) x = OrderHom.id x) }
        a) ≤
    g
      ({ toFun := ⇑f, invFun := ⇑g, left_inv := (_ : ∀ (x : α), (OrderHom.comp ↑g ↑f) x = OrderHom.id x),
          right_inv := (_ : ∀ (x : β), (OrderHom.comp ↑f ↑g) x = OrderHom.id x) }
        b)
⊢ a ≤ b

Next tactic:
rwa [Equiv.coe_fn_mk, show g (f a) = (g : β →o α).comp (f : α →o β) a from rfl,
        show g (f b) = (g : β →o α).comp (f : α →o β) b from rfl, h₂] at h
/-- Order isomorphism between `α → β` and `β`, where `α` has a unique element. -/
@[simps! toEquiv apply]
def funUnique (α β : Type*) [Unique α] [Preorder β] : (α → β) ≃o β where
  toEquiv := Equiv.funUnique α β
  map_rel_iff' := by 

Proof state:
F : Type u_1
α✝ : Type u_2
β✝ : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁴ : Preorder α✝
inst✝³ : Preorder β✝
inst✝² : Preorder γ
α : Type u_6
β : Type u_7
inst✝¹ : Unique α
inst✝ : Preorder β
⊢ ∀ {a b : α → β}, (Equiv.funUnique α β) a ≤ (Equiv.funUnique α β) b ↔ a ≤ b

Next tactic:
simp [Pi.le_def, Unique.forall_iff]
/-- If `e` is an equivalence with monotone forward and inverse maps, then `e` is an
order isomorphism. -/
def toOrderIso (e : α ≃ β) (h₁ : Monotone e) (h₂ : Monotone e.symm) : α ≃o β :=
  ⟨e, ⟨fun h => by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝¹ : Preorder α
inst✝ : Preorder β
e : α ≃ β
h₁ : Monotone ⇑e
h₂ : Monotone ⇑e.symm
a✝ b✝ : α
h : e a✝ ≤ e b✝
⊢ a✝ ≤ b✝

Next tactic:
simpa only [e.symm_apply_apply] using h₂ h
theorem OrderIso.map_bot' [LE α] [PartialOrder β] (f : α ≃o β) {x : α} {y : β} (hx : ∀ x', x ≤ x')
    (hy : ∀ y', y ≤ y') : f x = y := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝¹ : LE α
inst✝ : PartialOrder β
f : α ≃o β
x : α
y : β
hx : ∀ (x' : α), x ≤ x'
hy : ∀ (y' : β), y ≤ y'
⊢ f x = y

Next tactic:
refine' le_antisymm _ (hy _)
theorem OrderIso.map_bot' [LE α] [PartialOrder β] (f : α ≃o β) {x : α} {y : β} (hx : ∀ x', x ≤ x')
    (hy : ∀ y', y ≤ y') : f x = y := by
  refine' le_antisymm _ (hy _)
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝¹ : LE α
inst✝ : PartialOrder β
f : α ≃o β
x : α
y : β
hx : ∀ (x' : α), x ≤ x'
hy : ∀ (y' : β), y ≤ y'
⊢ f x ≤ y

Next tactic:
rw [← f.apply_symm_apply y, f.map_rel_iff]
theorem OrderIso.map_bot' [LE α] [PartialOrder β] (f : α ≃o β) {x : α} {y : β} (hx : ∀ x', x ≤ x')
    (hy : ∀ y', y ≤ y') : f x = y := by
  refine' le_antisymm _ (hy _)
  rw [← f.apply_symm_apply y, f.map_rel_iff]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝¹ : LE α
inst✝ : PartialOrder β
f : α ≃o β
x : α
y : β
hx : ∀ (x' : α), x ≤ x'
hy : ∀ (y' : β), y ≤ y'
⊢ x ≤ (symm f) y

Next tactic:
apply hx
theorem OrderIso.map_inf [SemilatticeInf α] [SemilatticeInf β] (f : α ≃o β) (x y : α) :
    f (x ⊓ y) = f x ⊓ f y := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝¹ : SemilatticeInf α
inst✝ : SemilatticeInf β
f : α ≃o β
x y : α
⊢ f (x ⊓ y) = f x ⊓ f y

Next tactic:
refine' (f.toOrderEmbedding.map_inf_le x y).antisymm _
theorem OrderIso.map_inf [SemilatticeInf α] [SemilatticeInf β] (f : α ≃o β) (x y : α) :
    f (x ⊓ y) = f x ⊓ f y := by
  refine' (f.toOrderEmbedding.map_inf_le x y).antisymm _
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝¹ : SemilatticeInf α
inst✝ : SemilatticeInf β
f : α ≃o β
x y : α
⊢ (toOrderEmbedding f) x ⊓ (toOrderEmbedding f) y ≤ (toOrderEmbedding f) (x ⊓ y)

Next tactic:
apply f.symm.le_iff_le.1