l3lab/ntp-mathlib huggingface dataset:
/-- The inclusion map (i.e., `coe`) from the sphere in `E` to `E` is smooth.  -/
theorem contMDiff_coe_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] :
    ContMDiff (𝓡 n) 𝓘(ℝ, E) ∞ ((↑) : sphere (0 : E) 1 → E) := by
  -- Porting note: trouble with filling these implicit variables in the instance
  have := smoothMfldWithCorners (E := E) (n := n)
  

Proof state:
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace ℝ E
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
this : SmoothManifoldWithCorners 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) ↑(sphere 0 1)
⊢ ContMDiff 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) 𝓘(ℝ, E) ⊤ Subtype.val

Next tactic:
rw [contMDiff_iff]
/-- The inclusion map (i.e., `coe`) from the sphere in `E` to `E` is smooth.  -/
theorem contMDiff_coe_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] :
    ContMDiff (𝓡 n) 𝓘(ℝ, E) ∞ ((↑) : sphere (0 : E) 1 → E) := by
  -- Porting note: trouble with filling these implicit variables in the instance
  have := smoothMfldWithCorners (E := E) (n := n)
  rw [contMDiff_iff]
  

Proof state:
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace ℝ E
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
this : SmoothManifoldWithCorners 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) ↑(sphere 0 1)
⊢ Continuous Subtype.val ∧
    ∀ (x : { x // x ∈ sphere 0 1 }) (y : E),
      ContDiffOn ℝ ⊤
        (↑(extChartAt 𝓘(ℝ, E) y) ∘ Subtype.val ∘ ↑(PartialEquiv.symm (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) x)))
        ((extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) x).target ∩
          ↑(PartialEquiv.symm (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) x)) ⁻¹'
            (Subtype.val ⁻¹' (extChartAt 𝓘(ℝ, E) y).source))

Next tactic:
constructor
/-- The inclusion map (i.e., `coe`) from the sphere in `E` to `E` is smooth.  -/
theorem contMDiff_coe_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] :
    ContMDiff (𝓡 n) 𝓘(ℝ, E) ∞ ((↑) : sphere (0 : E) 1 → E) := by
  -- Porting note: trouble with filling these implicit variables in the instance
  have := smoothMfldWithCorners (E := E) (n := n)
  rw [contMDiff_iff]
  constructor
  · 

Proof state:
case left
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace ℝ E
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
this : SmoothManifoldWithCorners 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) ↑(sphere 0 1)
⊢ Continuous Subtype.val

Next tactic:
exact continuous_subtype_val
/-- The inclusion map (i.e., `coe`) from the sphere in `E` to `E` is smooth.  -/
theorem contMDiff_coe_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] :
    ContMDiff (𝓡 n) 𝓘(ℝ, E) ∞ ((↑) : sphere (0 : E) 1 → E) := by
  -- Porting note: trouble with filling these implicit variables in the instance
  have := smoothMfldWithCorners (E := E) (n := n)
  rw [contMDiff_iff]
  constructor
  · exact continuous_subtype_val
  · 

Proof state:
case right
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace ℝ E
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
this : SmoothManifoldWithCorners 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) ↑(sphere 0 1)
⊢ ∀ (x : { x // x ∈ sphere 0 1 }) (y : E),
    ContDiffOn ℝ ⊤
      (↑(extChartAt 𝓘(ℝ, E) y) ∘ Subtype.val ∘ ↑(PartialEquiv.symm (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) x)))
      ((extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) x).target ∩
        ↑(PartialEquiv.symm (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) x)) ⁻¹'
          (Subtype.val ⁻¹' (extChartAt 𝓘(ℝ, E) y).source))

Next tactic:
intro v _
/-- The inclusion map (i.e., `coe`) from the sphere in `E` to `E` is smooth.  -/
theorem contMDiff_coe_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] :
    ContMDiff (𝓡 n) 𝓘(ℝ, E) ∞ ((↑) : sphere (0 : E) 1 → E) := by
  -- Porting note: trouble with filling these implicit variables in the instance
  have := smoothMfldWithCorners (E := E) (n := n)
  rw [contMDiff_iff]
  constructor
  · exact continuous_subtype_val
  · intro v _
    

