Skip to content

Commit a282b18

Browse files
authored
Merge branch 'leanprover-community:master' into uniqueness-riesz
2 parents 6631a3c + bc0b6c6 commit a282b18

484 files changed

Lines changed: 11037 additions & 4225 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/nolints.yml‎

Lines changed: 14 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
if: github.repository == 'leanprover-community/mathlib4'
1313
steps:
14-
- name: cleanup
15-
run: |
16-
find . -name . -o -prune -exec rm -rf -- {} +
17-
18-
# The Hoskinson runners may not have jq installed, so do that now.
19-
- name: 'Setup jq'
20-
uses: dcarbone/install-jq-action@f0e10f46ff84f4d32178b4b76e1ef180b16f82c3 # v3.1.1
21-
2214
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23-
with:
24-
## fetch the whole repository, as we want to push to it later
25-
fetch-depth: 0
26-
27-
- name: prune ProofWidgets .lake
28-
run: |
29-
# The ProofWidgets release contains not just the `.js` (which we need in order to build)
30-
# but also `.oleans`, which may have been built with the wrong toolchain.
31-
# This removes them.
32-
# See discussion at https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/nightly-testing/near/411225235
33-
rm -rf .lake/packages/proofwidgets/.lake/build/lib
34-
rm -rf .lake/packages/proofwidgets/.lake/build/ir
3515

3616
- name: Configure Lean
3717
uses: leanprover/lean-action@f807b338d95de7813c5c50d018f1c23c9b93b4ec # 2025-04-24
@@ -40,31 +20,22 @@ jobs:
4020
use-github-cache: false
4121
use-mathlib-cache: true
4222

