l3lab/ntp-mathlib huggingface dataset:
/-- Let `K` a subfield of `ℂ` and let `ψ : K →+* ℂ` a ring homomorphism. Assume that `ψ` is uniform
continuous, then `ψ` is either the inclusion map or the composition of the inclusion map with the
complex conjugation. -/
theorem Complex.uniformContinuous_ringHom_eq_id_or_conj (K : Subfield ℂ) {ψ : K →+* ℂ}
    (hc : UniformContinuous ψ) : ψ.toFun = K.subtype ∨ ψ.toFun = conj ∘ K.subtype := by
  letI : TopologicalDivisionRing ℂ := TopologicalDivisionRing.mk
  letI : TopologicalRing K.topologicalClosure :=
    Subring.instTopologicalRing K.topologicalClosure.toSubring
  set ι : K → K.topologicalClosure := ⇑(Subfield.inclusion K.le_topologicalClosure)
  have ui : UniformInducing ι :=
    ⟨by
      erw [uniformity_subtype, uniformity_subtype, Filter.comap_comap]
      congr ⟩
  let di := ui.denseInducing (?_ : DenseRange ι)
  · -- extψ : closure(K) →+* ℂ is the extension of ψ : K →+* ℂ
    let extψ := DenseInducing.extendRingHom ui di.dense hc
    haveI hψ := (uniformContinuous_uniformly_extend ui di.dense hc).continuous
    cases' Complex.subfield_eq_of_closed (Subfield.isClosed_topologicalClosure K) with h h
    · left
      let j := RingEquiv.subfieldCongr h
      -- ψ₁ is the continuous ring hom `ℝ →+* ℂ` constructed from `j : closure (K) ≃+* ℝ`
      -- and `extψ : closure (K) →+* ℂ`
      let ψ₁ := RingHom.comp extψ (RingHom.comp j.symm.toRingHom ofReal.rangeRestrict)
      -- porting note: was `by continuity!` and was used inline
      have hψ₁ : Continuous ψ₁ := by
        simpa only [RingHom.coe_comp] using hψ.comp ((continuous_algebraMap ℝ ℂ).subtype_mk _)
      ext1 x
      rsuffices ⟨r, hr⟩ : ∃ r : ℝ, ofReal.rangeRestrict r = j (ι x)
      · have :=
          RingHom.congr_fun (ringHom_eq_ofReal_of_continuous hψ₁) r
        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
        erw [RingHom.comp_apply, RingHom.comp_apply, hr, RingEquiv.toRingHom_eq_coe] at this
        convert this using 1
        · 

Proof state:
case h.e'_2
K : Subfield ℂ
ψ : ↥K →+* ℂ
hc : UniformContinuous ⇑ψ
this✝¹ : TopologicalDivisionRing ℂ := TopologicalDivisionRing.mk
this✝ : TopologicalRing ↥(Subfield.topologicalClosure K) :=
  Subring.instTopologicalRing (Subfield.topologicalClosure K).toSubring
ι : ↥K → ↥(Subfield.topologicalClosure K) := ⇑(Subfield.inclusion (_ : K ≤ Subfield.topologicalClosure K))
ui : UniformInducing ι
di : DenseInducing ι := UniformInducing.denseInducing ui ?refine_1
extψ : ↥(Subfield.topologicalClosure K) →+* ℂ := DenseInducing.extendRingHom ui (_ : DenseRange ι) hc
hψ : Continuous (DenseInducing.extend (_ : DenseInducing ι) ⇑ψ)
h : Subfield.topologicalClosure K = RingHom.fieldRange ofReal
j : ↥(Subfield.topologicalClosure K) ≃+* ↥(RingHom.fieldRange ofReal) := RingEquiv.subfieldCongr h
ψ₁ : ℝ →+* ℂ := RingHom.comp extψ (RingHom.comp (RingEquiv.toRingHom (RingEquiv.symm j)) (RingHom.rangeRestrict ofReal))
hψ₁ : Continuous ⇑ψ₁
x : ↥K
r : ℝ
hr : (RingHom.rangeRestrict ofReal) r = j (ι x)
this : extψ (↑(RingEquiv.symm j) (j (ι x))) = ofReal r
⊢ OneHom.toFun (↑↑ψ) x = extψ (↑(RingEquiv.symm j) (j (ι x)))