Proof state:
case right
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace ℝ E
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
this : SmoothManifoldWithCorners 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) ↑(sphere 0 1)
v : { x // x ∈ sphere 0 1 }
y✝ : E
⊢ ContDiffOn ℝ ⊤
    (↑(extChartAt 𝓘(ℝ, E) y✝) ∘ Subtype.val ∘ ↑(PartialEquiv.symm (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v)))
    ((extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v).target ∩
      ↑(PartialEquiv.symm (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v)) ⁻¹'
        (Subtype.val ⁻¹' (extChartAt 𝓘(ℝ, E) y✝).source))

Next tactic:
let U : _ ≃ₗᵢ[ℝ] _ :=
      (-- Again, partially removing type ascription...
          OrthonormalBasis.fromOrthogonalSpanSingleton
          n (ne_zero_of_mem_unit_sphere (-v))).repr
/-- The inclusion map (i.e., `coe`) from the sphere in `E` to `E` is smooth.  -/
theorem contMDiff_coe_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] :
    ContMDiff (𝓡 n) 𝓘(ℝ, E) ∞ ((↑) : sphere (0 : E) 1 → E) := by
  -- Porting note: trouble with filling these implicit variables in the instance
  have := smoothMfldWithCorners (E := E) (n := n)
  rw [contMDiff_iff]
  constructor
  · exact continuous_subtype_val
  · intro v _
    let U : _ ≃ₗᵢ[ℝ] _ :=
      (-- Again, partially removing type ascription...
          OrthonormalBasis.fromOrthogonalSpanSingleton
          n (ne_zero_of_mem_unit_sphere (-v))).repr
    

Proof state:
case right
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace ℝ E
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
this : SmoothManifoldWithCorners 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) ↑(sphere 0 1)
v : { x // x ∈ sphere 0 1 }
y✝ : E
U : ↥(Submodule.span ℝ {↑(-v)})ᗮ ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n) :=
  (OrthonormalBasis.fromOrthogonalSpanSingleton n (_ : ↑(-v) ≠ 0)).repr
⊢ ContDiffOn ℝ ⊤
    (↑(extChartAt 𝓘(ℝ, E) y✝) ∘ Subtype.val ∘ ↑(PartialEquiv.symm (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v)))
    ((extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v).target ∩
      ↑(PartialEquiv.symm (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v)) ⁻¹'
        (Subtype.val ⁻¹' (extChartAt 𝓘(ℝ, E) y✝).source))

Next tactic:
exact
      ((contDiff_stereoInvFunAux.comp (ℝ ∙ (-v : E))ᗮ.subtypeL.contDiff).comp
          U.symm.contDiff).contDiffOn
/-- If a `ContMDiff` function `f : M → E`, where `M` is some manifold, takes values in the
sphere, then it restricts to a `ContMDiff` function from `M` to the sphere. -/
theorem ContMDiff.codRestrict_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] {m : ℕ∞} {f : M → E}
    (hf : ContMDiff I 𝓘(ℝ, E) m f) (hf' : ∀ x, f x ∈ sphere (0 : E) 1) :
    ContMDiff I (𝓡 n) m (Set.codRestrict _ _ hf' : M → sphere (0 : E) 1) := by
  

Proof state:
E : Type u_1
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : InnerProductSpace ℝ E
F : Type u_2
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace ℝ F
H : Type u_3
inst✝⁴ : TopologicalSpace H
I : ModelWithCorners ℝ F H
M : Type u_4
inst✝³ : TopologicalSpace M
inst✝² : ChartedSpace H M
inst✝¹ : SmoothManifoldWithCorners I M
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
m : ℕ∞
f : M → E
hf : ContMDiff I 𝓘(ℝ, E) m f
hf' : ∀ (x : M), f x ∈ sphere 0 1
⊢ ContMDiff I 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) m (Set.codRestrict (fun x => f x) (sphere 0 1) hf')

Next tactic:
rw [contMDiff_iff_target]
/-- If a `ContMDiff` function `f : M → E`, where `M` is some manifold, takes values in the
sphere, then it restricts to a `ContMDiff` function from `M` to the sphere. -/
theorem ContMDiff.codRestrict_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] {m : ℕ∞} {f : M → E}
    (hf : ContMDiff I 𝓘(ℝ, E) m f) (hf' : ∀ x, f x ∈ sphere (0 : E) 1) :
    ContMDiff I (𝓡 n) m (Set.codRestrict _ _ hf' : M → sphere (0 : E) 1) := by
  rw [contMDiff_iff_target]
  

Proof state:
E : Type u_1
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : InnerProductSpace ℝ E
F : Type u_2
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace ℝ F
H : Type u_3
inst✝⁴ : TopologicalSpace H
I : ModelWithCorners ℝ F H
M : Type u_4
inst✝³ : TopologicalSpace M
inst✝² : ChartedSpace H M
inst✝¹ : SmoothManifoldWithCorners I M
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
m : ℕ∞
f : M → E
hf : ContMDiff I 𝓘(ℝ, E) m f
hf' : ∀ (x : M), f x ∈ sphere 0 1
⊢ Continuous (Set.codRestrict (fun x => f x) (sphere 0 1) hf') ∧
    ∀ (y : ↑(sphere 0 1)),
      ContMDiffOn I 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) m
        (↑(extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) y) ∘ Set.codRestrict (fun x => f x) (sphere 0 1) hf')
        (Set.codRestrict (fun x => f x) (sphere 0 1) hf' ⁻¹' (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) y).source)

Next tactic:
refine' ⟨continuous_induced_rng.2 hf.continuous, _⟩
/-- If a `ContMDiff` function `f : M → E`, where `M` is some manifold, takes values in the
sphere, then it restricts to a `ContMDiff` function from `M` to the sphere. -/
theorem ContMDiff.codRestrict_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] {m : ℕ∞} {f : M → E}
    (hf : ContMDiff I 𝓘(ℝ, E) m f) (hf' : ∀ x, f x ∈ sphere (0 : E) 1) :
    ContMDiff I (𝓡 n) m (Set.codRestrict _ _ hf' : M → sphere (0 : E) 1) := by
  rw [contMDiff_iff_target]
  refine' ⟨continuous_induced_rng.2 hf.continuous, _⟩
  

Proof state:
E : Type u_1
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : InnerProductSpace ℝ E
F : Type u_2
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace ℝ F
H : Type u_3
inst✝⁴ : TopologicalSpace H
I : ModelWithCorners ℝ F H
M : Type u_4
inst✝³ : TopologicalSpace M
inst✝² : ChartedSpace H M
inst✝¹ : SmoothManifoldWithCorners I M
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
m : ℕ∞
f : M → E
hf : ContMDiff I 𝓘(ℝ, E) m f
hf' : ∀ (x : M), f x ∈ sphere 0 1
⊢ ∀ (y : ↑(sphere 0 1)),
    ContMDiffOn I 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) m
      (↑(extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) y) ∘ Set.codRestrict (fun x => f x) (sphere 0 1) hf')
      (Set.codRestrict (fun x => f x) (sphere 0 1) hf' ⁻¹' (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) y).source)

Next tactic:
intro v
/-- If a `ContMDiff` function `f : M → E`, where `M` is some manifold, takes values in the
sphere, then it restricts to a `ContMDiff` function from `M` to the sphere. -/
theorem ContMDiff.codRestrict_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] {m : ℕ∞} {f : M → E}
    (hf : ContMDiff I 𝓘(ℝ, E) m f) (hf' : ∀ x, f x ∈ sphere (0 : E) 1) :
    ContMDiff I (𝓡 n) m (Set.codRestrict _ _ hf' : M → sphere (0 : E) 1) := by
  rw [contMDiff_iff_target]
  refine' ⟨continuous_induced_rng.2 hf.continuous, _⟩
  intro v
  

Proof state:
E : Type u_1
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : InnerProductSpace ℝ E
F : Type u_2
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace ℝ F
H : Type u_3
inst✝⁴ : TopologicalSpace H
I : ModelWithCorners ℝ F H
M : Type u_4
inst✝³ : TopologicalSpace M
inst✝² : ChartedSpace H M
inst✝¹ : SmoothManifoldWithCorners I M
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
m : ℕ∞
f : M → E
hf : ContMDiff I 𝓘(ℝ, E) m f
hf' : ∀ (x : M), f x ∈ sphere 0 1
v : ↑(sphere 0 1)
⊢ ContMDiffOn I 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) m
    (↑(extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v) ∘ Set.codRestrict (fun x => f x) (sphere 0 1) hf')
    (Set.codRestrict (fun x => f x) (sphere 0 1) hf' ⁻¹' (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v).source)

Next tactic:
let U : _ ≃ₗᵢ[ℝ] _ :=
    (-- Again, partially removing type ascription... Weird that this helps!
        OrthonormalBasis.fromOrthogonalSpanSingleton
        n (ne_zero_of_mem_unit_sphere (-v))).repr
/-- If a `ContMDiff` function `f : M → E`, where `M` is some manifold, takes values in the
sphere, then it restricts to a `ContMDiff` function from `M` to the sphere. -/
theorem ContMDiff.codRestrict_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] {m : ℕ∞} {f : M → E}
    (hf : ContMDiff I 𝓘(ℝ, E) m f) (hf' : ∀ x, f x ∈ sphere (0 : E) 1) :
    ContMDiff I (𝓡 n) m (Set.codRestrict _ _ hf' : M → sphere (0 : E) 1) := by
  rw [contMDiff_iff_target]
  refine' ⟨continuous_induced_rng.2 hf.continuous, _⟩
  intro v
  let U : _ ≃ₗᵢ[ℝ] _ :=
    (-- Again, partially removing type ascription... Weird that this helps!
        OrthonormalBasis.fromOrthogonalSpanSingleton
        n (ne_zero_of_mem_unit_sphere (-v))).repr
  

Proof state:
E : Type u_1
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : InnerProductSpace ℝ E
F : Type u_2
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace ℝ F
H : Type u_3
inst✝⁴ : TopologicalSpace H
I : ModelWithCorners ℝ F H
M : Type u_4
inst✝³ : TopologicalSpace M
inst✝² : ChartedSpace H M
inst✝¹ : SmoothManifoldWithCorners I M
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
m : ℕ∞
f : M → E
hf : ContMDiff I 𝓘(ℝ, E) m f
hf' : ∀ (x : M), f x ∈ sphere 0 1
v : ↑(sphere 0 1)
U : ↥(Submodule.span ℝ {↑(-v)})ᗮ ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n) :=
  (OrthonormalBasis.fromOrthogonalSpanSingleton n (_ : ↑(-v) ≠ 0)).repr
⊢ ContMDiffOn I 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) m
    (↑(extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v) ∘ Set.codRestrict (fun x => f x) (sphere 0 1) hf')
    (Set.codRestrict (fun x => f x) (sphere 0 1) hf' ⁻¹' (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v).source)

Next tactic:
have h : ContDiffOn ℝ ⊤ _ Set.univ := U.contDiff.contDiffOn
/-- If a `ContMDiff` function `f : M → E`, where `M` is some manifold, takes values in the
sphere, then it restricts to a `ContMDiff` function from `M` to the sphere. -/
theorem ContMDiff.codRestrict_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] {m : ℕ∞} {f : M → E}
    (hf : ContMDiff I 𝓘(ℝ, E) m f) (hf' : ∀ x, f x ∈ sphere (0 : E) 1) :
    ContMDiff I (𝓡 n) m (Set.codRestrict _ _ hf' : M → sphere (0 : E) 1) := by
  rw [contMDiff_iff_target]
  refine' ⟨continuous_induced_rng.2 hf.continuous, _⟩
  intro v
  let U : _ ≃ₗᵢ[ℝ] _ :=
    (-- Again, partially removing type ascription... Weird that this helps!
        OrthonormalBasis.fromOrthogonalSpanSingleton
        n (ne_zero_of_mem_unit_sphere (-v))).repr
  have h : ContDiffOn ℝ ⊤ _ Set.univ := U.contDiff.contDiffOn
  

Proof state:
E : Type u_1
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : InnerProductSpace ℝ E
F : Type u_2
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace ℝ F
H : Type u_3
inst✝⁴ : TopologicalSpace H
I : ModelWithCorners ℝ F H
M : Type u_4
inst✝³ : TopologicalSpace M
inst✝² : ChartedSpace H M
inst✝¹ : SmoothManifoldWithCorners I M
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
m : ℕ∞
f : M → E
hf : ContMDiff I 𝓘(ℝ, E) m f
hf' : ∀ (x : M), f x ∈ sphere 0 1
v : ↑(sphere 0 1)
U : ↥(Submodule.span ℝ {↑(-v)})ᗮ ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n) :=
  (OrthonormalBasis.fromOrthogonalSpanSingleton n (_ : ↑(-v) ≠ 0)).repr
h : ContDiffOn ℝ ⊤ (⇑U) Set.univ
⊢ ContMDiffOn I 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) m
    (↑(extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v) ∘ Set.codRestrict (fun x => f x) (sphere 0 1) hf')
    (Set.codRestrict (fun x => f x) (sphere 0 1) hf' ⁻¹' (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v).source)

Next tactic:
have H₁ := (h.comp' contDiffOn_stereoToFun).contMDiffOn
/-- If a `ContMDiff` function `f : M → E`, where `M` is some manifold, takes values in the
sphere, then it restricts to a `ContMDiff` function from `M` to the sphere. -/
theorem ContMDiff.codRestrict_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] {m : ℕ∞} {f : M → E}
    (hf : ContMDiff I 𝓘(ℝ, E) m f) (hf' : ∀ x, f x ∈ sphere (0 : E) 1) :
    ContMDiff I (𝓡 n) m (Set.codRestrict _ _ hf' : M → sphere (0 : E) 1) := by
  rw [contMDiff_iff_target]
  refine' ⟨continuous_induced_rng.2 hf.continuous, _⟩
  intro v
  let U : _ ≃ₗᵢ[ℝ] _ :=
    (-- Again, partially removing type ascription... Weird that this helps!
        OrthonormalBasis.fromOrthogonalSpanSingleton
        n (ne_zero_of_mem_unit_sphere (-v))).repr
  have h : ContDiffOn ℝ ⊤ _ Set.univ := U.contDiff.contDiffOn
  have H₁ := (h.comp' contDiffOn_stereoToFun).contMDiffOn
  

Proof state:
E : Type u_1
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : InnerProductSpace ℝ E
F : Type u_2
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace ℝ F
H : Type u_3
inst✝⁴ : TopologicalSpace H
I : ModelWithCorners ℝ F H
M : Type u_4
inst✝³ : TopologicalSpace M
inst✝² : ChartedSpace H M
inst✝¹ : SmoothManifoldWithCorners I M
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
m : ℕ∞
f : M → E
hf : ContMDiff I 𝓘(ℝ, E) m f
hf' : ∀ (x : M), f x ∈ sphere 0 1
v : ↑(sphere 0 1)
U : ↥(Submodule.span ℝ {↑(-v)})ᗮ ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n) :=
  (OrthonormalBasis.fromOrthogonalSpanSingleton n (_ : ↑(-v) ≠ 0)).repr
h : ContDiffOn ℝ ⊤ (⇑U) Set.univ
H₁ :
  ContMDiffOn 𝓘(ℝ, E) 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) ⊤ (⇑U ∘ stereoToFun ↑(-v))
    ({x | ((innerSL ℝ) ↑(-v)) x ≠ 1} ∩ stereoToFun ↑(-v) ⁻¹' Set.univ)
⊢ ContMDiffOn I 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) m
    (↑(extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v) ∘ Set.codRestrict (fun x => f x) (sphere 0 1) hf')
    (Set.codRestrict (fun x => f x) (sphere 0 1) hf' ⁻¹' (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v).source)

Next tactic:
have H₂ : ContMDiffOn _ _ _ _ Set.univ := hf.contMDiffOn
/-- If a `ContMDiff` function `f : M → E`, where `M` is some manifold, takes values in the
sphere, then it restricts to a `ContMDiff` function from `M` to the sphere. -/
theorem ContMDiff.codRestrict_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] {m : ℕ∞} {f : M → E}
    (hf : ContMDiff I 𝓘(ℝ, E) m f) (hf' : ∀ x, f x ∈ sphere (0 : E) 1) :
    ContMDiff I (𝓡 n) m (Set.codRestrict _ _ hf' : M → sphere (0 : E) 1) := by
  rw [contMDiff_iff_target]
  refine' ⟨continuous_induced_rng.2 hf.continuous, _⟩
  intro v
  let U : _ ≃ₗᵢ[ℝ] _ :=
    (-- Again, partially removing type ascription... Weird that this helps!
        OrthonormalBasis.fromOrthogonalSpanSingleton
        n (ne_zero_of_mem_unit_sphere (-v))).repr
  have h : ContDiffOn ℝ ⊤ _ Set.univ := U.contDiff.contDiffOn
  have H₁ := (h.comp' contDiffOn_stereoToFun).contMDiffOn
  have H₂ : ContMDiffOn _ _ _ _ Set.univ := hf.contMDiffOn
  

Proof state:
E : Type u_1
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : InnerProductSpace ℝ E
F : Type u_2
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace ℝ F
H : Type u_3
inst✝⁴ : TopologicalSpace H
I : ModelWithCorners ℝ F H
M : Type u_4
inst✝³ : TopologicalSpace M
inst✝² : ChartedSpace H M
inst✝¹ : SmoothManifoldWithCorners I M
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
m : ℕ∞
f : M → E
hf : ContMDiff I 𝓘(ℝ, E) m f
hf' : ∀ (x : M), f x ∈ sphere 0 1
v : ↑(sphere 0 1)
U : ↥(Submodule.span ℝ {↑(-v)})ᗮ ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n) :=
  (OrthonormalBasis.fromOrthogonalSpanSingleton n (_ : ↑(-v) ≠ 0)).repr
h : ContDiffOn ℝ ⊤ (⇑U) Set.univ
H₁ :
  ContMDiffOn 𝓘(ℝ, E) 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) ⊤ (⇑U ∘ stereoToFun ↑(-v))
    ({x | ((innerSL ℝ) ↑(-v)) x ≠ 1} ∩ stereoToFun ↑(-v) ⁻¹' Set.univ)
H₂ : ContMDiffOn I 𝓘(ℝ, E) m f Set.univ
⊢ ContMDiffOn I 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) m
    (↑(extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v) ∘ Set.codRestrict (fun x => f x) (sphere 0 1) hf')
    (Set.codRestrict (fun x => f x) (sphere 0 1) hf' ⁻¹' (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v).source)

Next tactic:
convert (H₁.of_le le_top).comp' H₂ using 1
/-- If a `ContMDiff` function `f : M → E`, where `M` is some manifold, takes values in the
sphere, then it restricts to a `ContMDiff` function from `M` to the sphere. -/
theorem ContMDiff.codRestrict_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] {m : ℕ∞} {f : M → E}
    (hf : ContMDiff I 𝓘(ℝ, E) m f) (hf' : ∀ x, f x ∈ sphere (0 : E) 1) :
    ContMDiff I (𝓡 n) m (Set.codRestrict _ _ hf' : M → sphere (0 : E) 1) := by
  rw [contMDiff_iff_target]
  refine' ⟨continuous_induced_rng.2 hf.continuous, _⟩
  intro v
  let U : _ ≃ₗᵢ[ℝ] _ :=
    (-- Again, partially removing type ascription... Weird that this helps!
        OrthonormalBasis.fromOrthogonalSpanSingleton
        n (ne_zero_of_mem_unit_sphere (-v))).repr
  have h : ContDiffOn ℝ ⊤ _ Set.univ := U.contDiff.contDiffOn
  have H₁ := (h.comp' contDiffOn_stereoToFun).contMDiffOn
  have H₂ : ContMDiffOn _ _ _ _ Set.univ := hf.contMDiffOn
  convert (H₁.of_le le_top).comp' H₂ using 1
  

Proof state:
case h.e'_23
E : Type u_1
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : InnerProductSpace ℝ E
F : Type u_2
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace ℝ F
H : Type u_3
inst✝⁴ : TopologicalSpace H
I : ModelWithCorners ℝ F H
M : Type u_4
inst✝³ : TopologicalSpace M
inst✝² : ChartedSpace H M
inst✝¹ : SmoothManifoldWithCorners I M
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
m : ℕ∞
f : M → E
hf : ContMDiff I 𝓘(ℝ, E) m f
hf' : ∀ (x : M), f x ∈ sphere 0 1
v : ↑(sphere 0 1)
U : ↥(Submodule.span ℝ {↑(-v)})ᗮ ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n) :=
  (OrthonormalBasis.fromOrthogonalSpanSingleton n (_ : ↑(-v) ≠ 0)).repr
h : ContDiffOn ℝ ⊤ (⇑U) Set.univ
H₁ :
  ContMDiffOn 𝓘(ℝ, E) 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) ⊤ (⇑U ∘ stereoToFun ↑(-v))
    ({x | ((innerSL ℝ) ↑(-v)) x ≠ 1} ∩ stereoToFun ↑(-v) ⁻¹' Set.univ)
H₂ : ContMDiffOn I 𝓘(ℝ, E) m f Set.univ
⊢ Set.codRestrict (fun x => f x) (sphere 0 1) hf' ⁻¹' (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v).source =
    Set.univ ∩ f ⁻¹' ({x | ((innerSL ℝ) ↑(-v)) x ≠ 1} ∩ stereoToFun ↑(-v) ⁻¹' Set.univ)

Next tactic:
ext x
/-- If a `ContMDiff` function `f : M → E`, where `M` is some manifold, takes values in the
sphere, then it restricts to a `ContMDiff` function from `M` to the sphere. -/
theorem ContMDiff.codRestrict_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] {m : ℕ∞} {f : M → E}
    (hf : ContMDiff I 𝓘(ℝ, E) m f) (hf' : ∀ x, f x ∈ sphere (0 : E) 1) :
    ContMDiff I (𝓡 n) m (Set.codRestrict _ _ hf' : M → sphere (0 : E) 1) := by
  rw [contMDiff_iff_target]
  refine' ⟨continuous_induced_rng.2 hf.continuous, _⟩
  intro v
  let U : _ ≃ₗᵢ[ℝ] _ :=
    (-- Again, partially removing type ascription... Weird that this helps!
        OrthonormalBasis.fromOrthogonalSpanSingleton
        n (ne_zero_of_mem_unit_sphere (-v))).repr
  have h : ContDiffOn ℝ ⊤ _ Set.univ := U.contDiff.contDiffOn
  have H₁ := (h.comp' contDiffOn_stereoToFun).contMDiffOn
  have H₂ : ContMDiffOn _ _ _ _ Set.univ := hf.contMDiffOn
  convert (H₁.of_le le_top).comp' H₂ using 1
  ext x
  

Proof state:
case h.e'_23.h
E : Type u_1
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : InnerProductSpace ℝ E
F : Type u_2
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace ℝ F
H : Type u_3
inst✝⁴ : TopologicalSpace H
I : ModelWithCorners ℝ F H
M : Type u_4
inst✝³ : TopologicalSpace M
inst✝² : ChartedSpace H M
inst✝¹ : SmoothManifoldWithCorners I M
n : ℕ
inst✝ : Fact (finrank ℝ E = n + 1)
m : ℕ∞
f : M → E
hf : ContMDiff I 𝓘(ℝ, E) m f
hf' : ∀ (x : M), f x ∈ sphere 0 1
v : ↑(sphere 0 1)
U : ↥(Submodule.span ℝ {↑(-v)})ᗮ ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n) :=
  (OrthonormalBasis.fromOrthogonalSpanSingleton n (_ : ↑(-v) ≠ 0)).repr
h : ContDiffOn ℝ ⊤ (⇑U) Set.univ
H₁ :
  ContMDiffOn 𝓘(ℝ, E) 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) ⊤ (⇑U ∘ stereoToFun ↑(-v))
    ({x | ((innerSL ℝ) ↑(-v)) x ≠ 1} ∩ stereoToFun ↑(-v) ⁻¹' Set.univ)
H₂ : ContMDiffOn I 𝓘(ℝ, E) m f Set.univ
x : M
⊢ x ∈ Set.codRestrict (fun x => f x) (sphere 0 1) hf' ⁻¹' (extChartAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) v).source ↔
    x ∈ Set.univ ∩ f ⁻¹' ({x | ((innerSL ℝ) ↑(-v)) x ≠ 1} ∩ stereoToFun ↑(-v) ⁻¹' Set.univ)

Next tactic:
have hfxv : f x = -↑v ↔ ⟪f x, -↑v⟫_ℝ = 1 := by
    have hfx : ‖f x‖ = 1 := by simpa using hf' x
    rw [inner_eq_one_iff_of_norm_one hfx]
    exact norm_eq_of_mem_sphere (-v)