File size: 21,321 Bytes
4a56cd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
/-
Copyright 2026 The Formal Conjectures Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This file has been modified.
-/
import OAI.AlgebraicGeometry.Foundations.ProjectiveSpaceIs
import Mathlib.Algebra.Category.Ring.Topology
import Mathlib.AlgebraicGeometry.Noetherian
import Mathlib.Analysis.Complex.Basic
import Mathlib.RingTheory.Valuation.ValuationRing
import Mathlib.Topology.Algebra.IsOpenUnits
import OAI.CategoryTheory.ConcreteCategory.Notation
import OAI.Topology.Algebra.IsOpenUnits

/-! # Basic -/

namespace OAI.AlgebraicGeometry.ComplexPoint.Basic

open _root_.AlgebraicGeometry

/-!
# Points over a commutative ring, and analytification

For a scheme `X: Over (Spec R)` over a commutative ring `R`, an `R`-point is a morphism
`Over.mk (𝟙 (Spec R)) ⟶ X`. The structure map is bundled with `X`, and `map` is composition
in this over category. These constructions require only that `R` is a commutative ring.

Everything that speaks of *the* point underlying an `R`-point needs `Spec R` to have a unique
closed point, so from `stalkData` onwards `R` is local. An `R`-point then determines a scheme point
together with a local homomorphism out of the stalk there, and evaluating the sections on an open
`U` containing it gives a ring homomorphism `Γ(X.left, U) ⟶ ↧R`. Over an affine open this
identifies the `R`-points with a subspace of that hom set, which carries Mathlib's topology of
pointwise convergence; the analytic topology is the topology glued from these affine charts. It exists as
soon as multiplication on `R` is continuous and the units of `R` are open, so it applies to `ℝ`,
to a `p`-adic field, and to `ℤ_p` alike.

`analyticTopology_eq_generateFrom` identifies it with the more elementary description: the
topology generated by the sets on which a local regular function takes values in a prescribed open
subset of `R`.

Over a field the stalk homomorphism factors through the residue field, which is the classical
description; `residueData` and the lemmas beside it record it, and there nonvanishing replaces
invertibility.

Complex points are the case `K = ℂ`. Analytification is then packaged as a functor from schemes
over `Spec ℂ` to topological spaces, so that singular (co)homology of a complex variety is Mathlib's
singular (co)homology of the resulting space.

`isNoetherian_of_isProjective` records that a projective complex scheme is Noetherian.
-/

open _root_.CategoryTheory _root_.Topology
open scoped CommRingCat.HomTopology

variable (R : Type) [CommRing R]

/-- Let `R` be a commutative ring and `X` a scheme over `Spec R`. An `R`-point of `X` is a morphism
`Spec R → X` whose composite with the structure map `X → Spec R` is the identity. -/
abbrev Point (X : Over (Spec ↧R)) :=
  Over.mk (𝟙 (Spec ↧R)) ⟶ X

namespace Point

variable {R}

section Functoriality

variable {X Y Z : Over (Spec ↧R)}

/-- Let `R` be a commutative ring and `f: X → Y` a morphism of schemes over `Spec R`. This sends an
`R`-point `z: Spec R → X` to the composite `f ∘ z: Spec R → Y`. -/
noncomputable def map (f : X ⟶ Y) : Point R X → Point R Y :=
  fun z ↦ z ≫ f

/-- The identity scheme morphism induces the identity on `R`-points. -/
@[simp]
lemma map_id (z : Point R X) : Point.map (𝟙 X) z = z := rfl

/-- Composition of scheme morphisms agrees with composition on `R`-points. -/
@[simp]
lemma map_comp_apply (f : X ⟶ Y) (g : Y ⟶ Z) (z : Point R X) :
    Point.map (f ≫ g) z = Point.map g (Point.map f z) := rfl

end Functoriality

variable [IsLocalRing R] {X : Over (Spec ↧R)}