Next tactic:
exact (DenseInducing.extend_eq di hc.continuous _).symm
/-- Let `K` a subfield of `ℂ` and let `ψ : K →+* ℂ` a ring homomorphism. Assume that `ψ` is uniform
continuous, then `ψ` is either the inclusion map or the composition of the inclusion map with the
complex conjugation. -/
theorem Complex.uniformContinuous_ringHom_eq_id_or_conj (K : Subfield ℂ) {ψ : K →+* ℂ}
    (hc : UniformContinuous ψ) : ψ.toFun = K.subtype ∨ ψ.toFun = conj ∘ K.subtype := by
  letI : TopologicalDivisionRing ℂ := TopologicalDivisionRing.mk
  letI : TopologicalRing K.topologicalClosure :=
    Subring.instTopologicalRing K.topologicalClosure.toSubring
  set ι : K → K.topologicalClosure := ⇑(Subfield.inclusion K.le_topologicalClosure)
  have ui : UniformInducing ι :=
    ⟨by
      erw [uniformity_subtype, uniformity_subtype, Filter.comap_comap]
      congr ⟩
  let di := ui.denseInducing (?_ : DenseRange ι)
  · -- extψ : closure(K) →+* ℂ is the extension of ψ : K →+* ℂ
    let extψ := DenseInducing.extendRingHom ui di.dense hc
    haveI hψ := (uniformContinuous_uniformly_extend ui di.dense hc).continuous
    cases' Complex.subfield_eq_of_closed (Subfield.isClosed_topologicalClosure K) with h h
    · left
      let j := RingEquiv.subfieldCongr h
      -- ψ₁ is the continuous ring hom `ℝ →+* ℂ` constructed from `j : closure (K) ≃+* ℝ`
      -- and `extψ : closure (K) →+* ℂ`
      let ψ₁ := RingHom.comp extψ (RingHom.comp j.symm.toRingHom ofReal.rangeRestrict)
      -- porting note: was `by continuity!` and was used inline
      have hψ₁ : Continuous ψ₁ := by
        simpa only [RingHom.coe_comp] using hψ.comp ((continuous_algebraMap ℝ ℂ).subtype_mk _)
      ext1 x
      rsuffices ⟨r, hr⟩ : ∃ r : ℝ, ofReal.rangeRestrict r = j (ι x)
      · have :=
          RingHom.congr_fun (ringHom_eq_ofReal_of_continuous hψ₁) r
        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
        erw [RingHom.comp_apply, RingHom.comp_apply, hr, RingEquiv.toRingHom_eq_coe] at this
        convert this using 1
        · exact (DenseInducing.extend_eq di hc.continuous _).symm
        · 

Proof state:
case h.e'_3
K : Subfield ℂ
ψ : ↥K →+* ℂ
hc : UniformContinuous ⇑ψ
this✝¹ : TopologicalDivisionRing ℂ := TopologicalDivisionRing.mk
this✝ : TopologicalRing ↥(Subfield.topologicalClosure K) :=
  Subring.instTopologicalRing (Subfield.topologicalClosure K).toSubring
ι : ↥K → ↥(Subfield.topologicalClosure K) := ⇑(Subfield.inclusion (_ : K ≤ Subfield.topologicalClosure K))
ui : UniformInducing ι
di : DenseInducing ι := UniformInducing.denseInducing ui ?refine_1
extψ : ↥(Subfield.topologicalClosure K) →+* ℂ := DenseInducing.extendRingHom ui (_ : DenseRange ι) hc
hψ : Continuous (DenseInducing.extend (_ : DenseInducing ι) ⇑ψ)
h : Subfield.topologicalClosure K = RingHom.fieldRange ofReal
j : ↥(Subfield.topologicalClosure K) ≃+* ↥(RingHom.fieldRange ofReal) := RingEquiv.subfieldCongr h
ψ₁ : ℝ →+* ℂ := RingHom.comp extψ (RingHom.comp (RingEquiv.toRingHom (RingEquiv.symm j)) (RingHom.rangeRestrict ofReal))
hψ₁ : Continuous ⇑ψ₁
x : ↥K
r : ℝ
hr : (RingHom.rangeRestrict ofReal) r = j (ι x)
this : extψ (↑(RingEquiv.symm j) (j (ι x))) = ofReal r
⊢ (Subfield.subtype K) x = ofReal r