43-
- name: build mathlib
44-
id: build
45-
uses: leanprover-community/gh-problem-matcher-wrap@20007cb926a46aa324653a387363b52f07709845 # 2025-04-23
46-
with:
47-
linters: lean
48-
run: |
49-
bash -o pipefail -c "env LEAN_ABORT_ON_PANIC=1 lake build --wfail -KCI"
50-
5123
- name: update nolints.json
5224
shell: bash
5325
run: |
5426
env LEAN_ABORT_ON_PANIC=1 lake exe runLinter --update Mathlib
5527
56-
- name: configure git setup
57-
run: |
58-
git remote add origin-bot "https://leanprover-community-bot:${{ secrets.UPDATE_NOLINTS_TOKEN }}@github.com/leanprover-community/mathlib4.git"
59-
git config user.email "leanprover.community@gmail.com"
60-
git config user.name "leanprover-community-bot"
61-
62-
# By default, github actions overrides the credentials used to access any
63-
# github url so that it uses the github-actions[bot] user. We want to access
64-
# github using a different username.
65-
git config --unset http.https://github.com/.extraheader
66-
67-
- name: file a new PR to update nolints.json
68-
run: ./scripts/update_nolints_CI.sh
69-
env:
70-
DEPLOY_GITHUB_TOKEN: ${{ secrets.UPDATE_NOLINTS_TOKEN }}
28+
- name: Create Pull Request
29+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
30+
with:
31+
token: "${{ secrets.UPDATE_NOLINTS_TOKEN }}"
32+
author: "leanprover-community-bot <leanprover.community@gmail.com>"
33+
commit-message: "chore(scripts): update nolints.json"
34+
branch: "nolints"
35+
base: master
36+
title: "chore(scripts): update nolints.json"
37+
body: |
38+
I am happy to remove some nolints for you!
39+
40+
[workflow run for this PR](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
41+
labels: "auto-merge-after-CI"

‎.github/workflows/update_dependencies.yml‎

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ jobs:
99
update-dependencies:
1010
runs-on: ubuntu-latest
1111
if: github.repository == 'leanprover-community/mathlib4'
12+
env:
13+
BRANCH_NAME: "update-dependencies-bot-use-only"
1214
steps:
1315
- name: Checkout repository
1416
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -23,13 +25,28 @@ jobs:
2325
use-github-cache: false
2426
use-mathlib-cache: false
2527

28+
- name: Get branch SHA if it exists
29+
id: get-branch-sha
30+
run: |
31+
# Check if the branch exists remotely
32+
if git fetch origin "$BRANCH_NAME"; then
33+
SHA=$(git rev-parse "origin/$BRANCH_NAME")
34+
echo "Branch '$BRANCH_NAME' exists with SHA: $SHA"
35+
echo "sha=$SHA" >> "${GITHUB_OUTPUT}"
36+
else
37+
echo "Branch '$BRANCH_NAME' does not exist"
38+
echo "sha=" >>" ${GITHUB_OUTPUT}"
39+
fi
40+
2641
- name: Get PR and labels
42+
if: ${{ steps.get-branch-sha.outputs.sha != '' }}
2743
id: PR # all the steps below are skipped if 'ready-to-merge' is in the list of labels found here
2844
uses: 8BitJonny/gh-get-current-pr@4056877062a1f3b624d5d4c2bedefa9cf51435c9 # 4.0.0
2945
# TODO: this may not work properly if the same commit is pushed to multiple branches:
3046
# https://github.com/8BitJonny/gh-get-current-pr/issues/8
3147
with:
3248
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
sha: ${{ steps.get-branch-sha.outputs.sha }}
3350
# Only return if PR is still open
3451
filterOutClosed: true
3552

@@ -40,12 +57,6 @@ jobs:
4057
prNumber: ${{ steps.PR.outputs.number }}
4158
prUrl: ${{ steps.PR.outputs.pr_url }}
4259

43-
- name: Configure Git User
44-
if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }}
45-
run: |
46-
git config user.name "leanprover-community-mathlib4-bot"
47-
git config user.email "leanprover-community-mathlib4-bot@users.noreply.github.com"
48-
4960
- name: Update dependencies
5061
if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }}
5162
run: lake update -v
@@ -61,22 +72,44 @@ jobs:
6172
echo "toolchain_modified=false" >> "$GITHUB_OUTPUT"
6273
fi
6374
64-
- name: Generate PR title
75+
- name: Check if lake-manifest.json was modified
6576
if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') && steps.check_toolchain.outputs.toolchain_modified != 'true' }}
77+
id: check_manifest
78+
run: |
79+
if [ -n "${{ steps.get-branch-sha.outputs.sha }}" ]; then
80+
# Branch exists, compare the file
81+
if git diff --quiet HEAD "origin/$BRANCH_NAME" -- lake-manifest.json; then
82+
echo "has_diff=false" >> "${GITHUB_OUTPUT}"
83+
echo "No differences in lake-manifest.json"
84+
else
85+
echo "has_diff=true" >> "${GITHUB_OUTPUT}"
86+
echo "Differences found in lake-manifest.json"
87+
fi
88+
else
89+
# Branch doesn't exist, consider it as different
90+
echo "has_diff=true" >> "${GITHUB_OUTPUT}"
91+
echo "Branch does not exist, treating as different"
92+
fi
93+
94+
- name: Generate PR title
95+
if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') && steps.check_manifest.outputs.has_diff == 'true' }}
6696
run: |
6797
echo "timestamp=$(date -u +"%Y-%m-%d-%H-%M")" >> "$GITHUB_ENV"
6898
echo "pr_title=chore: update Mathlib dependencies $(date -u +"%Y-%m-%d")" >> "$GITHUB_ENV"
6999
70100
- name: Create Pull Request
71-
if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') && steps.check_toolchain.outputs.toolchain_modified != 'true' }}
101+
if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') && steps.check_manifest.outputs.has_diff == 'true' }}
72102
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
73103
with:
74104
token: "${{ secrets.UPDATE_DEPENDENCIES_TOKEN }}"
75105
author: "leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com>"
76106
commit-message: "chore: update Mathlib dependencies ${{ env.timestamp }}"
77107
# this branch is referenced in update_dependencies_zulip.yml
78-
branch: "update-dependencies-bot-use-only"
108+
branch: ${{ env.BRANCH_NAME }}
79109
base: master
80110
title: "${{ env.pr_title }}"
81-
body: "This PR updates the Mathlib dependencies."
111+
body: |
112+
This PR updates the Mathlib dependencies.
113+
114+
[workflow run for this PR](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
82115
labels: "auto-merge-after-CI"

‎Archive/Arithcc.lean‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ protected theorem StateEq.refl (t : Register) (ζ : State) : ζ ≃[t] ζ := by
209209

210210
@[symm]
211211
protected theorem StateEq.symm {t : Register} (ζ₁ ζ₂ : State) : ζ₁ ≃[t] ζ₂ → ζ₂ ≃[t] ζ₁ := by
212-
simp [StateEq]; intros
212+
simp only [StateEq, and_imp]; intros
213213
constructor <;> (symm; assumption)
214214

215215
@[trans]
216216
protected theorem StateEq.trans {t : Register} (ζ₁ ζ₂ ζ₃ : State) :
217217
ζ₁ ≃[t] ζ₂ → ζ₂ ≃[t] ζ₃ → ζ₁ ≃[t] ζ₃ := by
218-
simp [StateEq]; intros
218+
simp only [StateEq, and_imp]; intros
219219
constructor
220220
· simp_all only
221221
· trans ζ₂ <;> assumption
@@ -227,7 +227,7 @@ instance (t : Register) : Trans (StateEq (t + 1)) (StateEq (t + 1)) (StateEq (t
227227
@[trans]
228228
protected theorem StateEqStateEqRs.trans (t : Register) (ζ₁ ζ₂ ζ₃ : State) :
229229
ζ₁ ≃[t] ζ₂ → ζ₂ ≃[t]/ac ζ₃ → ζ₁ ≃[t]/ac ζ₃ := by
230-
simp [StateEq]; intros
230+
simp only [StateEq, and_imp]; intros
231231
trans ζ₂ <;> assumption
232232

233233
instance (t : Register) : Trans (StateEq (t + 1)) (StateEqRs (t + 1)) (StateEqRs (t + 1)) :=
@@ -236,7 +236,7 @@ instance (t : Register) : Trans (StateEq (t + 1)) (StateEqRs (t + 1)) (StateEqRs
236236
/-- Writing the same value to register `t` gives `≃[t + 1]` from `≃[t]`. -/
237237
theorem stateEq_implies_write_eq {t : Register} {ζ₁ ζ₂ : State} (h : ζ₁ ≃[t] ζ₂) (v : Word) :
238238
write t v ζ₁ ≃[t + 1] write t v ζ₂ := by
239-
simp [StateEq, StateEqRs] at *
239+
simp only [StateEq, StateEqRs, write] at *
240240
constructor; · exact h.1
241241
intro r hr
242242
have hr : r ≤ t := Register.le_of_lt_succ hr
@@ -249,15 +249,15 @@ theorem stateEq_implies_write_eq {t : Register} {ζ₁ ζ₂ : State} (h : ζ₁
249249
/-- Writing the same value to any register preserves `≃[t]/ac`. -/
250250
theorem stateEqRs_implies_write_eq_rs {t : Register} {ζ₁ ζ₂ : State} (h : ζ₁ ≃[t]/ac ζ₂)
251251
(r : Register) (v : Word) : write r v ζ₁ ≃[t]/ac write r v ζ₂ := by
252-
simp [StateEqRs] at *
252+
simp only [StateEqRs, write] at *
253253
intro r' hr'
254254
specialize h r' hr'
255255
congr
256256

257257
/-- `≃[t + 1]` with writing to register `t` implies `≃[t]`. -/
258258
theorem write_eq_implies_stateEq {t : Register} {v : Word} {ζ₁ ζ₂ : State}
259259
(h : ζ₁ ≃[t + 1] write t v ζ₂) : ζ₁ ≃[t] ζ₂ := by
260-
simp [StateEq, StateEqRs] at *
260+
simp only [StateEq, write, StateEqRs] at *
261261
constructor; · exact h.1
262262
intro r hr
263263
obtain ⟨_, h⟩ := h
@@ -313,10 +313,10 @@ theorem compiler_correctness
313313
have hζ₃ : ζ₃ ≃[t + 1] { write t ν₁ η with ac := ν₂ } := calc
314314
ζ₃ = outcome (compile map e_s₂ (t + 1)) ζ₂ := by simp_all
315315
_ ≃[t + 1] { ζ₂ with ac := ν₂ } := by apply e_ih_s₂ <;> assumption
316-
_ ≃[t + 1] { write t ν₁ η with ac := ν₂ } := by simp [StateEq]; apply hζ₂
316+
_ ≃[t + 1] { write t ν₁ η with ac := ν₂ } := by simpa [StateEq]
317317
have hζ₃_ν₂ : ζ₃.ac = ν₂ := by simp_all [StateEq]
318318
have hζ₃_ν₁ : read t ζ₃ = ν₁ := by
319-
simp [StateEq, StateEqRs] at hζ₃ ⊢
319+
simp only [StateEq, StateEqRs, write, read] at hζ₃ ⊢
320320
obtain ⟨_, hζ₃⟩ := hζ₃
321321
specialize hζ₃ t (Register.lt_succ_self _)
322322
simp_all

‎Archive/Imo/Imo2008Q2.lean‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ theorem imo2008_q2a (x y z : ℝ) (h : x * y * z = 1) (hx : x ≠ 1) (hy : y ≠
4646
x ^ 2 / (x - 1) ^ 2 + y ^ 2 / (y - 1) ^ 2 + z ^ 2 / (z - 1) ^ 2 ≥ 1 := by
4747
obtain ⟨a, b, c, ha, hb, hc, rfl, rfl, rfl⟩ := subst_abc h
4848
obtain ⟨m, n, rfl, rfl⟩ : ∃ m n, b = c - m ∧ a = c - m - n := by use c - b, b - a; simp
49-
have hm_ne_zero : m ≠ 0 := by contrapose! hy; simp [field]; assumption
50-
have hn_ne_zero : n ≠ 0 := by contrapose! hx; simp [field]; assumption
49+
have hm_ne_zero : m ≠ 0 := by contrapose! hy; simpa [field]
50+
have hn_ne_zero : n ≠ 0 := by contrapose! hx; simpa [field]
5151
have hmn_ne_zero : m + n ≠ 0 := by contrapose! hz; field_simp; linarith
5252
have hc_sub_sub : c - (c - m - n) = m + n := by abel
5353
rw [ge_iff_le, ← sub_nonneg]

‎Archive/Wiedijk100Theorems/CubingACube.lean‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ theorem mi_not_onBoundary (j : Fin n) : ¬OnBoundary (mi_mem_bcubes : mi h v ∈
401401
suffices ∀ j : Fin n, ite (j = j') x' ((cs i).b j.succ) ∈ c.side j.succ by
402402
simpa [p', bottom, toSet, tail, side_tail]
403403
intro j₂
404-
by_cases hj₂ : j₂ = j'; · simp [hj₂]; apply tail_sub h2i'; apply hx'.1
404+
by_cases hj₂ : j₂ = j'; · simpa [hj₂] using tail_sub h2i' _ hx'.1
405405
simp only [if_false, hj₂]; apply tail_sub hi; apply b_mem_side
406406
rcases v.1 hp' with ⟨_, ⟨i'', rfl⟩, hi''⟩
407407
have h2i'' : i'' ∈ bcubes cs c := ⟨hi''.1.symm, v.2.1 i'' hi''.1.symm ⟨tail p', hi''.2, hp'.2⟩⟩

‎Counterexamples.lean‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Counterexamples.MonicNonRegular
1515
import Counterexamples.Motzkin
1616
import Counterexamples.OrderedCancelAddCommMonoidWithBounds
1717
import Counterexamples.Phillips
18+
import Counterexamples.PolynomialIsDomain
1819
import Counterexamples.Pseudoelement
1920
import Counterexamples.QuadraticForm
2021
import Counterexamples.SeminormLatticeNotDistrib

‎Counterexamples/Phillips.lean‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ theorem discretePart_apply (f : BoundedAdditiveMeasure α) (s : Set α) :
360360

361361
theorem continuousPart_apply_eq_zero_of_countable (f : BoundedAdditiveMeasure α) (s : Set α)
362362
(hs : s.Countable) : f.continuousPart s = 0 := by
363-
simp [continuousPart]
363+
simp only [continuousPart, restrict_apply]
364364
convert f.apply_countable s hs using 2
365365
ext x
366366
simp [and_comm]
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/-
2+
Copyright (c) 2025 Junyan Xu. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Junyan Xu
5+
-/
6+
import Mathlib.Algebra.GroupWithZero.TransferInstance
7+
import Mathlib.Algebra.Order.Ring.Nat
8+
import Mathlib.Algebra.Ring.Equiv
9+
import Mathlib.RingTheory.Polynomial.Opposites
10+
11+
/-!
12+
# A commutative semiring that is a domain whose polynomial semiring is not a domain
13+
14+
`NatMaxAdd` is the natural numbers equipped with the usual multiplication but with maximum as
15+
addition. Under these operations it is a commutative semiring that is a domain, but
16+
`1 + 1 = 1 + 0 = 1` in this semiring so addition is not cancellative.
17+
As a consequence, the polynomial semiring `NatMaxAdd[X]` is not a domain,
18+
even though it has no zero-divisors other than 0.
19+
-/
20+
21+
/-- A type synonym for ℕ equipped with maximum as addition. -/
22+
def NatMaxAdd := ℕ
23+
24+
open scoped Polynomial
25+
26+
namespace NatMaxAdd
27+
28+
/-- Identification of `NatMaxAdd` with `ℕ`. -/
29+
protected abbrev mk : ℕ ≃ NatMaxAdd := Equiv.refl _
30+
31+
attribute [irreducible] NatMaxAdd
32+
33+
open NatMaxAdd (mk)
34+
35+
instance : AddCommSemigroup NatMaxAdd where
36+
add a b := mk (mk.symm a ⊔ mk.symm b)
37+
add_assoc _ _ _ := mk.symm.injective (sup_assoc ..)
38+
add_comm _ _ := mk.symm.injective (sup_comm ..)
39+
40+
instance : AddZeroClass NatMaxAdd where
41+
zero := mk 0
42+
zero_add _ := mk.symm.injective (bot_sup_eq _)
43+
add_zero _ := mk.symm.injective (sup_bot_eq _)
44+
45+
instance : CommMonoidWithZero NatMaxAdd := mk.symm.commMonoidWithZero
46+
47+
/-- `NatMaxAdd` is isomorphic to `ℕ` multiplicatively. -/
48+
protected def mulEquiv : NatMaxAdd ≃* ℕ where
49+
__ := mk.symm
50+
map_mul' _ _ := rfl
51+
52+
instance : CommSemiring NatMaxAdd where
53+
nsmul := nsmulRec
54+
left_distrib _ _ _ := mk.symm.injective (Nat.mul_max_mul_left ..).symm
55+
right_distrib _ _ _ := mk.symm.injective (Nat.mul_max_mul_right ..).symm
56+
57+
instance : IsDomain NatMaxAdd := NatMaxAdd.mulEquiv.isDomain
58+
59+
theorem natCast_eq_one (n : ℕ) : ∀ [NeZero n], (n : NatMaxAdd) = 1 := by
60+
induction n with
61+
| zero => intro; exact (NeZero.ne 0 rfl).elim
62+
| succ n ih =>
63+
obtain _ | n := n
64+
· intro; rfl
65+
· rw [Nat.cast_succ, ih]; intro; rfl
66+
67+
theorem not_isCancelAdd : ¬ IsCancelAdd NatMaxAdd := fun h ↦ by cases @h.1.1 1 0 1 rfl
68+
69+
theorem not_isDomain_polynomial : ¬ IsDomain NatMaxAdd[X] :=
70+
Polynomial.isDomain_iff.not.mpr fun h ↦ not_isCancelAdd h.2
71+
72+
theorem noZeroDivisors_polynomial : NoZeroDivisors NatMaxAdd[X] := inferInstance
73+
74+
end NatMaxAdd
75+
76+
theorem not_isDomain_commSemiring_imp_isDomain_polynomial :
77+
¬ ∀ (R : Type) [CommSemiring R] [IsDomain R], IsDomain R[X] :=
78+
fun h ↦ NatMaxAdd.not_isDomain_polynomial (h _)

0 commit comments

Comments
 (0)