mathlib4 review helperopen PRs by @wwylele on leanprover-community/mathlib4

← queue

#45537 feat(RingTheory/Valuation): more lemmas for ValuativeRel

t-ring-theory CI success

+80 −0 · 1 file · 4 commits · head daa13cc · updated 31 days ago · Files changed on GitHub

PR description
Conversation on GitHub 9
github-actions[bot] · comment · 2026-10-31
PR summary daa13cca20
Import changes for modified files

No significant changes to the import graph

<details><summary>Import changes for all files</summary>

|Files|Import difference| |-|-|

</details>


<details><summary>

Declarations diff (regex)

</summary>

+ add_vlt_of_vlt_of_vlt + div_veq_iff + div_veq_one_iff + div_vlt_iff + div_vlt_one_iff + inv_veq_one + neg_veq_iff + neg_veq_self + neg_vle_iff + neg_vle_self + neg_vlt_iff + one_veq_inv + one_vlt_div_iff + self_vle_neg + veq_div_iff + veq_neg_iff + vle_neg_iff + vle_one_or_inv_vle_one + vle_one_or_inv_vlt_one + vlt_div_iff + vlt_neg_iff <details> <summary>You can run this locally as follows</summary>

## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

</details>

The doc-module for scripts/pr_summary/declarations_diff.sh in the undefined repository contains some details about this script.

</details>

<details><summary>

Declarations diff (Lean)

</summary>

✅ Lean-aware diff — post-build, computed from the Lean environment (commit daa13cc).

  • +19 new declarations
  • −0 removed declarations
+ValuativeRel.add_vlt_of_vlt_of_vlt
+ValuativeRel.div_veq_iff
+ValuativeRel.div_veq_one_iff
+ValuativeRel.div_vlt_iff
+ValuativeRel.div_vlt_one_iff
+ValuativeRel.inv_veq_one
+ValuativeRel.neg_veq_iff
+ValuativeRel.neg_veq_self
+ValuativeRel.neg_vle_iff
+ValuativeRel.neg_vlt_iff
+ValuativeRel.one_veq_inv
+ValuativeRel.one_vlt_div_iff
+ValuativeRel.veq_div_iff
+ValuativeRel.veq_neg_iff
+ValuativeRel.vle_neg_iff
+ValuativeRel.vle_one_or_inv_vle_one
+ValuativeRel.vle_one_or_inv_vlt_one
+ValuativeRel.vlt_div_iff
+ValuativeRel.vlt_neg_iff

</details>


No changes to strong technical debt. No changes to weak technical debt.

Current commit daa13cca20 Reference commit 0d3fb85496

This script lives in the undefined repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
plp127 · on Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean:984 (outdated) · 2026-10-31

Does this not work for x = 0?

wwylele · on Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean:984 (outdated) · 2026-10-31

oops, I likely copied things too fast. Let me check

vihdzp · on Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean:306 (outdated) · 2026-11-04

I think this should be private with only neg_veq_self exposed.

wwylele · on Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean:306 (outdated) · 2026-11-04

I don't agree. We have public vle_refl despite having veq_refl

plp127 · on Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean:306 (outdated) · 2026-11-04

I don't agree. We have le_refl despite having Eq.refl, but though we have an add_comm we don't have an add_le_comm.

wwylele · on Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean:306 (outdated) · 2026-11-04

Not having add_le_comm is justified by having rw, but the corresponding grw doesn't quite work for veq yet

Plus neg_vle_self is needed in the source code regardless whether it is private or public, so I don't see why we have to go out of my way to make it private. add_le_comm is something you will need to add after proving add_comm, which makes less sense to do so

vihdzp · on Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean:306 (outdated) · 2026-11-04

We're able to recover the le version from the .1 field of the eq version, so I think this is redundant.

wwylele · on Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean:306 (outdated) · 2026-11-04

After some thought I think I am ok with the suggestion now. Pushed the changed

Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean +80 −0