Next tactic:
rw [← ofReal.coe_rangeRestrict, hr]
/-- Let `K` a subfield of `ℂ` and let `ψ : K →+* ℂ` a ring homomorphism. Assume that `ψ` is uniform
continuous, then `ψ` is either the inclusion map or the composition of the inclusion map with the
complex conjugation. -/
theorem Complex.uniformContinuous_ringHom_eq_id_or_conj (K : Subfield ℂ) {ψ : K →+* ℂ}
    (hc : UniformContinuous ψ) : ψ.toFun = K.subtype ∨ ψ.toFun = conj ∘ K.subtype := by
  letI : TopologicalDivisionRing ℂ := TopologicalDivisionRing.mk
  letI : TopologicalRing K.topologicalClosure :=
    Subring.instTopologicalRing K.topologicalClosure.toSubring
  set ι : K → K.topologicalClosure := ⇑(Subfield.inclusion K.le_topologicalClosure)
  have ui : UniformInducing ι :=
    ⟨by
      erw [uniformity_subtype, uniformity_subtype, Filter.comap_comap]
      congr ⟩
  let di := ui.denseInducing (?_ : DenseRange ι)
  · -- extψ : closure(K) →+* ℂ is the extension of ψ : K →+* ℂ
    let extψ := DenseInducing.extendRingHom ui di.dense hc
    haveI hψ := (uniformContinuous_uniformly_extend ui di.dense hc).continuous
    cases' Complex.subfield_eq_of_closed (Subfield.isClosed_topologicalClosure K) with h h
    · left
      let j := RingEquiv.subfieldCongr h
      -- ψ₁ is the continuous ring hom `ℝ →+* ℂ` constructed from `j : closure (K) ≃+* ℝ`
      -- and `extψ : closure (K) →+* ℂ`
      let ψ₁ := RingHom.comp extψ (RingHom.comp j.symm.toRingHom ofReal.rangeRestrict)
      -- porting note: was `by continuity!` and was used inline
      have hψ₁ : Continuous ψ₁ := by
        simpa only [RingHom.coe_comp] using hψ.comp ((continuous_algebraMap ℝ ℂ).subtype_mk _)
      ext1 x
      rsuffices ⟨r, hr⟩ : ∃ r : ℝ, ofReal.rangeRestrict r = j (ι x)
      · have :=
          RingHom.congr_fun (ringHom_eq_ofReal_of_continuous hψ₁) r
        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
        erw [RingHom.comp_apply, RingHom.comp_apply, hr, RingEquiv.toRingHom_eq_coe] at this
        convert this using 1
        · exact (DenseInducing.extend_eq di hc.continuous _).symm
        · rw [← ofReal.coe_rangeRestrict, hr]
          

Proof state:
case h.e'_3
K : Subfield ℂ
ψ : ↥K →+* ℂ
hc : UniformContinuous ⇑ψ
this✝¹ : TopologicalDivisionRing ℂ := TopologicalDivisionRing.mk
this✝ : TopologicalRing ↥(Subfield.topologicalClosure K) :=
  Subring.instTopologicalRing (Subfield.topologicalClosure K).toSubring
ι : ↥K → ↥(Subfield.topologicalClosure K) := ⇑(Subfield.inclusion (_ : K ≤ Subfield.topologicalClosure K))
ui : UniformInducing ι
di : DenseInducing ι := UniformInducing.denseInducing ui ?refine_1
extψ : ↥(Subfield.topologicalClosure K) →+* ℂ := DenseInducing.extendRingHom ui (_ : DenseRange ι) hc
hψ : Continuous (DenseInducing.extend (_ : DenseInducing ι) ⇑ψ)
h : Subfield.topologicalClosure K = RingHom.fieldRange ofReal
j : ↥(Subfield.topologicalClosure K) ≃+* ↥(RingHom.fieldRange ofReal) := RingEquiv.subfieldCongr h
ψ₁ : ℝ →+* ℂ := RingHom.comp extψ (RingHom.comp (RingEquiv.toRingHom (RingEquiv.symm j)) (RingHom.rangeRestrict ofReal))
hψ₁ : Continuous ⇑ψ₁
x : ↥K
r : ℝ
hr : (RingHom.rangeRestrict ofReal) r = j (ι x)
this : extψ (↑(RingEquiv.symm j) (j (ι x))) = ofReal r
⊢ (Subfield.subtype K) x = ↑(j (ι x))

