l3lab/ntp-mathlib huggingface dataset:
theorem stereo_left_inv (hv : ‖v‖ = 1) {x : sphere (0 : E) 1} (hx : (x : E) ≠ v) :
    stereoInvFun hv (stereoToFun v x) = x := by
  ext
  simp only [stereoToFun_apply, stereoInvFun_apply, smul_add]
  -- name two frequently-occuring quantities and write down their basic properties
  set a : ℝ := innerSL _ v x
  set y := orthogonalProjection (ℝ ∙ v)ᗮ x
  have split : ↑x = a • v + ↑y := by
    convert (orthogonalProjection_add_orthogonalProjection_orthogonal (ℝ ∙ v) x).symm
    exact (orthogonalProjection_unit_singleton ℝ hv x).symm
  have hvy : ⟪v, y⟫_ℝ = 0 := Submodule.mem_orthogonal_singleton_iff_inner_right.mp y.2
  have pythag : 1 = a ^ 2 + ‖y‖ ^ 2 := by
    have hvy' : ⟪a • v, y⟫_ℝ = 0 := by simp only [inner_smul_left, hvy, mul_zero]
    convert norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero _ _ hvy' using 2
    -- Porting note: was simp [← split] but wasn't finding `norm_eq_of_mem_sphere`
    · simp only [norm_eq_of_mem_sphere, Nat.cast_one, mul_one, ← split]
    · simp [norm_smul, hv, ← sq, sq_abs]
    · exact sq _
  -- Porting note : added to work around cancel_denoms and nlinarith failures
  have duh : ‖y.val‖ ^ 2 = 1 - a ^ 2 := by
    rw [← Submodule.coe_norm, pythag]; ring
  -- two facts which will be helpful for clearing denominators in the main calculation
  have ha : 1 - a ≠ 0 := by
    have : a < 1 := (inner_lt_one_iff_real_of_norm_one hv (by simp)).mpr hx.symm
    linarith
  -- the core of the problem is these two algebraic identities:
  have h₁ : (2 ^ 2 / (1 - a) ^ 2 * ‖y‖ ^ 2 + 4)⁻¹ * 4 * (2 / (1 - a)) = 1 := by
    -- Porting note: used to be `field_simp; simp only [Submodule.coe_norm] at *; nlinarith`
    -- but cancel_denoms does not seem to be working and
    -- nlinarith cannot close the goal even if it did
    -- clear_value because field_simp does zeta-reduction (by design?) and is annoying
    clear_value a y
    field_simp
    rw [duh]
    ring
  have h₂ : (2 ^ 2 / (1 - a) ^ 2 * ‖y‖ ^ 2 + 4)⁻¹ * (2 ^ 2 / (1 - a) ^ 2 * ‖y‖ ^ 2 - 4) = a := by
    -- Porting note: field_simp is not behaving as in ml3
    -- see porting note above; previous proof used trans and was comparably complicated
    clear_value a y
    field_simp
    rw [duh]
    

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
x : ↑(sphere 0 1)
hx : ↑x ≠ v
y : ↥(Submodule.span ℝ {v})ᗮ
hvy : inner v ↑y = 0
a : ℝ
ha : 1 - a ≠ 0
split : ↑x = a • v + ↑y
pythag : 1 = a ^ 2 + ‖y‖ ^ 2
duh : ‖↑y‖ ^ 2 = 1 - a ^ 2
h₁ : (2 ^ 2 / (1 - a) ^ 2 * ‖y‖ ^ 2 + 4)⁻¹ * 4 * (2 / (1 - a)) = 1
⊢ (1 - a) ^ 2 * (2 ^ 2 * (1 - a ^ 2) - (1 - a) ^ 2 * 4) = a * ((2 ^ 2 * (1 - a ^ 2) + 4 * (1 - a) ^ 2) * (1 - a) ^ 2)

