-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenpr_N_v3_gemini.txt
More file actions
654 lines (603 loc) · 31.6 KB
/
Copy pathopenpr_N_v3_gemini.txt
File metadata and controls
654 lines (603 loc) · 31.6 KB
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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
====================================================================================================
CASE N PR #24627 (open-pr, v3 prompt, Gemini)
file: Mathlib/Topology/Algebra/Valued/ValuedField.lean line: 410.0
reviewer: @loefflerd on 2025-05-29T14:09:54Z
advice_kind: suggestion block (proof rewrite)
model: gemini-2.5-flash prompt_tokens: 8280 completion_tokens: 1867
HUMAN reviewer (ground truth):
> 🏌️
> ```suggestion
> refine ⟨fun _ ↦ singletons_open_iff_discrete.mp fun x ↦ ?_, fun _ ↦ inferInstance⟩
> have hk : IsOpen (𝒪[K] : Set K) := isOpen_integer K
> rcases le_total (Valued.v x) 1 with hx | hx
> · simpa using hk.isOpenMap_subtype_val _ (show IsOpen {⟨x, hx⟩} from isOpen_discrete _)
> · have hx0 : x ≠ 0 := v.pos_iff.mp <| hx.trans_lt' zero_lt_one
> replace hx : Valued.v x⁻¹ ≤ 1 := by rwa [map_inv₀, inv_le_one₀ (zero_lt_one.trans_le hx)]
> have h1 : IsOpen ({⟨x⁻¹, hx⟩} : Set 𝒪[K]) := isOpen_discrete _
> have h2 : IsOpen {x⁻¹} := by simpa using hk.isOpenMap_subtype_val _ h1
> simp only [isOpen_iff_mem_nhds, Set.mem_singleton_iff, forall_eq] at h2
> simpa [isOpen_iff_mem_nhds, -Filter.map_inv] using continuousAt_inv₀ hx0 h2
> ```
====================================================================================================
[SYSTEM]
----------------------------------------------------------------------------------------------------
You are an expert reviewer for the Lean 4 / mathlib4 mathematical library. Given a NEW code hunk from an open pull request and a set of historically retrieved (past_hunk, past_comment) pairs, your job is to identify which past reviewer feedback would also apply to the new hunk.
Your single most important task is to AVOID "axis-miss" false positives: cases where a past comment and the new code LOOK similar on the surface, but the past reviewer was raising a different KIND of concern than anything the new hunk actually has. A correct silent output is far more valuable than a confident wrong-axis answer.
Read carefully before producing JSON. Follow the four steps below in order.
STEP 1 — STRUCTURAL + SEMANTIC READING OF THE NEW HUNK.
1a. Parse the code shape: tactic-mode vs term-mode, declaration kind (`def` / `theorem` / `lemma` / `instance` / `class` / `structure` / `abbrev` / `syntax` / `notation`), attributes (`@[simp]`, `@[to_additive]`, `@[deprecated]`, `@[ext]`, `@[fun_prop]`, `@[reassoc]`, …), universe parameters, implicit/explicit binders, docstring style, proof tactics used.
1b. Inventory what *could* be criticized about THIS specific hunk. Pick as many as apply from this list of "concern axes":
- correctness-bug (code doesn't typecheck / is logically wrong)
- naming (lemma/def name doesn't follow conventions)
- docstring (missing, unclear, typo, wrong phrasing)
- attribute (missing/wrong `@[simp]` / `@[to_additive]` …)
- style-syntax (`fun x ↦` vs `fun x =>`, `by use _; exact _` vs `⟨_, _⟩`, whitespace/`ppSpace`, notation preference)
- proof-golf (the proof tactics could be shorter/nicer)
- refactor-simplify (same statement provable with less machinery)
- generalize-signature (hypotheses too strong; remove/weaken a typeclass)
- design-smell-architectural (this API shape is wrong; returning a string, unnecessary instance, redundant definition, etc.)
- imports-module (superfluous imports, module structure)
- namespace-organization (`_root_`, namespace boundary, file placement)
- automation-tactic (should use / should teach `aesop_cat`, `gcongr`, `positivity`, etc.)
- instance-diamond (this instance creates an ambiguity / defeq diamond with another)
- unify-with-existing (a similar definition/lemma already exists)
- junk-value (docstring should note behavior at the "undefined" input; handled via `0`/`⊥`/`⊤`)
List the concerns that PLAUSIBLY apply to the new hunk. If none are obviously present, say so — don't invent them.
STEP 2 — PER-CANDIDATE CONCERN CLASSIFICATION.
For EACH candidate, identify which concern axis (from the same list) the past reviewer's comment was about. Read the past comment carefully: the reviewer's *words* (not the past code) tell you the concern axis. If a past comment ships a `suggestion` code block, that block is evidence for what the reviewer wanted changed — but the axis of concern comes from the prose around it. Ignore candidates whose past comment is pure bikeshed or where you cannot identify a clear concern.
STEP 3 — AXIS MATCH + APPLICABILITY CHECK.
A candidate is eligible for `strong_matches` ONLY if BOTH:
(a) Its axis (from step 2) is among the new hunk's plausible concerns (from step 1b).
(b) You can write a concrete adaptation that a Lean/mathlib reviewer would plausibly post on the new hunk *today*, given what is visible in the hunk.
Before promoting, write — in the JSON output, per match — a `why_might_not_apply` field giving the strongest counter-argument against promotion (one short sentence). If this counter-argument is actually compelling (e.g. "the new code does not have that pattern", "the new code *does* have an ext lemma, so this doesn't apply"), DO NOT promote; demote to `weak_observations` or drop.
Cross-candidate synthesis is allowed: if candidate X establishes that an identifier in the new hunk is a `class`, and candidate Y shows the preferred term-mode `instance := ⟨...⟩` template, they jointly support a promotion. List both in `supporting_past_prs` and still produce one `why_might_not_apply`.
STEP 4 — CONFIDENCE AND OUTPUT.
Confidence scale:
- "high" — ≥1 strong match survives step 3 AND the adaptation is a near-verbatim application of a past comment; the counter-argument is weak.
- "medium" — ≥1 strong match survives step 3 BUT needs adaptation or synthesis; counter-argument is plausible but not decisive.
- "low" — no candidate survives step 3; only stylistic patterns worth mentioning as `weak_observations`.
- "none" — retrieved pool's axes don't match anything plausible about the new hunk; state this and stop.
When in doubt between "medium" and "low" on a single uncertain candidate, prefer "low" and put that candidate in `weak_observations`. "Confident but wrong-axis" is the #1 failure we are trying to eliminate.
Output JSON ONLY, matching this exact schema:
{
"new_hunk_plausible_concerns": [<one or more axis labels from Step 1b, or []>],
"summary": "<one sentence describing what we found>",
"confidence": "high"|"medium"|"low"|"none",
"strong_matches": [
{
"past_pr": <int>,
"past_file": "<string>",
"past_concern_axis": "<axis label from the list>",
"past_comment_excerpt": "<verbatim short quote from the past comment OR the relevant snippet from its suggestion block>",
"applies_because": "<one or two sentences linking past code/comment to the new hunk's structure AND explaining why the concern axis matches>",
"suggested_adaptation": "<one sentence on what the reviewer might say on the new hunk>",
"why_might_not_apply": "<one short sentence — strongest counter-argument against this promotion>",
"supporting_past_prs": [<int>, ...]
}
],
"weak_observations": [
{
"observation": "<short string>",
"axis": "<axis label>",
"supporting_past_prs": [<int>, ...]
}
]
}
Quote short — under 40 words per excerpt. Do not invent axis labels outside the list. Do not promote a candidate whose axis is not in `new_hunk_plausible_concerns`.
[USER]
----------------------------------------------------------------------------------------------------
NEW HUNK from open PR #24627 (file: Mathlib/Topology/Algebra/Valued/ValuedField.lean):
```
@@ -379,3 +379,32 @@ scoped notation "𝓀[" K "]" => ResidueField K
end Valued
end Notation
+
+open Valued
+lemma Valued.discreteTopology_valuationRing_iff_discreteTopology
+ {K Γ₀ : Type*} [Field K] [LinearOrderedCommGroupWithZero Γ₀] [Valued K Γ₀] :
+ DiscreteTopology 𝒪[K] ↔ DiscreteTopology K := by
+ have hk : IsOpen (𝒪[K] : Set K) := isOpen_integer K
+ constructor
+ · intro h
+ rw [← singletons_open_iff_discrete]
+ intro x
+ rcases le_total (Valued.v x) 1 with hx | hx
+ · have : IsOpen ({⟨x, hx⟩} : Set 𝒪[K]) := isOpen_discrete _
+ simpa using hk.isOpenMap_subtype_val _ this
+ · have hx0 : x ≠ 0 := by
+ rw [← Valued.v.pos_iff]
+ refine hx.trans_lt' ?_
+ norm_num
+ replace hx : Valued.v x⁻¹ ≤ 1 := by
+ rwa [map_inv₀, inv_le_one₀]
+ rwa [Valued.v.pos_iff]
+ suffices IsOpen {x⁻¹} by
+ simp only [isOpen_iff_mem_nhds, Set.mem_singleton_iff, forall_eq] at this ⊢
+ have := continuousAt_inv₀ hx0 this
+ rw [Filter.mem_map] at this
+ simpa using this
+ have : IsOpen ({⟨x⁻¹, hx⟩} : Set 𝒪[K]) := isOpen_discrete _
+ simpa using hk.isOpenMap_subtype_val _ this
+ · intro h
+ infer_instance
```
RETRIEVED CANDIDATES (top-20 by hunk-embedding similarity, sorted by sim desc):
--- candidate 1 (sim=0.859, past_pr=#27265, file=Mathlib/Topology/Algebra/Valued/ValuationTopology.lean) ---
PAST HUNK:
```
@@ -147,6 +147,39 @@ theorem loc_const {x : R} (h : (v x : Γ₀) ≠ 0) : { y : R | v y = v x } ∈
... [6 lines above hidden]
+lemma discreteTopology_of_ne_zero_imp_v_eq_one (h : ∀ x : R, x ≠ 0 → v x = 1) :
+ DiscreteTopology R := by
+ simp only [discreteTopology_iff_isOpen_singleton_zero, isOpen_iff_mem_nhds, mem_singleton_iff,
+ forall_eq, mem_nhds_zero, subset_singleton_iff, mem_setOf_eq]
+ use 1
+ contrapose! h
+ obtain ⟨x, hx, hx'⟩ := h
+ exact ⟨x, hx', hx.ne⟩
+
+variable {K : Type*} [DivisionRing K] [Valued K Γ₀] [MulArchimedean Γ₀]
+
+lemma val_discrete_of_forall_lt {r : Γ₀} (hr : r ≠ 0) (h : ∀ x : K, v x ≠ 0 → r < v x)
+ (x : K) (hx : v x ≠ 0) : v x = 1 := by
```
PAST COMMENT (from reviewer):
Should this be stated for any `Valuation` rather than just `Valued.v`?
--- candidate 2 (sim=0.777, past_pr=#13508, file=Mathlib/Topology/Algebra/Valuation.lean) ---
PAST HUNK:
```
@@ -184,3 +184,16 @@ theorem valuationSubring_isOpen (K : Type u) [Field K] [hv : Valued K Γ₀] :
integer_isOpen K
end Valued
+
+theorem Valuation.valuationSubring_isOpen {K : Type*} [Field K] {Γ : Type*}
```
PAST COMMENT (from reviewer):
This has no difference to the theorem above it except having `K` as an implicit variable, and an additional hypothesis.
--- candidate 3 (sim=0.746, past_pr=#8148, file=Mathlib/Topology/Algebra/Valuation.lean) ---
PAST HUNK:
```
@@ -168,4 +168,23 @@ theorem cauchy_iff {F : Filter R} : Cauchy F ↔
... [4 lines above hidden]
+variable (R)
+
+/-- The unit ball of a valued ring is open. -/
+theorem integer_isOpen : IsOpen (_i.v.integer : Set R) := by
+ rw [isOpen_iff_mem_nhds]
+ intro x hx
+ rw [SetLike.mem_coe, mem_integer_iff] at hx
+ rw [mem_nhds]
+ use (1 : Units Γ₀)
+ intro y hy
+ rw [Units.val_one, mem_setOf_eq] at hy
+ rw [SetLike.mem_coe, mem_integer_iff, ← sub_add_cancel y x]
+ exact le_trans (map_add _ _ _) (max_le (le_of_lt hy) hx)
```
PAST COMMENT (from reviewer):
```suggestion
rw [mem_nhds]
exact ⟨1,
fun y hy => (sub_add_cancel y x).symm ▸ le_trans (map_add _ _ _) (max_le (le_of_lt hy) hx)⟩
```
--- candidate 4 (sim=0.742, past_pr=#7779, file=Mathlib/Topology/Algebra/Valuation.lean) ---
PAST HUNK:
```
@@ -166,4 +166,24 @@ theorem cauchy_iff {F : Filter R} : Cauchy F ↔
exact h γ
#align valued.cauchy_iff Valued.cauchy_iff
+variable (R)
+
+/-- The unit ball of a valued ring is open. -/
+theorem integer_isOpen :
+ IsOpen (_i.v.integer : Set R) := by
```
PAST COMMENT (from reviewer):
Maybe we can rename the variable `_i` too, it looks very strange using that in the statement of a theorem
--- candidate 5 (sim=0.742, past_pr=#7779, file=Mathlib/Topology/Algebra/Valuation.lean) ---
PAST HUNK:
```
@@ -166,4 +166,24 @@ theorem cauchy_iff {F : Filter R} : Cauchy F ↔
exact h γ
#align valued.cauchy_iff Valued.cauchy_iff
+variable (R)
+
+/-- The unit ball of a valued ring is open. -/
+theorem integer_isOpen :
+ IsOpen (_i.v.integer : Set R) := by
```
PAST COMMENT (from reviewer):
Not that it matters but I'd be tempted to just put the statement on one line here
--- candidate 6 (sim=0.731, past_pr=#16733, file=Mathlib/Topology/Algebra/Valued/ValuationTopology.lean) ---
PAST HUNK:
```
@@ -153,13 +153,39 @@ theorem cauchy_iff {F : Filter R} : Cauchy F ↔
... [7 lines above hidden]
+theorem isOpen_ball (r : Γ₀) : IsOpen (X := R) {x | v x < r} := by
rw [isOpen_iff_mem_nhds]
+ rcases eq_or_ne r 0 with rfl|hr
+ · simp
intro x hx
rw [mem_nhds]
- exact ⟨1,
- fun y hy => (sub_add_cancel y x).symm ▸ le_trans (v.map_add _ _) (max_le (le_of_lt hy) hx)⟩
+ simp only [setOf_subset_setOf]
+ exact ⟨Units.mk0 _ hr,
+ fun y hy => (sub_add_cancel y x).symm ▸ (v.map_add _ x).trans_lt (max_lt hy hx)⟩
+
+/-- A closed ball of a valued ring is open. -/
```
PAST COMMENT (from reviewer):
```suggestion
/-- A closed ball centred at the origin in a valued ring is open. -/
```
--- candidate 7 (sim=0.731, past_pr=#36532, file=Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean) ---
PAST HUNK:
```
@@ -1091,41 +1092,33 @@ lemma uniformizer_inv_le_iff [IsDiscrete R] [IsNontrivial R] {a : ValueGroupWith
... [11 lines above hidden]
- ∃ γ : (ValueGroupWithZero R)ˣ, (x + ·) '' { z | valuation _ z < γ } ⊆ s
-
-namespace ValuativeRel
-
variable {R Γ : Type*} [CommRing R] [ValuativeRel R] [LinearOrderedCommGroupWithZero Γ]
(v : Valuation R Γ)
-open MonoidWithZeroHom
+open MonoidWithZeroHom ValueGroup₀
+
+namespace ValueGroupWithZero
/-- Any valuation compatible with the valuative relation can be factored through
```
PAST COMMENT (from reviewer):
I'm not sure that this doc really says what `embed` does. Moreover, I think that it would be useful to add a bit of docs to some of the lemmas below, because for someone not at ease with these objects (but who knows the Math) most results might look daunting.
--- candidate 8 (sim=0.728, past_pr=#28211, file=Mathlib/Topology/Algebra/Valued/ValuativeRel.lean) ---
PAST HUNK:
```
@@ -188,6 +189,16 @@ lemma isOpen_sphere {r : ValueGroupWithZero R} (hr : r ≠ 0) :
@[deprecated (since := "2025-08-01")]
alias _root_.ValuativeTopology.isOpen_sphere := isOpen_sphere
+open WithZeroTopology in
+lemma continuous_valuation : Continuous v := by
+ simp only [continuous_iff_continuousAt, ContinuousAt]
+ rintro x
+ by_cases hx : v x = 0
+ · simpa [hx, (hasBasis_nhds _).tendsto_iff WithZeroTopology.hasBasis_nhds_zero,
+ Valuation.map_sub_of_right_eq_zero _ hx] using fun i hi ↦ ⟨.mk0 i hi, fun y ↦ id⟩
+ · simpa [(hasBasis_nhds _).tendsto_iff (WithZeroTopology.hasBasis_nhds_of_ne_zero hx)]
+ using ⟨.mk0 (v x) hx, fun _ ↦ Valuation.map_eq_of_sub_lt _⟩
```
PAST COMMENT (from reviewer):
```suggestion
lemma continuous_valuation : Continuous v := by
simp only [continuous_iff_continuousAt, ContinuousAt]
intro x
by_cases hx : v x = 0
· simpa [hx, (hasBasis_nhds _).tendsto_iff WithZeroTopology.hasBasis_nhds_zero,
(v).map_sub_of_right_eq_zero hx] using fun i hi ↦ ⟨.mk0 i hi, fun y ↦ id⟩
· simpa [(hasBasis_nhds _).tendsto_iff (WithZeroTopology.hasBasis_nhds_of_ne_zero hx)]
using ⟨.mk0 (v x) hx, fun _ ↦ (v).map_eq_of_sub_lt⟩
```
--- candidate 9 (sim=0.728, past_pr=#28211, file=Mathlib/Topology/Algebra/Valued/ValuativeRel.lean) ---
PAST HUNK:
```
@@ -188,6 +189,16 @@ lemma isOpen_sphere {r : ValueGroupWithZero R} (hr : r ≠ 0) :
@[deprecated (since := "2025-08-01")]
alias _root_.ValuativeTopology.isOpen_sphere := isOpen_sphere
+open WithZeroTopology in
+lemma continuous_valuation : Continuous v := by
+ simp only [continuous_iff_continuousAt, ContinuousAt]
+ rintro x
+ by_cases hx : v x = 0
+ · simpa [hx, (hasBasis_nhds _).tendsto_iff WithZeroTopology.hasBasis_nhds_zero,
+ Valuation.map_sub_of_right_eq_zero _ hx] using fun i hi ↦ ⟨.mk0 i hi, fun y ↦ id⟩
+ · simpa [(hasBasis_nhds _).tendsto_iff (WithZeroTopology.hasBasis_nhds_of_ne_zero hx)]
+ using ⟨.mk0 (v x) hx, fun _ ↦ Valuation.map_eq_of_sub_lt _⟩
```
PAST COMMENT (from reviewer):
Why use the botched `intro` tactic? It's one letter less and strictly worse
--- candidate 10 (sim=0.724, past_pr=#16733, file=Mathlib/Topology/Algebra/Valued/ValuationTopology.lean) ---
PAST HUNK:
```
@@ -153,13 +153,39 @@ theorem cauchy_iff {F : Filter R} : Cauchy F ↔
variable (R)
-/-- The unit ball of a valued ring is open. -/
-theorem integer_isOpen : IsOpen (_i.v.integer : Set R) := by
+/-- A ball of a valued ring is open. -/
```
PAST COMMENT (from reviewer):
```suggestion
/-- An open ball centred at the origin in a valued ring is open. -/
```
--- candidate 11 (sim=0.721, past_pr=#13508, file=Mathlib/RingTheory/DedekindDomain/AdicValuation.lean) ---
PAST HUNK:
```
@@ -381,6 +381,11 @@ theorem mem_adicCompletionIntegers {x : v.adicCompletion K} :
Iff.rfl
#align is_dedekind_domain.height_one_spectrum.mem_adic_completion_integers IsDedekindDomain.HeightOneSpectrum.mem_adicCompletionIntegers
+/-- The unit ball `adicCompletionIntegers` is an open subset of `adicCompletion`. -/
+theorem adicCompletionIntegers_isOpen :
+ IsOpen (v.adicCompletionIntegers K : Set (v.adicCompletion K)) := by
+ exact Valuation.valuationSubring_isOpen
```
PAST COMMENT (from reviewer):
```suggestion
IsOpen (v.adicCompletionIntegers K : Set (v.adicCompletion K)) :=
Valuation.valuationSubring_isOpen
```
--- candidate 12 (sim=0.720, past_pr=#26713, file=Mathlib/Topology/Algebra/Valued/ValuativeRel.lean) ---
PAST HUNK:
```
@@ -0,0 +1,107 @@
... [76 lines above hidden]
+ rw [mem_nhds]
+ simp only [setOf_subset_setOf]
+ exact ⟨Units.mk0 _ hr, fun y hy => (sub_add_cancel y x).symm ▸
+ le_trans ((v).map_add _ _) (max_le (le_of_lt hy) hx)⟩
+
+theorem isClosed_closedBall (r : ValueGroupWithZero R) :
+ IsClosed {x | v x ≤ r} := by
+ rw [← isOpen_compl_iff, isOpen_iff_mem_nhds]
+ intro x hx
+ simp only [mem_compl_iff, mem_setOf_eq, not_le] at hx
+ rw [mem_nhds]
+ have hx' : v x ≠ 0 := ne_of_gt <| lt_of_le_of_lt zero_le' <| hx
+ refine ⟨Units.mk0 _ hx', fun y hy hy' => ne_of_lt hy <| Valuation.map_sub_swap v x y ▸
```
PAST COMMENT (from reviewer):
You can do `exact` here, right?
--- candidate 13 (sim=0.716, past_pr=#32454, file=Mathlib/Analysis/Normed/Field/Basic.lean) ---
PAST HUNK:
```
@@ -119,9 +119,8 @@ lemma norm_eq_one_iff_ne_zero_of_discrete {x : 𝕜} : ‖x‖ = 1 ↔ x ≠ 0 :
· have : IsOpen {(0 : 𝕜)} := isOpen_discrete {0}
simp_rw [Metric.isOpen_singleton_iff, dist_eq_norm, sub_zero] at this
obtain ⟨ε, εpos, h'⟩ := this
- wlog h : ‖x‖ < 1 generalizing 𝕜 with H
- · push_neg at h
- rcases h.eq_or_lt with h|h
+ wlog! h : ‖x‖ < 1 generalizing 𝕜 with H
+ · rcases h.eq_or_lt with h|h
```
PAST COMMENT (from reviewer):
Pre-existing: we might as well follow mathlib's style guide now
```suggestion
· rcases h.eq_or_lt with h | h
```
--- candidate 14 (sim=0.715, past_pr=#27939, file=Mathlib/RingTheory/Valuation/ValuativeRel.lean) ---
PAST HUNK:
```
@@ -680,8 +680,8 @@ open Topology ValuativeRel in
/-- We say that a topology on `R` is valuative if the neighborhoods of `0` in `R`
are determined by the relation `· ≤ᵥ ·`. -/
class IsValuativeTopology (R : Type*) [CommRing R] [ValuativeRel R] [TopologicalSpace R] where
- mem_nhds_iff : ∀ s : Set R, s ∈ 𝓝 (0 : R) ↔
- ∃ γ : (ValueGroupWithZero R)ˣ, { x | valuation _ x < γ } ⊆ s
+ mem_nhds {s : Set R} {x : R} : s ∈ 𝓝 (x : R) ↔
+ ∃ γ : (ValueGroupWithZero R)ˣ, { z | valuation _ (z - x) < γ } ⊆ s
```
PAST COMMENT (from reviewer):
Just a matter of personal taste, but I would prefer the following spelling here:
```lean
s ∈ 𝓝 (x : R) ↔ ∃ γ : (ValueGroupWithZero R)ˣ, (x + ·) '' { z | valuation _ z < γ } ⊆ s
```
(At least this would make it possible to replace `CommRing` with `CommSemiring` in the future. Maybe we do want to talk about valuations on $\mathbb{N}$?)
--- candidate 15 (sim=0.714, past_pr=#24353, file=Mathlib/Topology/Algebra/Valued/ValuationTopology.lean) ---
PAST HUNK:
```
@@ -193,4 +208,13 @@ theorem valuationSubring_isOpen (K : Type u) [Field K] [hv : Valued K Γ₀] :
IsOpen (hv.v.valuationSubring : Set K) :=
integer_isOpen K
+/-- The closed unit ball of a valued ring is closed. -/
+theorem integer_isClosed : IsClosed (_i.v.integer : Set R) :=
+ isClosed_closedBall _ _
+
+/-- The valuation subring of a valued field is closed. -/
+theorem valuationSubring_isClosed (K : Type u) [Field K] [hv : Valued K Γ₀] :
+ IsClosed (hv.v.valuationSubring : Set K) :=
+ integer_isClosed K
```
PAST COMMENT (from reviewer):
I think these should be `isClosed_blah` instead and maybe you can rename the `isOpen` ones too. Remember to add deprecation aliases if you do so.
--- candidate 16 (sim=0.713, past_pr=#26549, file=Mathlib/Topology/Algebra/Valued/LocallyCompact.lean) ---
PAST HUNK:
```
@@ -132,18 +144,24 @@ lemma totallyBounded_iff_finite_residueField [IsDiscreteValuationRing 𝒪[K]] :
... [13 lines above hidden]
- obtain ⟨n, hn⟩ : ∃ n : ℕ, ‖p‖ ^ n < ε := exists_pow_lt_of_lt_one εpos hp'
+ have hp' := Valuation.integer.v_irreducible_lt_one hp
+ obtain ⟨n, hn⟩ : ∃ n : ℕ, ‖(p : K)‖ ^ n < ε := exists_pow_lt_of_lt_one εpos
+ (toNormedField.norm_lt_one_iff.mpr hp')
have hF := finite_quotient_maximalIdeal_pow_of_finite_residueField H n
refine ⟨Quotient.out '' (Set.univ (α := 𝒪[K] ⧸ (𝓂[K] ^ n))), Set.toFinite _, ?_⟩
- simp only [Ideal.univ_eq_iUnion_image_add (𝓂[K] ^ n), hp.maximalIdeal_pow_eq_closedBall_pow,
+ have : {y : 𝒪[K] | v (y : K) ≤ v (p : K) ^ n} = Metric.closedBall 0 (‖p‖ ^ n) := by
+ ext
+ simp [← norm_pow]
+ simp only [Ideal.univ_eq_iUnion_image_add (𝓂[K] ^ n),
+ hp.maximalIdeal_pow_eq_setOf_le_v_coe_pow,
+ this,
```
PAST COMMENT (from reviewer):
Maybe put these on fewer lines?
--- candidate 17 (sim=0.712, past_pr=#27939, file=Mathlib/Topology/Algebra/Valued/ValuativeRel.lean) ---
PAST HUNK:
```
@@ -19,6 +19,27 @@ to facilitate a refactor.
... [5 lines above hidden]
+
+/-! # Alternate constructors -/
+
+variable {R : Type*} [CommRing R] [ValuativeRel R] [TopologicalSpace R]
+
+open ValuativeRel TopologicalSpace Filter Topology Set
+
+local notation "v" => valuation R
+
+/-- Assuming `ContinuousConstVAdd R R`, we only need to check the neighbourhood of `0` in order to
+prove `IsValuativeTopology R`. -/
+theorem of_zero [ContinuousConstVAdd R R]
+ (h₀ : ∀ s : Set R, s ∈ 𝓝 (0 : R) ↔ ∃ γ : (ValueGroupWithZero R)ˣ, { z | v z < ↑γ } ⊆ s) :
```
PAST COMMENT (from reviewer):
```suggestion
(h₀ : ∀ s : Set R, s ∈ 𝓝 (0 : R) ↔ ∃ γ : (ValueGroupWithZero R)ˣ, { z | v z < γ } ⊆ s) :
```
Is this necessary? (Not tested)
--- candidate 18 (sim=0.710, past_pr=#36532, file=Mathlib/Topology/Algebra/ValuativeRel/ValuativeTopology.lean) ---
PAST HUNK:
```
@@ -0,0 +1,379 @@
... [281 lines above hidden]
+ (isOpen_ball _)
+
+/-- An open ball centred at the origin in a valued ring is clopen. -/
+theorem isClopen_ball (r : ValueGroup₀ v) : IsClopen (X := R) {x | v.restrict x < r} :=
+ ⟨isClosed_ball _, isOpen_ball _⟩
+
+/-- A closed ball centred at the origin in a valued ring is open. -/
+theorem isOpen_closedBall {r : ValueGroup₀ v} (hr : r ≠ 0) :
+ IsOpen (X := R) {x | v.restrict x ≤ r} := by
+ rw [isOpen_iff_mem_nhds]
+ intro x hx
+ rw [v.mem_nhds]
+ simp only [setOf_subset_setOf]
```
PAST COMMENT (from reviewer):
```suggestion
rw [v.mem_nhds]
simp only [setOf_subset_setOf]
```
simp only [v.mem_nhds, setOf_subset_setOf]
--- candidate 19 (sim=0.709, past_pr=#27465, file=Mathlib/Topology/Algebra/Valued/ValuativeRel.lean) ---
PAST HUNK:
```
@@ -74,17 +74,32 @@ instance (priority := low) {R : Type*} [CommRing R] [ValuativeRel R] [UniformSpa
«v» := valuation R
is_topological_valuation := mem_nhds_zero_iff
+lemma v_eq_valuation {R : Type*} [CommRing R] [ValuativeRel R] [UniformSpace R]
+ [IsUniformAddGroup R] [IsValuativeTopology R] :
+ Valued.v = valuation R := rfl
```
PAST COMMENT (from reviewer):
Which instance are you referring to exactly?
--- candidate 20 (sim=0.709, past_pr=#27465, file=Mathlib/Topology/Algebra/Valued/ValuativeRel.lean) ---
PAST HUNK:
```
@@ -74,17 +74,32 @@ instance (priority := low) {R : Type*} [CommRing R] [ValuativeRel R] [UniformSpa
«v» := valuation R
is_topological_valuation := mem_nhds_zero_iff
+lemma v_eq_valuation {R : Type*} [CommRing R] [ValuativeRel R] [UniformSpace R]
+ [IsUniformAddGroup R] [IsValuativeTopology R] :
+ Valued.v = valuation R := rfl
```
PAST COMMENT (from reviewer):
Do we really want to make `Valued` survive? Is this needed or are you adding it for general purposes?
Decide which candidates' comments genuinely apply to the NEW hunk. If none, say so. Output JSON only.
[ASSISTANT]
----------------------------------------------------------------------------------------------------
{
"new_hunk_plausible_concerns": [
"naming",
"docstring",
"proof-golf",
"style-syntax"
],
"summary": "The new lemma is missing a docstring and its proof could be golfed for conciseness, with some specific style suggestions for `rcases` and tactical combinations.",
"confidence": "medium",
"strong_matches": [
{
"past_pr": 6,
"past_file": "Mathlib/Topology/Algebra/Valued/ValuationTopology.lean",
"past_concern_axis": "docstring",
"past_comment_excerpt": "/-- A closed ball centred at the origin in a valued ring is open. -/",
"applies_because": "The new lemma `Valued.discreteTopology_valuationRing_iff_discreteTopology` is entirely missing a docstring, and this past comment indicates the need for precise documentation.",
"suggested_adaptation": "Add a clear and precise docstring to `Valued.discreteTopology_valuationRing_iff_discreteTopology`.",
"why_might_not_apply": "The past comment provides a suggestion for an existing docstring, whereas the new hunk has none."
},
{
"past_pr": 7,
"past_file": "Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean",
"past_concern_axis": "docstring",
"past_comment_excerpt": "I'm not sure that this doc really says what `embed` does. Moreover, I think that it would be useful to add a bit of docs to some of the lemmas below, because for someone not at ease with these objects (but who knows the Math) most results might look daunting.",
"applies_because": "The new lemma lacks any docstring, and this past comment emphasizes the general importance of providing clear documentation for lemmas, especially for complex mathematical concepts.",
"suggested_adaptation": "Provide a comprehensive docstring for `Valued.discreteTopology_valuationRing_iff_discreteTopology` explaining its purpose and context.",
"why_might_not_apply": "The past comment refers to an existing docstring that needs improvement, while the new hunk has no docstring at all."
},
{
"past_pr": 10,
"past_file": "Mathlib/Topology/Algebra/Valued/ValuationTopology.lean",
"past_concern_axis": "docstring",
"past_comment_excerpt": "/-- An open ball centred at the origin in a valued ring is open. -/",
"applies_because": "The new lemma `Valued.discreteTopology_valuationRing_iff_discreteTopology` is missing a docstring, and this past comment suggests adding a precise one.",
"suggested_adaptation": "Add a clear and precise docstring to `Valued.discreteTopology_valuationRing_iff_discreteTopology`.",
"why_might_not_apply": "The past comment provides a suggestion for an existing docstring, whereas the new hunk has none."
},
{
"past_pr": 11,
"past_file": "Mathlib/RingTheory/DedekindDomain/AdicValuation.lean",
"past_concern_axis": "proof-golf",
"past_comment_excerpt": "IsOpen (v.adicCompletionIntegers K : Set (v.adicCompletion K)) := Valuation.valuationSubring_isOpen",
"applies_because": "The past comment suggests simplifying `by exact` to `:=`. The new hunk has `intro h; infer_instance` which could potentially be `:= infer_instance` if `infer_instance` directly discharges the goal.",
"suggested_adaptation": "Consider if `intro h; infer_instance` can be golfed to `:= infer_instance` or `by infer_instance`.",
"why_might_not_apply": "`infer_instance` might not be directly convertible to `:= infer_instance` in this specific context without `intro h`."
},
{
"past_pr": 12,
"past_file": "Mathlib/Topology/Algebra/Valued/ValuativeRel.lean",
"past_concern_axis": "proof-golf",
"past_comment_excerpt": "You can do `exact` here, right?",
"applies_because": "The new hunk's proof is somewhat verbose, using multiple `simpa using` calls, and this past comment encourages using `exact` for brevity and proof-golfing, which is generally applicable here.",
"suggested_adaptation": "Review the proof for opportunities to shorten steps using `exact` or by combining tactics, reducing verbosity.",
"why_might_not_apply": "The specific `refine` tactic mentioned in the past comment is not present in the new hunk's proof."
},
{
"past_pr": 13,
"past_file": "Mathlib/Analysis/Normed/Field/Basic.lean",
"past_concern_axis": "style-syntax",
"past_comment_excerpt": "rcases h.eq_or_lt with h | h",
"applies_because": "The new hunk uses `rcases le_total (Valued.v x) 1 with hx | hx`, which could be formatted to align with the suggested `rcases` style.",
"suggested_adaptation": "Format the `rcases` line as `rcases le_total (Valued.v x) 1 with hx | hx`.",
"why_might_not_apply": "The current `rcases` formatting is already acceptable and legible."
},
{
"past_pr": 18,
"past_file": "Mathlib/Topology/Algebra/ValuativeRel/ValuativeTopology.lean",
"past_concern_axis": "proof-golf",
"past_comment_excerpt": "simp only [v.mem_nhds, setOf_subset_setOf]",
"applies_because": "The new hunk uses multiple `simp only` calls throughout its proof, and this past comment suggests combining them for brevity and proof-golfing.",
"suggested_adaptation": "Consider combining multiple `simp only` lines into a single, more comprehensive one where appropriate.",
"why_might_not_apply": "The current `simp only` usage is specific to different goals and may not always be combinable efficiently."
},
{
"past_pr": 19,
"past_file": "Mathlib/Topology/Algebra/Valued/ValuativeRel.lean",
"past_concern_axis": "docstring",
"past_comment_excerpt": "Which instance are you referring to exactly?",
"applies_because": "The new lemma lacks any docstring, and this past comment highlights the importance of clarity and explanation, which a docstring would provide.",
"suggested_adaptation": "Add a clear docstring to `Valued.discreteTopology_valuationRing_iff_discreteTopology` to explain its context and purpose.",
"why_might_not_apply": "The past comment is about clarifying a specific reference within existing documentation, not a missing docstring."
}
],
"weak_observations": [
{
"observation": "The lemma statement could potentially be formatted onto a single line for brevity.",
"axis": "style-syntax",
"supporting_past_prs": [
5
]
},
{
"observation": "The name `discreteTopology_valuationRing_iff_discreteTopology` is lengthy but adheres to the `_iff_` naming convention.",
"axis": "naming",
"supporting_past_prs": [
15
]
},
{
"observation": "Some `have` statements could potentially be put on fewer lines.",
"axis": "style-syntax",
"supporting_past_prs": [
16
]
}
]
}