Next tactic:
rfl
/-- Let `K` a subfield of `ℂ` and let `ψ : K →+* ℂ` a ring homomorphism. Assume that `ψ` is uniform
continuous, then `ψ` is either the inclusion map or the composition of the inclusion map with the
complex conjugation. -/
theorem Complex.uniformContinuous_ringHom_eq_id_or_conj (K : Subfield ℂ) {ψ : K →+* ℂ}
    (hc : UniformContinuous ψ) : ψ.toFun = K.subtype ∨ ψ.toFun = conj ∘ K.subtype := by
  letI : TopologicalDivisionRing ℂ := TopologicalDivisionRing.mk
  letI : TopologicalRing K.topologicalClosure :=
    Subring.instTopologicalRing K.topologicalClosure.toSubring
  set ι : K → K.topologicalClosure := ⇑(Subfield.inclusion K.le_topologicalClosure)
  have ui : UniformInducing ι :=
    ⟨by
      erw [uniformity_subtype, uniformity_subtype, Filter.comap_comap]
      congr ⟩
  let di := ui.denseInducing (?_ : DenseRange ι)
  · -- extψ : closure(K) →+* ℂ is the extension of ψ : K →+* ℂ
    let extψ := DenseInducing.extendRingHom ui di.dense hc
    haveI hψ := (uniformContinuous_uniformly_extend ui di.dense hc).continuous
    cases' Complex.subfield_eq_of_closed (Subfield.isClosed_topologicalClosure K) with h h
    · left
      let j := RingEquiv.subfieldCongr h
      -- ψ₁ is the continuous ring hom `ℝ →+* ℂ` constructed from `j : closure (K) ≃+* ℝ`
      -- and `extψ : closure (K) →+* ℂ`
      let ψ₁ := RingHom.comp extψ (RingHom.comp j.symm.toRingHom ofReal.rangeRestrict)
      -- porting note: was `by continuity!` and was used inline
      have hψ₁ : Continuous ψ₁ := by
        simpa only [RingHom.coe_comp] using hψ.comp ((continuous_algebraMap ℝ ℂ).subtype_mk _)
      ext1 x
      rsuffices ⟨r, hr⟩ : ∃ r : ℝ, ofReal.rangeRestrict r = j (ι x)
      · have :=
          RingHom.congr_fun (ringHom_eq_ofReal_of_continuous hψ₁) r
        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
        erw [RingHom.comp_apply, RingHom.comp_apply, hr, RingEquiv.toRingHom_eq_coe] at this
        convert this using 1
        · exact (DenseInducing.extend_eq di hc.continuous _).symm
        · rw [← ofReal.coe_rangeRestrict, hr]
          rfl
      

Proof state:
K : Subfield ℂ
ψ : ↥K →+* ℂ
hc : UniformContinuous ⇑ψ
this✝ : TopologicalDivisionRing ℂ := TopologicalDivisionRing.mk
this : TopologicalRing ↥(Subfield.topologicalClosure K) :=
  Subring.instTopologicalRing (Subfield.topologicalClosure K).toSubring