Next tactic:
ring
theorem stereo_left_inv (hv : ‖v‖ = 1) {x : sphere (0 : E) 1} (hx : (x : E) ≠ v) :
    stereoInvFun hv (stereoToFun v x) = x := by
  ext
  simp only [stereoToFun_apply, stereoInvFun_apply, smul_add]
  -- name two frequently-occuring quantities and write down their basic properties
  set a : ℝ := innerSL _ v x
  set y := orthogonalProjection (ℝ ∙ v)ᗮ x
  have split : ↑x = a • v + ↑y := by
    convert (orthogonalProjection_add_orthogonalProjection_orthogonal (ℝ ∙ v) x).symm
    exact (orthogonalProjection_unit_singleton ℝ hv x).symm
  have hvy : ⟪v, y⟫_ℝ = 0 := Submodule.mem_orthogonal_singleton_iff_inner_right.mp y.2
  have pythag : 1 = a ^ 2 + ‖y‖ ^ 2 := by
    have hvy' : ⟪a • v, y⟫_ℝ = 0 := by simp only [inner_smul_left, hvy, mul_zero]
    convert norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero _ _ hvy' using 2
    -- Porting note: was simp [← split] but wasn't finding `norm_eq_of_mem_sphere`
    · simp only [norm_eq_of_mem_sphere, Nat.cast_one, mul_one, ← split]
    · simp [norm_smul, hv, ← sq, sq_abs]
    · exact sq _
  -- Porting note : added to work around cancel_denoms and nlinarith failures
  have duh : ‖y.val‖ ^ 2 = 1 - a ^ 2 := by
    rw [← Submodule.coe_norm, pythag]; ring
  -- two facts which will be helpful for clearing denominators in the main calculation
  have ha : 1 - a ≠ 0 := by
    have : a < 1 := (inner_lt_one_iff_real_of_norm_one hv (by simp)).mpr hx.symm
    linarith
  -- the core of the problem is these two algebraic identities:
  have h₁ : (2 ^ 2 / (1 - a) ^ 2 * ‖y‖ ^ 2 + 4)⁻¹ * 4 * (2 / (1 - a)) = 1 := by
    -- Porting note: used to be `field_simp; simp only [Submodule.coe_norm] at *; nlinarith`
    -- but cancel_denoms does not seem to be working and
    -- nlinarith cannot close the goal even if it did
    -- clear_value because field_simp does zeta-reduction (by design?) and is annoying
    clear_value a y
    field_simp
    rw [duh]
    ring
  have h₂ : (2 ^ 2 / (1 - a) ^ 2 * ‖y‖ ^ 2 + 4)⁻¹ * (2 ^ 2 / (1 - a) ^ 2 * ‖y‖ ^ 2 - 4) = a := by
    -- Porting note: field_simp is not behaving as in ml3
    -- see porting note above; previous proof used trans and was comparably complicated
    clear_value a y
    field_simp
    rw [duh]
    ring
  

Proof state:
case a
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
x : ↑(sphere 0 1)
hx : ↑x ≠ v
a : ℝ := ((innerSL ℝ) v) ↑x
y : ↥(Submodule.span ℝ {v})ᗮ := (orthogonalProjection (Submodule.span ℝ {v})ᗮ) ↑x
split : ↑x = a • v + ↑y
hvy : inner v ↑y = 0
pythag : 1 = a ^ 2 + ‖y‖ ^ 2
duh : ‖↑y‖ ^ 2 = 1 - a ^ 2
ha : 1 - a ≠ 0
h₁ : (2 ^ 2 / (1 - a) ^ 2 * ‖y‖ ^ 2 + 4)⁻¹ * 4 * (2 / (1 - a)) = 1
h₂ : (2 ^ 2 / (1 - a) ^ 2 * ‖y‖ ^ 2 + 4)⁻¹ * (2 ^ 2 / (1 - a) ^ 2 * ‖y‖ ^ 2 - 4) = a
⊢ (‖(2 / (1 - a)) • y‖ ^ 2 + 4)⁻¹ • 4 • ↑((2 / (1 - a)) • y) +
      (‖(2 / (1 - a)) • y‖ ^ 2 + 4)⁻¹ • (‖(2 / (1 - a)) • y‖ ^ 2 - 4) • v =
    ↑x

Next tactic:
convert
    congr_arg₂ Add.add (congr_arg (fun t => t • (y : E)) h₁) (congr_arg (fun t => t • v) h₂) using 1