/-- Let `R` be a commutative local ring and `X` a scheme over `Spec R`. An `R`-point `z: Spec R →
X` determines the image `x` of the unique closed point of `Spec R` and a local ring homomorphism
`𝒪_{X,x} → R`. This is that pair, with the assertion that the homomorphism is local. -/
noncomputable def stalkData (z : Point R X) :
    Σ x : X.left, {f : X.left.presheaf.stalk x ⟶ ↧R // IsLocalHom f.hom} :=
  SpecToEquivOfLocalRing X.left ↧R z.left

/-- Let `R` be a commutative local ring and `X` a scheme over `Spec R`. For an `R`-point `z: Spec R
→ X`, this is the image in `X` of the unique closed point of `Spec R`. -/
noncomputable def underlying (z : Point R X) : X.left := z.stalkData.1

/-- Let `R` be a commutative local ring and `X` a scheme over `Spec R`. For an `R`-point `z: Spec R
→ X`, let `x` be the image of the closed point of `Spec R`. This is the induced local
homomorphism `𝒪_{X,x} → R` from the stalk of the structure sheaf. -/
noncomputable def stalkHom (z : Point R X) :
    X.left.presheaf.stalk z.underlying ⟶ ↧R := z.stalkData.2.1

instance (z : Point R X) : IsLocalHom z.stalkHom.hom := z.stalkData.2.2

/-- Let `R` be a commutative local ring and `X` a scheme over `Spec R`. For a Zariski open `U ⊆ X`,
this is the set of `R`-points `z: Spec R → X` that send the unique closed point of `Spec R`
into `U`. -/
noncomputable def overOpen (U : X.left.Opens) : Set (Point R X) :=
  {z | z.underlying ∈ U}

/-- Let `R` be a commutative local ring and `X` a scheme over `Spec R`. For a Zariski open `U ⊆ X`,
this is the type of `R`-points together with the condition that the image of the closed point of
`Spec R` lies in `U`. -/
abbrev OverOpen (U : X.left.Opens) := {z : Point R X // z.underlying ∈ U}

open scoped Classical in
/-- Let `R` be a commutative local ring and `X` a scheme over `Spec R`. For a regular function `s`
on a Zariski open `U` and an `R`-point `z`, evaluate the germ of `s` using the stalk
homomorphism `𝒪_{X,x} → R` induced by `z` if its underlying point `x` is in `U`. The value is
defined to be zero when `x ∉ U`. -/
noncomputable def evaluate (U : X.left.Opens) (s : Γ(X.left, U))
    (z : Point R X) : R :=
  if hz : z.underlying ∈ U then z.stalkHom (X.left.presheaf.germ U z.underlying hz s) else 0

/-- Restricting a regular function does not change its value at a point in the smaller open. -/
lemma evaluate_res {U V : X.left.Opens} (hVU : V ≤ U) (s : Γ(X.left, U))
    (z : Point R X) (hz : z ∈ overOpen V) :
    evaluate U s z = evaluate V (X.left.presheaf.map (homOfLE hVU).op s) z := by
  rw [evaluate, dite_eq_left (show z.underlying ∈ U from hVU hz), evaluate,
    dite_eq_left (show z.underlying ∈ V from hz)]
  congr 1
  exact (X.left.presheaf.germ_res_apply (homOfLE hVU) z.underlying hz s).symm

/-- An `R`-point belongs to a principal open exactly when its defining function evaluates to a
unit there.

Over a field this is nonvanishing; see `mem_overOpen_basicOpen_iff_evaluate_ne_zero`. -/
lemma mem_overOpen_basicOpen_iff_isUnit_evaluate {U : X.left.Opens} (s : Γ(X.left, U))
    (z : Point R X) (hz : z ∈ overOpen U) :
    z ∈ overOpen (X.left.basicOpen s) ↔ IsUnit (evaluate U s z) := by
  rw [evaluate, dite_eq_left (show z.underlying ∈ U from hz)]
  rw [isUnit_map_iff z.stalkHom.hom]
  exact X.left.mem_basicOpen s z.underlying hz

/-- Let `R` be a commutative local ring and `X` a scheme over `Spec R`. For an `R`-point with
underlying point `x` in the Zariski open `U`, this ring homomorphism `Γ(U, 𝒪_X) → R` first takes
the germ at `x` and then applies the stalk map induced by the point. -/
noncomputable def evaluationHom (U : X.left.Opens)
    (z : OverOpen (X := X) U) : Γ(X.left, U) ⟶ ↧R :=
  X.left.presheaf.germ U z.1.underlying z.2 ≫ z.1.stalkHom

@[simp]
lemma evaluationHom_apply (U : X.left.Opens) (z : OverOpen (X := X) U)
    (s : Γ(X.left, U)) : evaluationHom U z s = evaluate U s z.1 := by
  rw [evaluate, dite_eq_left z.2]
  rfl

/-- On an affine open, a regular function on a principal open is, at every `R`-point of that
principal open, a regular function on the whole affine open divided by a power of the defining
function.

Over a field this reads as an honest quotient; see `exists_evaluate_basicOpen_eq_div`. -/
lemma exists_evaluate_basicOpen_eq_inverse_mul {U : X.left.Opens} (hU : IsAffineOpen U)
    (f : Γ(X.left, U)) (t : Γ(X.left, X.left.basicOpen f)) :
    ∃ (k : ℕ) (a : Γ(X.left, U)), ∀ z : Point R X,
      z ∈ overOpen (X.left.basicOpen f) →
        evaluate (X.left.basicOpen f) t z =
          Ring.inverse (evaluate U f z ^ k) * evaluate U a z := by
  let := hU.isLocalization_basicOpen f
  obtain ⟨k, a, hta⟩ := IsLocalization.Away.surj f t
  refine ⟨k, a, fun z hz ↦ ?_⟩
  have hzU : z ∈ overOpen U := X.left.basicOpen_le f hz
  have hunit : IsUnit (evaluate U f z) :=
    (mem_overOpen_basicOpen_iff_isUnit_evaluate f z hzU).mp hz
  have key : evaluate (X.left.basicOpen f) t z * evaluate U f z ^ k = evaluate U a z := by
    have hz' : z.underlying ∈ X.left.basicOpen f := hz
    let ψ : Γ(X.left, X.left.basicOpen f) →+* R := (evaluationHom (X.left.basicOpen f) ⟨z, hz⟩).hom
    have hmap := congrArg ψ hta
    rw [evaluate_res (X.left.basicOpen_le f) f z hz, evaluate_res (X.left.basicOpen_le f) a z hz]
    simp only [evaluate, dite_eq_left hz']
    change ψ t * ψ (algebraMap _ _ f) ^ k = ψ (algebraMap _ _ a)
    simpa using hmap
  rw [← key, mul_comm (evaluate (X.left.basicOpen f) t z), ← mul_assoc,
    Ring.inverse_mul_cancel _ (hunit.pow k), one_mul]

@[simp]
lemma underlying_map {Y : Over (Spec ↧R)} (f : X ⟶ Y) (z : Point R X) :
    (Point.map f z).underlying = f.left z.underlying := rfl

/-- The stalk homomorphism of the image of an `R`-point is obtained functorially. -/
private lemma stalkHom_map {Y : Over (Spec ↧R)} (f : X ⟶ Y) (z : Point R X) :
    (Point.map f z).stalkHom = f.left.stalkMap z.underlying ≫ z.stalkHom :=
  Scheme.stalkClosedPointTo_comp _ _

/-- Pulling back a scheme open commutes with passage to `R`-points. -/
lemma mem_overOpen_map_iff {Y : Over (Spec ↧R)} (f : X ⟶ Y)
    (z : Point R X) (U : Y.left.Opens) :
    Point.map f z ∈ overOpen U ↔ z ∈ overOpen (f.left ⁻¹ᵁ U) := by
  simp [overOpen]

/-- Evaluation of a pulled-back regular function agrees with evaluation after mapping the point. -/
lemma evaluate_map {Y : Over (Spec ↧R)} (f : X ⟶ Y)
    (U : Y.left.Opens) (s : Γ(Y.left, U)) (z : Point R X) :
    evaluate U s (Point.map f z) = evaluate (f.left ⁻¹ᵁ U) (f.left.app U s) z := by
  by_cases hx : z.underlying ∈ f.left ⁻¹ᵁ U
  · have hy : f.left z.underlying ∈ U := hx
    rw [evaluate, dite_eq_left (show (Point.map f z).underlying ∈ U from hy), evaluate,
      dite_eq_left (show z.underlying ∈ f.left ⁻¹ᵁ U from hx), stalkHom_map]
    exact congrArg (CommRingCat.Hom.hom z.stalkHom)
      (f.left.germ_stalkMap_apply U z.underlying hy s)
  · have hy : f.left z.underlying ∉ U := hx
    rw [evaluate, dite_eq_right (show ¬ (Point.map f z).underlying ∈ U from hy), evaluate,
      dite_eq_right (show ¬ z.underlying ∈ f.left ⁻¹ᵁ U from hx)]

variable [TopologicalSpace R]

/-- Let `R` be a commutative local ring with a topology and `X` a scheme over `Spec R`. On the
`R`-points whose underlying points lie in the open `U`, this is the topology induced by
evaluation into `Hom(Γ(U, 𝒪_X), R)`. The homomorphism space has the topology of pointwise
convergence on regular functions. -/
@[instance_reducible]
noncomputable def chartTopology (U : X.left.Opens) :
    TopologicalSpace (OverOpen (X := X) U) :=
  .induced (evaluationHom U) inferInstance

/-- Let `R` be a commutative local ring with a topology and `X` a scheme over `Spec R`. This family
consists of sets `{z | underlying(z) ∈ U and s(z) ∈ V}`, where `U` is Zariski open in `X`, `s` a
regular function on `U`, and `V` open in `R`. These sets specify local conditions on values of
regular functions. -/
noncomputable def analyticSubbasis : Set (Set (Point R X)) :=
  {W | ∃ (U : X.left.Opens) (s : Γ(X.left, U)) (V : Set R), IsOpen V ∧
    W = overOpen U ∩ evaluate U s ⁻¹' V}

/-- Let `R` be a commutative local ring with a topology and `X` a scheme over `Spec R`. Give the
points over each affine open the topology of pointwise convergence of regular-function
evaluations. This is the topology on all `R`-points obtained by taking the supremum of the
topologies coinduced by those chart inclusions. For `R = ℂ`, it is the analytic topology on
complex points. -/
@[instance_reducible]
noncomputable instance analyticTopology : TopologicalSpace (Point R X) :=
  ⨆ U : X.left.affineOpens,
    .coinduced (Subtype.val : OverOpen (X := X) U.1 → _) (chartTopology U.1)

/-- A set of `R`-points is analytically open exactly when, in every affine chart, it is cut
out by an open set of ring homomorphisms `Γ(X.left, U) ⟶ ↧R`. -/
private lemma isOpen_analyticTopology_iff {W : Set (Point R X)} :
    IsOpen W ↔ ∀ U : X.left.affineOpens,
      ∃ O : Set (Γ(X.left, U.1) ⟶ ↧R), IsOpen O ∧ evaluationHom U.1 ⁻¹' O = Subtype.val ⁻¹' W := by
  rw [isOpen_iSup_iff]
  exact forall_congr' fun U ↦ isOpen_coinduced.trans isOpen_induced_iff

variable [ContinuousMul R] [IsOpenUnits R]

/-- A defining subbasic set is open in the analytic topology. -/
lemma isOpen_overOpen_inter_preimage (U : X.left.Opens) (s : Γ(X.left, U))
    (V : Set R) (hV : IsOpen V) :
    IsOpen (overOpen U ∩ evaluate U s ⁻¹' V : Set (Point R X)) := by
  rw [isOpen_analyticTopology_iff]
  rintro ⟨W, hW⟩
  refine ⟨⋃ (g : Γ(X.left, W)) (k : ℕ) (a : Γ(X.left, W)) (_ : X.left.basicOpen g ≤ U ⊓ W)
      (_ : ∀ y : Point R X, y ∈ overOpen (X.left.basicOpen g) →
        evaluate U s y = Ring.inverse (evaluate W g y ^ k) * evaluate W a y),
      {φ : Γ(X.left, W) ⟶ ↧R | IsUnit (φ g)} ∩
        (fun φ : Γ(X.left, W) ⟶ ↧R ↦ Ring.inverse (φ g ^ k) * φ a) ⁻¹' V,
      ?_, ?_⟩
  · refine isOpen_iUnion fun g ↦ isOpen_iUnion fun k ↦ isOpen_iUnion fun a ↦
      isOpen_iUnion fun _ ↦ isOpen_iUnion fun _ ↦ ?_
    have hg : Continuous fun φ : Γ(X.left, W) ⟶ ↧R ↦ φ g :=
      CommRingCat.HomTopology.continuous_apply (R := ↧R) g
    have ha : Continuous fun φ : Γ(X.left, W) ⟶ ↧R ↦ φ a :=
      CommRingCat.HomTopology.continuous_apply (R := ↧R) a
    have hinv : ContinuousOn (fun φ : Γ(X.left, W) ⟶ ↧R ↦ Ring.inverse (φ g ^ k))
        {φ : Γ(X.left, W) ⟶ ↧R | IsUnit (φ g)} :=
      OAI.Topology.Algebra.IsOpenUnits.continuousOn_ringInverse.comp (hg.pow k).continuousOn fun _ hφ ↦ hφ.pow k
    exact (hinv.mul ha.continuousOn).isOpen_inter_preimage
      ((OAI.Topology.Algebra.IsOpenUnits.isOpen_setOf_isUnit _).preimage hg) hV
  · ext z
    have key : ∀ t : Γ(X.left, W), evaluationHom W z t = evaluate W t z.1 :=
      fun t ↦ evaluationHom_apply W z t
    simp only [Set.mem_preimage, Set.mem_iUnion, Set.mem_ofPred_eq, Set.mem_inter_iff,
      exists_prop, key]
    constructor
    · rintro ⟨g, k, a, hgle, hdiv, hg0, hgV⟩
      have hzg : z.1 ∈ overOpen (X.left.basicOpen g) :=
        (mem_overOpen_basicOpen_iff_isUnit_evaluate g z.1 z.2).mpr hg0
      exact ⟨(hgle.trans inf_le_left) hzg, by rw [hdiv z.1 hzg]; exact hgV⟩
    · rintro ⟨hzU, hzV⟩
      obtain ⟨g, hgle, hzg⟩ :=
        hW.exists_basicOpen_le (⟨z.1.underlying, ⟨hzU, z.2⟩⟩ : (U ⊓ W : X.left.Opens)) z.2
      have hgU : X.left.basicOpen g ≤ U := hgle.trans inf_le_left
      obtain ⟨k, a, hka⟩ :=
        exists_evaluate_basicOpen_eq_inverse_mul (X := X) hW g
          (X.left.presheaf.map (homOfLE hgU).op s)
      have hdiv : ∀ y : Point R X, y ∈ overOpen (X.left.basicOpen g) →
          evaluate U s y = Ring.inverse (evaluate W g y ^ k) * evaluate W a y := fun y hy ↦ by
        rw [evaluate_res hgU s y hy]; exact hka y hy
      refine ⟨g, k, a, hgle, hdiv, ?_, ?_⟩
      · exact (mem_overOpen_basicOpen_iff_isUnit_evaluate g z.1 z.2).mp hzg
      · rw [← hdiv z.1 hzg]; exact hzV

/-- The analytic topology is generated by evaluation of local regular functions.

This is the original description of the topology: it is generated by the sets on which a local
regular function takes values in a prescribed open subset of `R`. -/
lemma analyticTopology_eq_generateFrom :
    (analyticTopology : TopologicalSpace (Point R X)) =
      .generateFrom analyticSubbasis := by
  refine le_antisymm (le_generateFrom ?_) ?_
  · rintro W ⟨U, s, V, hV, rfl⟩
    exact isOpen_overOpen_inter_preimage U s V hV
  · intro W hW
    rw [isOpen_analyticTopology_iff] at hW
    refine (@isOpen_iff_forall_mem_open _
      (.generateFrom (analyticSubbasis (X := X))) _).2 fun z hz ↦ ?_
    obtain ⟨U, hU, hzU, -⟩ :=
      exists_isAffineOpen_mem_and_subset (x := z.underlying) (U := ⊤) trivial
    obtain ⟨O, hO, hWO⟩ := hW ⟨U, hU⟩
    obtain ⟨O', hO', rfl⟩ :=
      (CommRingCat.HomTopology.isEmbedding_hom ↧R Γ(X.left, U)).isInducing.isOpen_iff.mp hO
    have hzO : ⇑(evaluationHom U ⟨z, hzU⟩).hom ∈ O' := by
      have h : (⟨z, hzU⟩ : OverOpen (X := X) U) ∈ Subtype.val ⁻¹' W := hz
      rwa [← hWO] at h
    obtain ⟨I, u, hu, hIO⟩ := isOpen_pi_iff.mp hO' _ hzO
    refine ⟨overOpen U ∩ ⋂ t ∈ (I : Set Γ(X.left, U)), (overOpen U ∩ evaluate U t ⁻¹' u t),
      ?_, ?_, ?_⟩
    · rintro y ⟨hyU, hyu⟩
      have hy : ⇑(evaluationHom U ⟨y, hyU⟩).hom ∈ O' :=
        hIO fun t ht ↦ by
          rw [evaluationHom_apply]
          exact (Set.mem_iInter₂.1 hyu t ht).2
      have hmem : (⟨y, hyU⟩ : OverOpen (X := X) U) ∈
          evaluationHom U ⁻¹' ((fun f : Γ(X.left, U) ⟶ ↧R ↦ ⇑f.hom) ⁻¹' O') := hy
      rwa [hWO] at hmem
    · exact @IsOpen.inter _ (.generateFrom _) _ _
        (TopologicalSpace.isOpen_generateFrom_of_mem ⟨U, 0, Set.univ, isOpen_univ, by simp⟩)
        (@Set.Finite.isOpen_biInter _ _ (.generateFrom _) _ _ I.finite_toSet fun t ht ↦
          TopologicalSpace.isOpen_generateFrom_of_mem ⟨U, t, u t, (hu t ht).1, rfl⟩)
    · refine ⟨hzU, Set.mem_iInter₂.2 fun t ht ↦ ⟨hzU, ?_⟩⟩
      have h2 := (hu t ht).2
      rwa [evaluationHom_apply] at h2

/-- Continuity of a map into the `R`-points is tested on the defining subbasis. -/
lemma continuous_iff_analyticSubbasis {Z : Type*} [TopologicalSpace Z]
    {g : Z → Point R X} :
    Continuous g ↔ ∀ W ∈ analyticSubbasis (X := X), IsOpen (g ⁻¹' W) := by
  rw [analyticTopology_eq_generateFrom]
  exact continuous_generateFrom_iff

/-- Every morphism over `Spec R` induces a continuous map on `R`-points for the topology
generated by regular-function evaluations. -/
lemma continuous_map {Y : Over (Spec ↧R)} (f : X ⟶ Y) :
    @Continuous (Point R X) (Point R Y)
      analyticTopology analyticTopology (Point.map f) := by
  rw [continuous_iff_analyticSubbasis]
  rintro W ⟨U, s, V, hV, rfl⟩
  rw [Set.preimage_inter, Set.preimage_preimage]
  have hover : Point.map f ⁻¹' overOpen U = overOpen (f.left ⁻¹ᵁ U) :=
    Set.ext fun z ↦ mem_overOpen_map_iff f z U
  have heval : (fun z ↦ evaluate U s (Point.map f z)) =
      evaluate (f.left ⁻¹ᵁ U) (f.left.app U s) :=
    funext fun z ↦ evaluate_map f U s z
  rw [hover, heval]
  exact isOpen_overOpen_inter_preimage _ _ _ hV

/-- Let `R` be a commutative local ring with continuous multiplication and open units, and let `f:
X → Y` be a morphism of schemes over `R`. This is the continuous map on `R`-points `z ↦ f ∘ z`,
for the topologies defined by local regular-function evaluations. -/
noncomputable def continuousMap {Y : Over (Spec ↧R)} (f : X ⟶ Y) :
    @ContinuousMap (Point R X) (Point R Y)
      analyticTopology analyticTopology :=
  @ContinuousMap.mk _ _ analyticTopology analyticTopology (Point.map f) (continuous_map f)

/-- Let `R` be a commutative local ring with continuous multiplication and open units, and let `e:
X ≅ Y` be an isomorphism of schemes over `R`. Composition with `e` and `e⁻¹` gives this
homeomorphism of `R`-point spaces with their regular-function evaluation topologies. -/
noncomputable def isoMapHomeomorph {Y : Over (Spec ↧R)} (e : X ≅ Y) :
    @Homeomorph (Point R X) (Point R Y)
      analyticTopology analyticTopology :=
  letI : TopologicalSpace (Point R X) := analyticTopology
  letI : TopologicalSpace (Point R Y) := analyticTopology
  { toFun := Point.map e.hom
    invFun := Point.map e.inv
    left_inv z := by simp [Point.map, Category.assoc]
    right_inv z := by simp [Point.map, Category.assoc]
    continuous_toFun := continuous_map e.hom
    continuous_invFun := continuous_map e.inv }

@[simp]
lemma isoMapHomeomorph_apply {Y : Over (Spec ↧R)} (e : X ≅ Y)
    (z : Point R X) :
    isoMapHomeomorph e z = Point.map e.hom z :=
  rfl

end Point

/-- Let `X` be a scheme over `ℂ`. A complex point is a scheme morphism `Spec ℂ → X` over `Spec ℂ`,
equivalently a point with a compatible complex-valued homomorphism from its residue field. -/
abbrev ComplexSchemePoint (X : Over (Spec ↧ℂ)) := Point ℂ X

end OAI.AlgebraicGeometry.ComplexPoint.Basic