ι : ↥K → ↥(Subfield.topologicalClosure K) := ⇑(Subfield.inclusion (_ : K ≤ Subfield.topologicalClosure K))
ui : UniformInducing ι
di : DenseInducing ι := UniformInducing.denseInducing ui ?refine_1
extψ : ↥(Subfield.topologicalClosure K) →+* ℂ := DenseInducing.extendRingHom ui (_ : DenseRange ι) hc
hψ : Continuous (DenseInducing.extend (_ : DenseInducing ι) ⇑ψ)
h : Subfield.topologicalClosure K = RingHom.fieldRange ofReal
j : ↥(Subfield.topologicalClosure K) ≃+* ↥(RingHom.fieldRange ofReal) := RingEquiv.subfieldCongr h
ψ₁ : ℝ →+* ℂ := RingHom.comp extψ (RingHom.comp (RingEquiv.toRingHom (RingEquiv.symm j)) (RingHom.rangeRestrict ofReal))
hψ₁ : Continuous ⇑ψ₁
x : ↥K
⊢ ∃ r, (RingHom.rangeRestrict ofReal) r = j (ι x)

Next tactic:
obtain ⟨r, hr⟩ := SetLike.coe_mem (j (ι x))
instance : FunLike (α ≃. β) α fun _ => Option β :=
  { coe := toFun
    coe_injective' := by
      

Proof state:
α : Type u
β : Type v
γ : Type w
δ : Type x
⊢ Injective toFun

Next tactic:
rintro ⟨f₁, f₂, hf⟩ ⟨g₁, g₂, hg⟩ (rfl : f₁ = g₁)
instance : FunLike (α ≃. β) α fun _ => Option β :=
  { coe := toFun
    coe_injective' := by
      rintro ⟨f₁, f₂, hf⟩ ⟨g₁, g₂, hg⟩ (rfl : f₁ = g₁)
      

Proof state:
case mk.mk
α : Type u
β : Type v
γ : Type w
δ : Type x
f₁ : α → Option β
f₂ : β → Option α
hf : ∀ (a : α) (b : β), a ∈ f₂ b ↔ b ∈ f₁ a
g₂ : β → Option α
hg : ∀ (a : α) (b : β), a ∈ g₂ b ↔ b ∈ f₁ a
⊢ { toFun := f₁, invFun := f₂, inv := hf } = { toFun := f₁, invFun := g₂, inv := hg }

Next tactic:
congr with y x
instance : FunLike (α ≃. β) α fun _ => Option β :=
  { coe := toFun
    coe_injective' := by
      rintro ⟨f₁, f₂, hf⟩ ⟨g₁, g₂, hg⟩ (rfl : f₁ = g₁)
      congr with y x
      

Proof state:
case mk.mk.e_invFun.h.a
α : Type u
β : Type v
γ : Type w
δ : Type x
f₁ : α → Option β
f₂ : β → Option α
hf : ∀ (a : α) (b : β), a ∈ f₂ b ↔ b ∈ f₁ a
g₂ : β → Option α
hg : ∀ (a : α) (b : β), a ∈ g₂ b ↔ b ∈ f₁ a
y : β
x : α
⊢ x ∈ f₂ y ↔ x ∈ g₂ y

Next tactic:
simp only [hf, hg]
/-- Composition of partial equivalences `f : α ≃. β` and `g : β ≃. γ`. -/
@[trans]
protected def trans (f : α ≃. β) (g : β ≃. γ) :
    α ≃. γ where
  toFun a := (f a).bind g
  invFun a := (g.symm a).bind f.symm
  inv a b := by 

Proof state:
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
g : β ≃. γ
a : α
b : γ
⊢ a ∈ (fun a => Option.bind ((PEquiv.symm g) a) ⇑(PEquiv.symm f)) b ↔ b ∈ (fun a => Option.bind (f a) ⇑g) a

Next tactic:
simp_all [and_comm, eq_some_iff f, eq_some_iff g]
@[simp]
theorem symm_symm (f : α ≃. β) : f.symm.symm = f := by 

Proof state:
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
⊢ PEquiv.symm (PEquiv.symm f) = f

Next tactic:
cases f
@[simp]
theorem symm_symm (f : α ≃. β) : f.symm.symm = f := by cases f; 

Proof state:
case mk
α : Type u
β : Type v
γ : Type w
δ : Type x
toFun✝ : α → Option β
invFun✝ : β → Option α
inv✝ : ∀ (a : α) (b : β), a ∈ invFun✝ b ↔ b ∈ toFun✝ a
⊢ PEquiv.symm (PEquiv.symm { toFun := toFun✝, invFun := invFun✝, inv := inv✝ }) =
    { toFun := toFun✝, invFun := invFun✝, inv := inv✝ }

Next tactic:
rfl
theorem trans_eq_none (f : α ≃. β) (g : β ≃. γ) (a : α) :
    f.trans g a = none ↔ ∀ b c, b ∉ f a ∨ c ∉ g b := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
g : β ≃. γ
a : α
⊢ (PEquiv.trans f g) a = none ↔ ∀ (b : β) (c : γ), b ∉ f a ∨ c ∉ g b

Next tactic:
simp only [eq_none_iff_forall_not_mem, mem_trans, imp_iff_not_or.symm]
theorem trans_eq_none (f : α ≃. β) (g : β ≃. γ) (a : α) :
    f.trans g a = none ↔ ∀ b c, b ∉ f a ∨ c ∉ g b := by
  simp only [eq_none_iff_forall_not_mem, mem_trans, imp_iff_not_or.symm]
  

Proof state:
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
g : β ≃. γ
a : α
⊢ (∀ (a_1 : γ), ¬∃ b ∈ f a, a_1 ∈ g b) ↔ ∀ (b : β) (c : γ), b ∈ f a → c ∉ g b

Next tactic:
push_neg
theorem trans_eq_none (f : α ≃. β) (g : β ≃. γ) (a : α) :
    f.trans g a = none ↔ ∀ b c, b ∉ f a ∨ c ∉ g b := by
  simp only [eq_none_iff_forall_not_mem, mem_trans, imp_iff_not_or.symm]
  push_neg
  

Proof state:
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
g : β ≃. γ
a : α
⊢ (∀ (a_1 : γ), ∀ b ∈ f a, a_1 ∉ g b) ↔ ∀ (b : β) (c : γ), b ∈ f a → c ∉ g b

Next tactic:
exact forall_swap
@[simp]
theorem refl_trans (f : α ≃. β) : (PEquiv.refl α).trans f = f := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
⊢ PEquiv.trans (PEquiv.refl α) f = f

Next tactic:
ext
@[simp]
theorem refl_trans (f : α ≃. β) : (PEquiv.refl α).trans f = f := by
  ext; 

Proof state:
case h.a
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
x✝ : α
a✝ : β
⊢ a✝ ∈ (PEquiv.trans (PEquiv.refl α) f) x✝ ↔ a✝ ∈ f x✝

Next tactic:
dsimp [PEquiv.trans]
@[simp]
theorem refl_trans (f : α ≃. β) : (PEquiv.refl α).trans f = f := by
  ext; dsimp [PEquiv.trans]; 

Proof state:
case h.a
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
x✝ : α
a✝ : β
⊢ a✝ ∈ f x✝ ↔ a✝ ∈ f x✝

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

Proof state:
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
⊢ PEquiv.trans f (PEquiv.refl β) = f

Next tactic:
ext
@[simp]
theorem trans_refl (f : α ≃. β) : f.trans (PEquiv.refl β) = f := by
  ext; 

Proof state:
case h.a
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
x✝ : α
a✝ : β
⊢ a✝ ∈ (PEquiv.trans f (PEquiv.refl β)) x✝ ↔ a✝ ∈ f x✝

Next tactic:
dsimp [PEquiv.trans]
@[simp]
theorem trans_refl (f : α ≃. β) : f.trans (PEquiv.refl β) = f := by
  ext; dsimp [PEquiv.trans]; 

Proof state:
case h.a
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
x✝ : α
a✝ : β
⊢ a✝ ∈ Option.bind (f x✝) ⇑(PEquiv.refl β) ↔ a✝ ∈ f x✝

Next tactic:
simp
protected theorem inj (f : α ≃. β) {a₁ a₂ : α} {b : β} (h₁ : b ∈ f a₁) (h₂ : b ∈ f a₂) : a₁ = a₂ :=
  by 

Proof state:
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
a₁ a₂ : α
b : β
h₁ : b ∈ f a₁
h₂ : b ∈ f a₂
⊢ a₁ = a₂

Next tactic:
rw [← mem_iff_mem] at *
protected theorem inj (f : α ≃. β) {a₁ a₂ : α} {b : β} (h₁ : b ∈ f a₁) (h₂ : b ∈ f a₂) : a₁ = a₂ :=
  by rw [← mem_iff_mem] at *; 

Proof state:
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
a₁ a₂ : α
b : β
h₁ : a₁ ∈ (PEquiv.symm f) b
h₂ : a₂ ∈ (PEquiv.symm f) b
⊢ a₁ = a₂

Next tactic:
cases h : f.symm b
protected theorem inj (f : α ≃. β) {a₁ a₂ : α} {b : β} (h₁ : b ∈ f a₁) (h₂ : b ∈ f a₂) : a₁ = a₂ :=
  by rw [← mem_iff_mem] at *; cases h : f.symm b <;> 

Proof state:
case none
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
a₁ a₂ : α
b : β
h₁ : a₁ ∈ (PEquiv.symm f) b
h₂ : a₂ ∈ (PEquiv.symm f) b
h : (PEquiv.symm f) b = none
⊢ a₁ = a₂

Next tactic:
simp_all
protected theorem inj (f : α ≃. β) {a₁ a₂ : α} {b : β} (h₁ : b ∈ f a₁) (h₂ : b ∈ f a₂) : a₁ = a₂ :=
  by rw [← mem_iff_mem] at *; cases h : f.symm b <;> 

Proof state:
case some
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
a₁ a₂ : α
b : β
h₁ : a₁ ∈ (PEquiv.symm f) b
h₂ : a₂ ∈ (PEquiv.symm f) b
val✝ : α
h : (PEquiv.symm f) b = some val✝
⊢ a₁ = a₂

Next tactic:
simp_all
/-- If the domain of a `PEquiv` is `α` except a point, its forward direction is injective. -/
theorem injective_of_forall_ne_isSome (f : α ≃. β) (a₂ : α)
    (h : ∀ a₁ : α, a₁ ≠ a₂ → isSome (f a₁)) : Injective f :=
  HasLeftInverse.injective
    ⟨fun b => Option.recOn b a₂ fun b' => Option.recOn (f.symm b') a₂ id, fun x => by
      

Proof state:
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
a₂ : α
h : ∀ (a₁ : α), a₁ ≠ a₂ → isSome (f a₁) = true
x : α
⊢ (fun b => Option.recOn b a₂ fun b' => Option.recOn ((PEquiv.symm f) b') a₂ id) (f x) = x

Next tactic:
classical
        cases hfx : f x
        · have : x = a₂ := not_imp_comm.1 (h x) (hfx.symm ▸ by simp)
          simp [this]
        · dsimp only
          rw [(eq_some_iff f).2 hfx]
          rfl
/-- If the domain of a `PEquiv` is `α` except a point, its forward direction is injective. -/
theorem injective_of_forall_ne_isSome (f : α ≃. β) (a₂ : α)
    (h : ∀ a₁ : α, a₁ ≠ a₂ → isSome (f a₁)) : Injective f :=
  HasLeftInverse.injective
    ⟨fun b => Option.recOn b a₂ fun b' => Option.recOn (f.symm b') a₂ id, fun x => by
      classical
        

