Skip to content

Commit b8d2609

Browse files
leanprover-community-mathlib4-botgithub-actionsnomeatakim-emKha
authored
chore: adaptations for nightly-2025-06-20 (#26209)
* Trigger CI for leanprover-community/batteries#1220 * Merge master into nightly-testing * chore: bump to nightly-2025-06-05 * Kick CI * Bump lean4-cli * Bump import-graph * Kick CI * update lakefile * chore: use more robust syntax quotation in Shake * Trigger CI for leanprover/lean4#8419 * Revert "chore: use more robust syntax quotation in Shake" This reverts commit cd87328. * fix(Shake): fix import syntax @Kha this is deliberately using this approach because syntax quotations are also not robust but for a different reason: they fail to parse the new versions of the syntax (and do so at run time). And using all the optional doohickeys will not be future proof. The current setup is explicitly meant to ping me when there is a syntax change so I can evaluate the right way to handle it. In this case we want all the module options to be ignored (treated the same as a regular import for the purpose of dependency tracking), we don't want to fail. * cleanup lakefile * chore: bump to nightly-2025-06-06 * Update lean-toolchain for testing leanprover/lean4#8653 * fix * how did this get dropped?!?! * chore: bump to nightly-2025-06-07 * chore: bump to nightly-2025-06-08 * chore: bump to nightly-2025-06-09 * fix lakefile * fix lint-style for new Lean.Options API * chore: bump to nightly-2025-06-10 * chore: bump to nightly-2025-06-09 * merge lean-pr-testing-4 * chore: bump to nightly-2025-06-11 * chore: adaptations for nightly-2025-06-11 * Update Shake/Main.lean Co-authored-by: Johan Commelin <[email protected]> * Apply suggestions from code review * revert * chore: adaptations for nightly-2025-06-11 * cleanup grind tests * chore: bump to nightly-2025-06-12 * merge lean-pr-testing-8419 * chore: bump to nightly-2025-06-12 * merge lean-pr-testing-8653 * adaptation note * oops * chore: adaptations for nightly-2025-06-12 * remove nolint simpNF * remove spurious file * Update lean-toolchain for testing leanprover/lean4#8751 * fix * chore: bump to nightly-2025-06-13 * Merge master into nightly-testing * fix * remove upstreamed * drop no-op `show` * chore: bump to nightly-2025-06-14 * chore: bump to nightly-2025-06-15 * intentionally left blank * fix tests * chore: bump to nightly-2025-06-16 * fix upstream * fix * fix * fixes * chore: adaptations for nightly-2025-06-16 * chore: bump to nightly-2025-06-17 * fixes * more fixes * fixes! * more fixes! * hmm * chore: adaptations for nightly-2025-06-17 * chore: adaptations for nightly-2025-06-17 * chore: lint `show` (adaptation for leanprover/lean4#7395) (#25749) Adds `show` as an exception to the unused tactic linter and adds a separate linter for `show`s that should be replaced by `change`. Context: https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/unused.20tactic.20linter.20for.20.60show.60/with/523701633 Co-authored-by: Christian Merten <[email protected]> Co-authored-by: Kenny Lau <[email protected]> Co-authored-by: Fabrizio Barroero <[email protected]> Co-authored-by: Rob23oba <[email protected]> Co-authored-by: leanprover-community-mathlib4-bot <[email protected]> Co-authored-by: Rob23oba <[email protected]> Co-authored-by: Kim Morrison <[email protected]> * chore: bump to nightly-2025-06-18 * chore: adaptations for nightly-2025-06-18 * Merge master into nightly-testing * chore: bump to nightly-2025-06-19 * fix * remove mul_hmul * linter * chore: bump to nightly-2025-06-20 * chore: adaptations for nightly-2025-06-20 --------- Co-authored-by: leanprover-community-mathlib4-bot <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: Joachim Breitner <[email protected]> Co-authored-by: Kim Morrison <[email protected]> Co-authored-by: Sebastian Ullrich <[email protected]> Co-authored-by: mathlib4-bot <[email protected]> Co-authored-by: Mario Carneiro <[email protected]> Co-authored-by: Johan Commelin <[email protected]> Co-authored-by: sgouezel <[email protected]> Co-authored-by: Kyle Miller <[email protected]> Co-authored-by: Rob23oba <[email protected]> Co-authored-by: Rob23oba <[email protected]> Co-authored-by: Christian Merten <[email protected]> Co-authored-by: Kenny Lau <[email protected]> Co-authored-by: Fabrizio Barroero <[email protected]> Co-authored-by: Rob23oba <[email protected]>
1 parent c48b640 commit b8d2609

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

Mathlib/Algebra/CharP/Basic.lean

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,10 @@ end AddMonoidWithOne
207207

208208
section CommRing
209209

210-
instance (α : Type*) [Ring α] (n : ℕ) [CharP α n] : Lean.Grind.IsCharP α n where
211-
ofNat_eq_zero_iff m := by
212-
rw [Semiring.toGrindSemiring_ofNat]
213-
simpa [← Nat.dvd_iff_mod_eq_zero] using CharP.cast_eq_zero_iff α n m
210+
instance (α : Type*) [Semiring α] [IsLeftCancelAdd α] (n : ℕ) [CharP α n] :
211+
Lean.Grind.IsCharP α n where
212+
ofNat_ext_iff {a b} := by
213+
rw [Lean.Grind.Semiring.ofNat_eq_natCast, Lean.Grind.Semiring.ofNat_eq_natCast]
214+
exact CharP.cast_eq_iff_mod_eq α n
214215

215216
end CommRing

Mathlib/Algebra/CharP/Defs.lean

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@ lemma congr {q : ℕ} (h : p = q) : CharP R q := h ▸ ‹CharP R p›
5757

5858
@[simp] lemma cast_eq_zero : (p : R) = 0 := (cast_eq_zero_iff R p p).2 dvd_rfl
5959

60+
lemma cast_eq_mod (k : ℕ) : (k : R) = (k % p : ℕ) :=
61+
have (a : ℕ) : ((p * a : ℕ) : R) = 0 := by
62+
rw [CharP.cast_eq_zero_iff R p]
63+
exact Nat.dvd_mul_right p a
64+
calc
65+
(k : R) = ↑(k % p + p * (k / p)) := by rw [Nat.mod_add_div]
66+
_ = ↑(k % p) := by simp [cast_eq_zero, this]
67+
68+
lemma cast_eq_iff_mod_eq [IsLeftCancelAdd R] : (a:R) = (b:R) ↔ a % p = b % p := by
69+
wlog hle : a ≤ b
70+
· simpa only [eq_comm] using (this _ _ (lt_of_not_ge hle).le)
71+
obtain ⟨c, rfl⟩ := Nat.le.dest hle
72+
rw [Nat.cast_add, left_eq_add, CharP.cast_eq_zero_iff R p]
73+
constructor
74+
· simp +contextual [Nat.add_mod, Nat.dvd_iff_mod_eq_zero]
75+
intro h
76+
have := Nat.sub_mod_eq_zero_of_mod_eq h.symm
77+
simpa [Nat.dvd_iff_mod_eq_zero] using this
78+
6079
-- TODO: This lemma needs to be `@[simp]` for confluence in the presence of `CharP.cast_eq_zero` and
6180
-- `Nat.cast_ofNat`, but with `no_index` on its entire LHS, it matches literally every expression so
6281
-- is too expensive. If https://github.com/leanprover/lean4/issues/2867 is fixed in a performant way, this can be made `@[simp]`.
@@ -178,11 +197,6 @@ section
178197

179198
variable [NonAssocRing R]
180199

181-
lemma cast_eq_mod (p : ℕ) [CharP R p] (k : ℕ) : (k : R) = (k % p : ℕ) :=
182-
calc
183-
(k : R) = ↑(k % p + p * (k / p)) := by rw [Nat.mod_add_div]
184-
_ = ↑(k % p) := by simp [cast_eq_zero]
185-
186200
lemma ringChar_zero_iff_CharZero : ringChar R = 0 ↔ CharZero R := by
187201
rw [ringChar.eq_iff, charP_zero_iff_charZero]
188202

Mathlib/Algebra/Group/Basic.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,7 @@ instance AddCommMonoid.toGrindNatModule [s : AddCommMonoid α] :
10791079
one_hmul := one_nsmul
10801080
add_hmul n m a := add_nsmul a n m
10811081
hmul_zero := nsmul_zero
1082-
hmul_add n a b := nsmul_add a b n
1083-
mul_hmul n m a := mul_nsmul' a n m }
1082+
hmul_add n a b := nsmul_add a b n }
10841083

10851084
instance AddCommGroup.toGrindIntModule [s : AddCommGroup α] :
10861085
Grind.IntModule α :=
@@ -1090,5 +1089,4 @@ instance AddCommGroup.toGrindIntModule [s : AddCommGroup α] :
10901089
one_hmul := one_zsmul
10911090
add_hmul n m a := add_zsmul a n m
10921091
hmul_zero := zsmul_zero
1093-
hmul_add n a b := zsmul_add a b n
1094-
mul_hmul n m a := mul_zsmul a n m }
1092+
hmul_add n a b := zsmul_add a b n }

lean-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
leanprover/lean4:nightly-2025-06-18
1+
leanprover/lean4:nightly-2025-06-20

0 commit comments

Comments
 (0)