theorem stereo_right_inv (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : stereoToFun v (stereoInvFun hv w) = w := by
  

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
w : ↥(Submodule.span ℝ {v})ᗮ
⊢ stereoToFun v ↑(stereoInvFun hv w) = w

Next tactic:
have : 2 / (1 - (‖(w : E)‖ ^ 2 + 4)⁻¹ * (‖(w : E)‖ ^ 2 - 4)) * (‖(w : E)‖ ^ 2 + 4)⁻¹ * 4 = 1 := by
    field_simp; ring
theorem stereo_right_inv (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : stereoToFun v (stereoInvFun hv w) = w := by
  have : 2 / (1 - (‖(w : E)‖ ^ 2 + 4)⁻¹ * (‖(w : E)‖ ^ 2 - 4)) * (‖(w : E)‖ ^ 2 + 4)⁻¹ * 4 = 1 := by
    

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
w : ↥(Submodule.span ℝ {v})ᗮ
⊢ 2 / (1 - (‖↑w‖ ^ 2 + 4)⁻¹ * (‖↑w‖ ^ 2 - 4)) * (‖↑w‖ ^ 2 + 4)⁻¹ * 4 = 1

Next tactic:
field_simp
theorem stereo_right_inv (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : stereoToFun v (stereoInvFun hv w) = w := by
  have : 2 / (1 - (‖(w : E)‖ ^ 2 + 4)⁻¹ * (‖(w : E)‖ ^ 2 - 4)) * (‖(w : E)‖ ^ 2 + 4)⁻¹ * 4 = 1 := by
    field_simp; 

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
w : ↥(Submodule.span ℝ {v})ᗮ
⊢ 2 * (‖↑w‖ ^ 2 + 4) * 4 = (4 + 4) * (‖↑w‖ ^ 2 + 4)

Next tactic:
ring
theorem stereo_right_inv (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : stereoToFun v (stereoInvFun hv w) = w := by
  have : 2 / (1 - (‖(w : E)‖ ^ 2 + 4)⁻¹ * (‖(w : E)‖ ^ 2 - 4)) * (‖(w : E)‖ ^ 2 + 4)⁻¹ * 4 = 1 := by
    field_simp; ring
  

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
w : ↥(Submodule.span ℝ {v})ᗮ
this : 2 / (1 - (‖↑w‖ ^ 2 + 4)⁻¹ * (‖↑w‖ ^ 2 - 4)) * (‖↑w‖ ^ 2 + 4)⁻¹ * 4 = 1
⊢ stereoToFun v ↑(stereoInvFun hv w) = w

Next tactic:
convert congr_arg (· • w) this
theorem stereo_right_inv (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : stereoToFun v (stereoInvFun hv w) = w := by
  have : 2 / (1 - (‖(w : E)‖ ^ 2 + 4)⁻¹ * (‖(w : E)‖ ^ 2 - 4)) * (‖(w : E)‖ ^ 2 + 4)⁻¹ * 4 = 1 := by
    field_simp; ring
  convert congr_arg (· • w) this
  · 

Proof state:
case h.e'_2
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
w : ↥(Submodule.span ℝ {v})ᗮ
this : 2 / (1 - (‖↑w‖ ^ 2 + 4)⁻¹ * (‖↑w‖ ^ 2 - 4)) * (‖↑w‖ ^ 2 + 4)⁻¹ * 4 = 1
⊢ stereoToFun v ↑(stereoInvFun hv w) = (2 / (1 - (‖↑w‖ ^ 2 + 4)⁻¹ * (‖↑w‖ ^ 2 - 4)) * (‖↑w‖ ^ 2 + 4)⁻¹ * 4) • w

Next tactic:
have h₁ : orthogonalProjection (ℝ ∙ v)ᗮ v = 0 :=
      orthogonalProjection_orthogonalComplement_singleton_eq_zero v
theorem stereo_right_inv (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : stereoToFun v (stereoInvFun hv w) = w := by
  have : 2 / (1 - (‖(w : E)‖ ^ 2 + 4)⁻¹ * (‖(w : E)‖ ^ 2 - 4)) * (‖(w : E)‖ ^ 2 + 4)⁻¹ * 4 = 1 := by
    field_simp; ring
  convert congr_arg (· • w) this
  · have h₁ : orthogonalProjection (ℝ ∙ v)ᗮ v = 0 :=
      orthogonalProjection_orthogonalComplement_singleton_eq_zero v
    -- Porting note: was innerSL _ and now just inner
    

Proof state:
case h.e'_2
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
w : ↥(Submodule.span ℝ {v})ᗮ
this : 2 / (1 - (‖↑w‖ ^ 2 + 4)⁻¹ * (‖↑w‖ ^ 2 - 4)) * (‖↑w‖ ^ 2 + 4)⁻¹ * 4 = 1
h₁ : (orthogonalProjection (Submodule.span ℝ {v})ᗮ) v = 0
⊢ stereoToFun v ↑(stereoInvFun hv w) = (2 / (1 - (‖↑w‖ ^ 2 + 4)⁻¹ * (‖↑w‖ ^ 2 - 4)) * (‖↑w‖ ^ 2 + 4)⁻¹ * 4) • w

Next tactic:
have h₃ : inner v w = (0 : ℝ) := Submodule.mem_orthogonal_singleton_iff_inner_right.mp w.2
theorem stereo_right_inv (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : stereoToFun v (stereoInvFun hv w) = w := by
  have : 2 / (1 - (‖(w : E)‖ ^ 2 + 4)⁻¹ * (‖(w : E)‖ ^ 2 - 4)) * (‖(w : E)‖ ^ 2 + 4)⁻¹ * 4 = 1 := by
    field_simp; ring
  convert congr_arg (· • w) this
  · have h₁ : orthogonalProjection (ℝ ∙ v)ᗮ v = 0 :=
      orthogonalProjection_orthogonalComplement_singleton_eq_zero v
    -- Porting note: was innerSL _ and now just inner
    have h₃ : inner v w = (0 : ℝ) := Submodule.mem_orthogonal_singleton_iff_inner_right.mp w.2
    -- Porting note: was innerSL _ and now just inner
    

Proof state:
case h.e'_2
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
w : ↥(Submodule.span ℝ {v})ᗮ
this : 2 / (1 - (‖↑w‖ ^ 2 + 4)⁻¹ * (‖↑w‖ ^ 2 - 4)) * (‖↑w‖ ^ 2 + 4)⁻¹ * 4 = 1
h₁ : (orthogonalProjection (Submodule.span ℝ {v})ᗮ) v = 0
h₃ : inner v ↑w = 0
⊢ stereoToFun v ↑(stereoInvFun hv w) = (2 / (1 - (‖↑w‖ ^ 2 + 4)⁻¹ * (‖↑w‖ ^ 2 - 4)) * (‖↑w‖ ^ 2 + 4)⁻¹ * 4) • w

Next tactic:
have h₄ : inner v v = (1 : ℝ) := by simp [real_inner_self_eq_norm_mul_norm, hv]
theorem stereo_right_inv (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : stereoToFun v (stereoInvFun hv w) = w := by
  have : 2 / (1 - (‖(w : E)‖ ^ 2 + 4)⁻¹ * (‖(w : E)‖ ^ 2 - 4)) * (‖(w : E)‖ ^ 2 + 4)⁻¹ * 4 = 1 := by
    field_simp; ring
  convert congr_arg (· • w) this
  · have h₁ : orthogonalProjection (ℝ ∙ v)ᗮ v = 0 :=
      orthogonalProjection_orthogonalComplement_singleton_eq_zero v
    -- Porting note: was innerSL _ and now just inner
    have h₃ : inner v w = (0 : ℝ) := Submodule.mem_orthogonal_singleton_iff_inner_right.mp w.2
    -- Porting note: was innerSL _ and now just inner
    have h₄ : inner v v = (1 : ℝ) := by 

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
w : ↥(Submodule.span ℝ {v})ᗮ
this : 2 / (1 - (‖↑w‖ ^ 2 + 4)⁻¹ * (‖↑w‖ ^ 2 - 4)) * (‖↑w‖ ^ 2 + 4)⁻¹ * 4 = 1
h₁ : (orthogonalProjection (Submodule.span ℝ {v})ᗮ) v = 0
h₃ : inner v ↑w = 0
⊢ inner v v = 1

Next tactic:
simp [real_inner_self_eq_norm_mul_norm, hv]
theorem stereo_right_inv (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : stereoToFun v (stereoInvFun hv w) = w := by
  have : 2 / (1 - (‖(w : E)‖ ^ 2 + 4)⁻¹ * (‖(w : E)‖ ^ 2 - 4)) * (‖(w : E)‖ ^ 2 + 4)⁻¹ * 4 = 1 := by
    field_simp; ring
  convert congr_arg (· • w) this
  · have h₁ : orthogonalProjection (ℝ ∙ v)ᗮ v = 0 :=
      orthogonalProjection_orthogonalComplement_singleton_eq_zero v
    -- Porting note: was innerSL _ and now just inner
    have h₃ : inner v w = (0 : ℝ) := Submodule.mem_orthogonal_singleton_iff_inner_right.mp w.2
    -- Porting note: was innerSL _ and now just inner
    have h₄ : inner v v = (1 : ℝ) := by simp [real_inner_self_eq_norm_mul_norm, hv]
    

Proof state:
case h.e'_2
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
w : ↥(Submodule.span ℝ {v})ᗮ
this : 2 / (1 - (‖↑w‖ ^ 2 + 4)⁻¹ * (‖↑w‖ ^ 2 - 4)) * (‖↑w‖ ^ 2 + 4)⁻¹ * 4 = 1
h₁ : (orthogonalProjection (Submodule.span ℝ {v})ᗮ) v = 0
h₃ : inner v ↑w = 0
h₄ : inner v v = 1
⊢ stereoToFun v ↑(stereoInvFun hv w) = (2 / (1 - (‖↑w‖ ^ 2 + 4)⁻¹ * (‖↑w‖ ^ 2 - 4)) * (‖↑w‖ ^ 2 + 4)⁻¹ * 4) • w

Next tactic:
simp [h₁, h₃, h₄, ContinuousLinearMap.map_add, ContinuousLinearMap.map_smul, mul_smul]
theorem stereo_right_inv (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : stereoToFun v (stereoInvFun hv w) = w := by
  have : 2 / (1 - (‖(w : E)‖ ^ 2 + 4)⁻¹ * (‖(w : E)‖ ^ 2 - 4)) * (‖(w : E)‖ ^ 2 + 4)⁻¹ * 4 = 1 := by
    field_simp; ring
  convert congr_arg (· • w) this
  · have h₁ : orthogonalProjection (ℝ ∙ v)ᗮ v = 0 :=
      orthogonalProjection_orthogonalComplement_singleton_eq_zero v
    -- Porting note: was innerSL _ and now just inner
    have h₃ : inner v w = (0 : ℝ) := Submodule.mem_orthogonal_singleton_iff_inner_right.mp w.2
    -- Porting note: was innerSL _ and now just inner
    have h₄ : inner v v = (1 : ℝ) := by simp [real_inner_self_eq_norm_mul_norm, hv]
    simp [h₁, h₃, h₄, ContinuousLinearMap.map_add, ContinuousLinearMap.map_smul, mul_smul]
  · 

Proof state:
case h.e'_3
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
w : ↥(Submodule.span ℝ {v})ᗮ
this : 2 / (1 - (‖↑w‖ ^ 2 + 4)⁻¹ * (‖↑w‖ ^ 2 - 4)) * (‖↑w‖ ^ 2 + 4)⁻¹ * 4 = 1
⊢ w = 1 • w

Next tactic:
simp
/-- Stereographic projection from the unit sphere in `E`, centred at a unit vector `v` in `E`; this
is the version as a local homeomorphism. -/
def stereographic (hv : ‖v‖ = 1) : PartialHomeomorph (sphere (0 : E) 1) (ℝ ∙ v)ᗮ where
  toFun := stereoToFun v ∘ (↑)
  invFun := stereoInvFun hv
  source := {⟨v, by 

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
⊢ v ∈ sphere 0 1

Next tactic:
simp [hv]
/-- Stereographic projection from the unit sphere in `E`, centred at a unit vector `v` in `E`; this
is the version as a local homeomorphism. -/
def stereographic (hv : ‖v‖ = 1) : PartialHomeomorph (sphere (0 : E) 1) (ℝ ∙ v)ᗮ where
  toFun := stereoToFun v ∘ (↑)
  invFun := stereoInvFun hv
  source := {⟨v, by simp [hv]⟩}ᶜ
  target := Set.univ
  map_source' := by 

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
⊢ ∀ ⦃x : ↑(sphere 0 1)⦄, x ∈ {{ val := v, property := ?m.491481 }}ᶜ → (stereoToFun v ∘ Subtype.val) x ∈ Set.univ

Next tactic:
simp
/-- Stereographic projection from the unit sphere in `E`, centred at a unit vector `v` in `E`; this
is the version as a local homeomorphism. -/
def stereographic (hv : ‖v‖ = 1) : PartialHomeomorph (sphere (0 : E) 1) (ℝ ∙ v)ᗮ where
  toFun := stereoToFun v ∘ (↑)
  invFun := stereoInvFun hv
  source := {⟨v, by simp [hv]⟩}ᶜ
  target := Set.univ
  map_source' := by simp
  map_target' {w} _ := fun h => (stereoInvFun_ne_north_pole hv w) (Set.eq_of_mem_singleton h)
  left_inv' x hx := stereo_left_inv hv fun h => hx (by
    

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
x : ↑(sphere 0 1)
hx : x ∈ {{ val := v, property := ?m.491481 }}ᶜ
h : ↑x = v
⊢ x ∈ {{ val := v, property := ?m.491481 }}

Next tactic:
rw [← h] at hv
/-- Stereographic projection from the unit sphere in `E`, centred at a unit vector `v` in `E`; this
is the version as a local homeomorphism. -/
def stereographic (hv : ‖v‖ = 1) : PartialHomeomorph (sphere (0 : E) 1) (ℝ ∙ v)ᗮ where
  toFun := stereoToFun v ∘ (↑)
  invFun := stereoInvFun hv
  source := {⟨v, by simp [hv]⟩}ᶜ
  target := Set.univ
  map_source' := by simp
  map_target' {w} _ := fun h => (stereoInvFun_ne_north_pole hv w) (Set.eq_of_mem_singleton h)
  left_inv' x hx := stereo_left_inv hv fun h => hx (by
    rw [← h] at hv
    

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv✝ : ‖v‖ = 1
x : ↑(sphere 0 1)
hv : ‖↑x‖ = 1
hx : x ∈ {{ val := v, property := ?m.491481 }}ᶜ
h : ↑x = v
⊢ x ∈ {{ val := v, property := ?m.491481 }}

Next tactic:
apply Subtype.ext
/-- Stereographic projection from the unit sphere in `E`, centred at a unit vector `v` in `E`; this
is the version as a local homeomorphism. -/
def stereographic (hv : ‖v‖ = 1) : PartialHomeomorph (sphere (0 : E) 1) (ℝ ∙ v)ᗮ where
  toFun := stereoToFun v ∘ (↑)
  invFun := stereoInvFun hv
  source := {⟨v, by simp [hv]⟩}ᶜ
  target := Set.univ
  map_source' := by simp
  map_target' {w} _ := fun h => (stereoInvFun_ne_north_pole hv w) (Set.eq_of_mem_singleton h)
  left_inv' x hx := stereo_left_inv hv fun h => hx (by
    rw [← h] at hv
    apply Subtype.ext
    

Proof state:
case a
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv✝ : ‖v‖ = 1
x : ↑(sphere 0 1)
hv : ‖↑x‖ = 1
hx : x ∈ {{ val := v, property := ?m.491481 }}ᶜ
h : ↑x = v
⊢ ↑x = ↑{ val := v, property := ?m.491481 }

Next tactic:
dsimp
/-- Stereographic projection from the unit sphere in `E`, centred at a unit vector `v` in `E`; this
is the version as a local homeomorphism. -/
def stereographic (hv : ‖v‖ = 1) : PartialHomeomorph (sphere (0 : E) 1) (ℝ ∙ v)ᗮ where
  toFun := stereoToFun v ∘ (↑)
  invFun := stereoInvFun hv
  source := {⟨v, by simp [hv]⟩}ᶜ
  target := Set.univ
  map_source' := by simp
  map_target' {w} _ := fun h => (stereoInvFun_ne_north_pole hv w) (Set.eq_of_mem_singleton h)
  left_inv' x hx := stereo_left_inv hv fun h => hx (by
    rw [← h] at hv
    apply Subtype.ext
    dsimp
    

Proof state:
case a
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv✝ : ‖v‖ = 1
x : ↑(sphere 0 1)
hv : ‖↑x‖ = 1
hx : x ∈ {{ val := v, property := ?m.491481 }}ᶜ
h : ↑x = v
⊢ ↑x = v

Next tactic:
exact h
/-- Stereographic projection from the unit sphere in `E`, centred at a unit vector `v` in `E`; this
is the version as a local homeomorphism. -/
def stereographic (hv : ‖v‖ = 1) : PartialHomeomorph (sphere (0 : E) 1) (ℝ ∙ v)ᗮ where
  toFun := stereoToFun v ∘ (↑)
  invFun := stereoInvFun hv
  source := {⟨v, by simp [hv]⟩}ᶜ
  target := Set.univ
  map_source' := by simp
  map_target' {w} _ := fun h => (stereoInvFun_ne_north_pole hv w) (Set.eq_of_mem_singleton h)
  left_inv' x hx := stereo_left_inv hv fun h => hx (by
    rw [← h] at hv
    apply Subtype.ext
    dsimp
    exact h)
  right_inv' w _ := stereo_right_inv hv w
  open_source := isOpen_compl_singleton
  open_target := isOpen_univ
  continuousOn_toFun :=
    continuousOn_stereoToFun.comp continuous_subtype_val.continuousOn fun w h => by
      

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
w : ↑(sphere 0 1)
h :
  w ∈
    { toFun := stereoToFun v ∘ Subtype.val, invFun := stereoInvFun hv, source := {{ val := v, property := ?m.491481 }}ᶜ,
        target := Set.univ,
        map_source' :=
          (_ :
            ∀ a ∈ {{ val := v, property := ?m.491481 }}ᶜ,
              (2 / (1 - inner v ↑a)) • (orthogonalProjection (Submodule.span ℝ {v})ᗮ) ↑a ∈ Set.univ),
        map_target' :=
          (_ :
            ∀ {w : ↥(Submodule.span ℝ {v})ᗮ},
              w ∈ Set.univ → stereoInvFun hv w ∈ {{ val := v, property := ?m.491481 }} → False),
        left_inv' := (_ : ∀ x ∈ {{ val := v, property := ?m.491481 }}ᶜ, stereoInvFun hv (stereoToFun v ↑x) = x),
        right_inv' := (_ : ∀ w ∈ Set.univ, stereoToFun v ↑(stereoInvFun hv w) = w) }.source
⊢ ↑w ∈ {x | ((innerSL ℝ) v) x ≠ 1}

Next tactic:
dsimp
/-- Stereographic projection from the unit sphere in `E`, centred at a unit vector `v` in `E`; this
is the version as a local homeomorphism. -/
def stereographic (hv : ‖v‖ = 1) : PartialHomeomorph (sphere (0 : E) 1) (ℝ ∙ v)ᗮ where
  toFun := stereoToFun v ∘ (↑)
  invFun := stereoInvFun hv
  source := {⟨v, by simp [hv]⟩}ᶜ
  target := Set.univ
  map_source' := by simp
  map_target' {w} _ := fun h => (stereoInvFun_ne_north_pole hv w) (Set.eq_of_mem_singleton h)
  left_inv' x hx := stereo_left_inv hv fun h => hx (by
    rw [← h] at hv
    apply Subtype.ext
    dsimp
    exact h)
  right_inv' w _ := stereo_right_inv hv w
  open_source := isOpen_compl_singleton
  open_target := isOpen_univ
  continuousOn_toFun :=
    continuousOn_stereoToFun.comp continuous_subtype_val.continuousOn fun w h => by
      dsimp
      

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
w : ↑(sphere 0 1)
h :
  w ∈
    { toFun := stereoToFun v ∘ Subtype.val, invFun := stereoInvFun hv, source := {{ val := v, property := ?m.491481 }}ᶜ,
        target := Set.univ,
        map_source' :=
          (_ :
            ∀ a ∈ {{ val := v, property := ?m.491481 }}ᶜ,
              (2 / (1 - inner v ↑a)) • (orthogonalProjection (Submodule.span ℝ {v})ᗮ) ↑a ∈ Set.univ),
        map_target' :=
          (_ :
            ∀ {w : ↥(Submodule.span ℝ {v})ᗮ},
              w ∈ Set.univ → stereoInvFun hv w ∈ {{ val := v, property := ?m.491481 }} → False),
        left_inv' := (_ : ∀ x ∈ {{ val := v, property := ?m.491481 }}ᶜ, stereoInvFun hv (stereoToFun v ↑x) = x),
        right_inv' := (_ : ∀ w ∈ Set.univ, stereoToFun v ↑(stereoInvFun hv w) = w) }.source
⊢ ¬inner v ↑w = 1

Next tactic:
exact
        h ∘ Subtype.ext ∘ Eq.symm ∘ (inner_eq_one_iff_of_norm_one hv (by simp)).mp
/-- Stereographic projection from the unit sphere in `E`, centred at a unit vector `v` in `E`; this
is the version as a local homeomorphism. -/
def stereographic (hv : ‖v‖ = 1) : PartialHomeomorph (sphere (0 : E) 1) (ℝ ∙ v)ᗮ where
  toFun := stereoToFun v ∘ (↑)
  invFun := stereoInvFun hv
  source := {⟨v, by simp [hv]⟩}ᶜ
  target := Set.univ
  map_source' := by simp
  map_target' {w} _ := fun h => (stereoInvFun_ne_north_pole hv w) (Set.eq_of_mem_singleton h)
  left_inv' x hx := stereo_left_inv hv fun h => hx (by
    rw [← h] at hv
    apply Subtype.ext
    dsimp
    exact h)
  right_inv' w _ := stereo_right_inv hv w
  open_source := isOpen_compl_singleton
  open_target := isOpen_univ
  continuousOn_toFun :=
    continuousOn_stereoToFun.comp continuous_subtype_val.continuousOn fun w h => by
      dsimp
      exact
        h ∘ Subtype.ext ∘ Eq.symm ∘ (inner_eq_one_iff_of_norm_one hv (by 

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
w : ↑(sphere 0 1)
h :
  w ∈
    { toFun := stereoToFun v ∘ Subtype.val, invFun := stereoInvFun hv, source := {{ val := v, property := ?m.491481 }}ᶜ,
        target := Set.univ,
        map_source' :=
          (_ :
            ∀ a ∈ {{ val := v, property := ?m.491481 }}ᶜ,
              (2 / (1 - inner v ↑a)) • (orthogonalProjection (Submodule.span ℝ {v})ᗮ) ↑a ∈ Set.univ),
        map_target' :=
          (_ :
            ∀ {w : ↥(Submodule.span ℝ {v})ᗮ},
              w ∈ Set.univ → stereoInvFun hv w ∈ {{ val := v, property := ?m.491481 }} → False),
        left_inv' := (_ : ∀ x ∈ {{ val := v, property := ?m.491481 }}ᶜ, stereoInvFun hv (stereoToFun v ↑x) = x),
        right_inv' := (_ : ∀ w ∈ Set.univ, stereoToFun v ↑(stereoInvFun hv w) = w) }.source
⊢ ‖↑w‖ = 1

Next tactic:
simp
@[simp]
theorem stereographic_source (hv : ‖v‖ = 1) : (stereographic hv).source = {⟨v, by 

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v : E
hv : ‖v‖ = 1
⊢ v ∈ sphere 0 1

Next tactic:
simp [hv]
@[simp]
theorem stereographic_apply_neg (v : sphere (0 : E) 1) :
    stereographic (norm_eq_of_mem_sphere v) (-v) = 0 := by
  

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v✝ : E
v : ↑(sphere 0 1)
⊢ ↑(stereographic (_ : ‖↑v‖ = 1)) (-v) = 0

Next tactic:
simp [stereographic_apply, orthogonalProjection_orthogonalComplement_singleton_eq_zero]
@[simp]
theorem stereographic_neg_apply (v : sphere (0 : E) 1) :
    stereographic (norm_eq_of_mem_sphere (-v)) v = 0 := by
  

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v✝ : E
v : ↑(sphere 0 1)
⊢ ↑(stereographic (_ : ‖↑(-v)‖ = 1)) v = 0

Next tactic:
convert stereographic_apply_neg (-v)
@[simp]
theorem stereographic_neg_apply (v : sphere (0 : E) 1) :
    stereographic (norm_eq_of_mem_sphere (-v)) v = 0 := by
  convert stereographic_apply_neg (-v)
  

Proof state:
case h.e'_2.h.e'_6
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
v✝ : E
v : ↑(sphere 0 1)
⊢ v = - -v

Next tactic:
ext1