Proof state:
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
a₂ : α
h : ∀ (a₁ : α), a₁ ≠ a₂ → isSome (f a₁) = true
x : α
⊢ (fun b => Option.recOn b a₂ fun b' => Option.recOn ((PEquiv.symm f) b') a₂ id) (f x) = x

Next tactic:
cases hfx : f x
/-- If the domain of a `PEquiv` is `α` except a point, its forward direction is injective. -/
theorem injective_of_forall_ne_isSome (f : α ≃. β) (a₂ : α)
    (h : ∀ a₁ : α, a₁ ≠ a₂ → isSome (f a₁)) : Injective f :=
  HasLeftInverse.injective
    ⟨fun b => Option.recOn b a₂ fun b' => Option.recOn (f.symm b') a₂ id, fun x => by
      classical
        cases hfx : f x
        · 

Proof state:
case none
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
a₂ : α
h : ∀ (a₁ : α), a₁ ≠ a₂ → isSome (f a₁) = true
x : α
hfx : f x = none
⊢ (fun b => Option.recOn b a₂ fun b' => Option.recOn ((PEquiv.symm f) b') a₂ id) none = x

Next tactic:
have : x = a₂ := not_imp_comm.1 (h x) (hfx.symm ▸ by simp)
/-- If the domain of a `PEquiv` is `α` except a point, its forward direction is injective. -/
theorem injective_of_forall_ne_isSome (f : α ≃. β) (a₂ : α)
    (h : ∀ a₁ : α, a₁ ≠ a₂ → isSome (f a₁)) : Injective f :=
  HasLeftInverse.injective
    ⟨fun b => Option.recOn b a₂ fun b' => Option.recOn (f.symm b') a₂ id, fun x => by
      classical
        cases hfx : f x
        · have : x = a₂ := not_imp_comm.1 (h x) (hfx.symm ▸ by 

Proof state:
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
a₂ : α
h : ∀ (a₁ : α), a₁ ≠ a₂ → isSome (f a₁) = true
x : α
hfx : f x = none
⊢ ¬isSome none = true

Next tactic:
simp
/-- If the domain of a `PEquiv` is `α` except a point, its forward direction is injective. -/
theorem injective_of_forall_ne_isSome (f : α ≃. β) (a₂ : α)
    (h : ∀ a₁ : α, a₁ ≠ a₂ → isSome (f a₁)) : Injective f :=
  HasLeftInverse.injective
    ⟨fun b => Option.recOn b a₂ fun b' => Option.recOn (f.symm b') a₂ id, fun x => by
      classical
        cases hfx : f x
        · have : x = a₂ := not_imp_comm.1 (h x) (hfx.symm ▸ by simp)
          