theorem vle_add_cases (x y : R) : x + y ≤ᵥ x ∨ x + y ≤ᵥ y :=
295 grw [show (0 : R) = x * 0 by simp, veq_mul_comm, veq_mul_comm x] at hy
296 exact vle_mul_cancel hx hy
lemma add_vlt_of_vlt_of_vlt newL298–301
298lemma add_vlt_of_vlt_of_vlt {x y z : R} (hx : x <ᵥ z) (hy : y <ᵥ z) : x + y <ᵥ z := by
299 rcases vle_add_cases x y with h | h
300 · exact h.trans_vlt hx
301 · exact h.trans_vlt hy
303section Ring
304variable {R : Type*} [Ring R] [ValuativeRel R]
lemma neg_vle_self newL306–309
306private lemma neg_vle_self (x : R) : -x ≤ᵥ x := by
307 rcases vle_total (-x) x with h | h
308 · exact h
309 · simpa using mul_vle_mul_left h (-1)
lemma self_vle_neg newL311–311
311private lemma self_vle_neg (x : R) : x ≤ᵥ -x := by simpa using neg_vle_self (-x)
lemma neg_veq_self newL313–313
313lemma neg_veq_self (x : R) : -x =ᵥ x := ⟨neg_vle_self x, self_vle_neg x⟩
lemma neg_vle_iff newL315–318
315@[simp]
316lemma neg_vle_iff {x y : R} : -x ≤ᵥ y ↔ x ≤ᵥ y where
317 mp h := vle_trans (self_vle_neg x) h
318 mpr h := vle_trans (neg_vle_self x) h
lemma vle_neg_iff newL320–323
320@[simp]
321lemma vle_neg_iff {x y : R} : x ≤ᵥ -y ↔ x ≤ᵥ y where
322 mp h := vle_trans h (neg_vle_self y)
323 mpr h := vle_trans h (self_vle_neg y)
lemma neg_vlt_iff newL325–326
325@[simp]
326lemma neg_vlt_iff {x y : R} : -x <ᵥ y ↔ x <ᵥ y := vle_neg_iff.not
lemma vlt_neg_iff newL328–329
328@[simp]
329lemma vlt_neg_iff {x y : R} : x <ᵥ -y ↔ x <ᵥ y := neg_vle_iff.not
lemma neg_veq_iff newL331–332
331@[simp]
332lemma neg_veq_iff {x y : R} : -x =ᵥ y ↔ x =ᵥ y := by simp [veq_def]
lemma veq_neg_iff newL334–335
334@[simp]
335lemma veq_neg_iff {x y : R} : x =ᵥ -y ↔ x =ᵥ y := by simp [veq_def]
337end Ring
339variable (R) in
340/-- The submonoid of elements `x : R` whose valuation is positive. -/
341def posSubmonoid : Submonoid R where
lemma vle_div_iff (hc : c ≠ 0) : a ≤ᵥ b / c ↔ a * c ≤ᵥ b := by
946lemma div_vle_iff (hc : c ≠ 0) : a / c ≤ᵥ b ↔ a ≤ᵥ b * c := by
947 rw [← mul_vle_mul_iff_left (by simpa), div_mul_cancel₀ _ (by lia)]
lemma vlt_div_iff newL949–949
949lemma vlt_div_iff (hc : c ≠ 0) : a <ᵥ b / c ↔ a * c <ᵥ b := (div_vle_iff hc).not
lemma div_vlt_iff newL951–951
951lemma div_vlt_iff (hc : c ≠ 0) : a / c <ᵥ b ↔ a <ᵥ b * c := (vle_div_iff hc).not
lemma div_veq_iff newL953–954
953lemma div_veq_iff (hc : c ≠ 0) : a / c =ᵥ b ↔ a =ᵥ b * c := by
954 simp [veq_def, vle_div_iff hc, div_vle_iff hc]
lemma veq_div_iff newL956–957
956lemma veq_div_iff (hc : c ≠ 0) : b =ᵥ a / c ↔ b * c =ᵥ a := by
vihdzp · 2026-11-04

Likewise here, it should be easier to reason by using veq_comm.

957 rw [veq_comm, div_veq_iff hc, veq_comm]
959lemma one_vle_div_iff (hb : b ≠ 0) : 1 ≤ᵥ a / b ↔ b ≤ᵥ a := by
960 simp [vle_div_iff hb]
962lemma div_vle_one_iff (hb : b ≠ 0) : a / b ≤ᵥ 1 ↔ a ≤ᵥ b := by
963 simp [div_vle_iff hb]
lemma one_vlt_div_iff newL965–965
965lemma one_vlt_div_iff (hb : b ≠ 0) : 1 <ᵥ a / b ↔ b <ᵥ a := (div_vle_one_iff hb).not
lemma div_vlt_one_iff newL967–967
967lemma div_vlt_one_iff (hb : b ≠ 0) : a / b <ᵥ 1 ↔ a <ᵥ b := (one_vle_div_iff hb).not
lemma div_veq_one_iff newL969–970
969lemma div_veq_one_iff (hb : b ≠ 0) : a / b =ᵥ 1 ↔ a =ᵥ b := by
970 simp [veq_def, one_vle_div_iff hb, div_vle_one_iff hb]
972lemma one_vle_inv (hx : x ≠ 0) : 1 ≤ᵥ x⁻¹ ↔ x ≤ᵥ 1 := by
973 simpa using one_vle_div_iff (a := 1) hx
lemma inv_vlt_one (hx : x ≠ 0) : x⁻¹ <ᵥ 1 ↔ 1 <ᵥ x :=
981lemma one_vlt_inv (hx : x ≠ 0) : 1 <ᵥ x⁻¹ ↔ x <ᵥ 1 :=
982 (inv_vle_one hx).not
lemma inv_veq_one newL984–988
984@[simp]
985lemma inv_veq_one : x⁻¹ =ᵥ 1 ↔ x =ᵥ 1 := by
986 by_cases hx : x = 0
987 · simp [hx]
988 grind [veq_def, one_vle_inv, inv_vle_one]
lemma one_veq_inv newL990–992
990@[simp]
991lemma one_veq_inv : 1 =ᵥ x⁻¹ ↔ 1 =ᵥ x := by
vihdzp · 2026-11-04

I think it might be easier to prove this using inv_veq_one above.

992 rw [veq_comm, inv_veq_one, veq_comm]
lemma vle_one_or_inv_vlt_one newL994–997
994lemma vle_one_or_inv_vlt_one : x ≤ᵥ 1 ∨ x⁻¹ <ᵥ 1 := by
995 by_cases h : x = 0
996 · simp [h]
997 · simp [or_iff_not_imp_right, one_vle_inv h]
999/- This theorem is a weaker version of `ValuativeRel.vle_one_or_inv_vlt_one`,
1000but more symmetric in x and x⁻¹. -/
lemma vle_one_or_inv_vle_one newL1001–1004
1001lemma vle_one_or_inv_vle_one : x ≤ᵥ 1 ∨ x⁻¹ ≤ᵥ 1 := by
1002 by_cases h : x = 0
1003 · simp [h]
1004 · simpa [inv_vle_one h] using vle_total x 1
1006end DivisionRing
1008open NNReal in variable (R) in
0/21 declarations checked

Your review, as Markdown

Paste it as a comment or a review on the PR. Line links to the head commit unfold into code snippets on GitHub.