Proof state:
case none
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
a₂ : α
h : ∀ (a₁ : α), a₁ ≠ a₂ → isSome (f a₁) = true
x : α
hfx : f x = none
this : x = a₂
⊢ (fun b => Option.recOn b a₂ fun b' => Option.recOn ((PEquiv.symm f) b') a₂ id) none = x

Next tactic:
simp [this]
/-- If the domain of a `PEquiv` is `α` except a point, its forward direction is injective. -/
theorem injective_of_forall_ne_isSome (f : α ≃. β) (a₂ : α)
    (h : ∀ a₁ : α, a₁ ≠ a₂ → isSome (f a₁)) : Injective f :=
  HasLeftInverse.injective
    ⟨fun b => Option.recOn b a₂ fun b' => Option.recOn (f.symm b') a₂ id, fun x => by
      classical
        cases hfx : f x
        · have : x = a₂ := not_imp_comm.1 (h x) (hfx.symm ▸ by simp)
          simp [this]
        · 

Proof state:
case some
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
a₂ : α
h : ∀ (a₁ : α), a₁ ≠ a₂ → isSome (f a₁) = true
x : α
val✝ : β
hfx : f x = some val✝
⊢ (fun b => Option.recOn b a₂ fun b' => Option.recOn ((PEquiv.symm f) b') a₂ id) (some val✝) = x

Next tactic:
dsimp only
/-- If the domain of a `PEquiv` is `α` except a point, its forward direction is injective. -/
theorem injective_of_forall_ne_isSome (f : α ≃. β) (a₂ : α)
    (h : ∀ a₁ : α, a₁ ≠ a₂ → isSome (f a₁)) : Injective f :=
  HasLeftInverse.injective
    ⟨fun b => Option.recOn b a₂ fun b' => Option.recOn (f.symm b') a₂ id, fun x => by
      classical
        cases hfx : f x
        · have : x = a₂ := not_imp_comm.1 (h x) (hfx.symm ▸ by simp)
          simp [this]
        · dsimp only
          

Proof state:
case some
α : Type u
β : Type v
γ : Type w
δ : Type x
f : α ≃. β
a₂ : α
h : ∀ (a₁ : α), a₁ ≠ a₂ → isSome (f a₁) = true
x : α
val✝ : β
hfx : f x = some val✝
⊢ Option.rec a₂ id ((PEquiv.symm f) val✝) = x

Next tactic:
rw [(eq_some_iff f).2 hfx]