Skip to content

Commit d1af079

Browse files
Merge master into nightly-testing
2 parents 2967019 + b991a31 commit d1af079

110 files changed

Lines changed: 1108 additions & 373 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/actions/get-mathlib-ci/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inputs:
1010
# Default pinned commit used by workflows unless they explicitly override.
1111
# Update this ref as needed to pick up changes to mathlib-ci scripts
1212
# This is also updated automatically by .github/workflows/update_dependencies.yml
13-
default: 4db29a340d585b5ca9cc45ba5b951a3939753d53
13+
default: a498f841ad55c852a9203fba855432b922a1b653
1414
path:
1515
description: Checkout destination path.
1616
required: false
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Populates `tools-branch/` with the trusted CI tooling (`cache` binary + the
2+
# `lake-build-*` helper scripts) that `build_template.yml` invokes by path.
3+
#
4+
# Fast path: download the `tools-bin` artifact published by `publish_tools.yml`
5+
# from its latest successful `master` `push` run, unpack it, and install the
6+
# matching toolchain. Fallback: check out `tools_source_ref` and build from source
7+
# (the original behaviour). The fallback also triggers automatically if anything
8+
# about the download/verification fails, so this action can never make CI worse
9+
# than building from source.
10+
#
11+
# Requires (fast path only): `actions: read` permission. The `gh` CLI is provided
12+
# by the Hoskinson runner image. Any lookup/download failure falls through to the
13+
# source build, so the fast path can never make CI worse.
14+
name: Get CI tools
15+
description: Download prebuilt CI tools from master, or build them from source.
16+
inputs:
17+
use_artifact:
18+
description: Whether to attempt the prebuilt-artifact fast path ('true'/'false').
19+
required: true
20+
tools_source_ref:
21+
description: Git ref to check out and build from when not using the artifact.
22+
required: true
23+
github_token:
24+
description: "Token with `actions: read` on artifact_repo (fast path only)."
25+
required: false
26+
default: ''
27+
artifact_repo:
28+
description: Repository that publishes the tools artifact.
29+
required: false
30+
default: leanprover-community/mathlib4
31+
artifact_workflow:
32+
description: Workflow file that publishes the tools artifact.
33+
required: false
34+
default: publish_tools.yml
35+
path:
36+
description: Destination directory for the tools.
37+
required: false
38+
default: tools-branch
39+
runs:
40+
using: composite
41+
steps:
42+
# Resolve the run-id of the latest successful master push of the publisher.
43+
# Pure lookup: on any failure (or when the fast path is disabled) we emit an
44+
# empty run_id, which skips the download and lands us on the source-build path.
45+
- name: Resolve tools artifact run
46+
id: resolve
47+
shell: bash
48+
env:
49+
GH_TOKEN: ${{ inputs.github_token }}
50+
run: |
51+
set -uo pipefail
52+
run_id=""
53+
if [[ "${{ inputs.use_artifact }}" == "true" && -n "${{ inputs.github_token }}" ]]; then
54+
run_id=$(gh run list \
55+
--repo "${{ inputs.artifact_repo }}" \
56+
--workflow "${{ inputs.artifact_workflow }}" \
57+
--branch master --status success --event push \
58+
--limit 1 --json databaseId --jq '.[0].databaseId // empty' 2>/dev/null || true)
59+
fi
60+
echo "Resolved publisher run_id: '${run_id}'"
61+
echo "run_id=${run_id}" >> "$GITHUB_OUTPUT"
62+
63+
- name: Download tools artifact
64+
if: ${{ steps.resolve.outputs.run_id != '' }}
65+
continue-on-error: true
66+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
67+
with:
68+
name: tools-bin
69+
path: tools-artifact
70+
repository: ${{ inputs.artifact_repo }}
71+
run-id: ${{ steps.resolve.outputs.run_id }}
72+
github-token: ${{ inputs.github_token }}
73+
74+
# Unpack the tools and install the toolchain the `cache` binary was linked
75+
# against (the one guarantee the old `lake build` of the tools gave us for
76+
# free). If the tarball is missing, the unpack fails, or the toolchain won't
77+
# install, wipe any partial state and signal a source build.
78+
- name: Unpack tools
79+
id: finalize
80+
shell: bash
81+
run: |
82+
set -uo pipefail
83+
result=build
84+
tarball="tools-artifact/tools-bin.tar.gz"
85+
if [[ -f "$tarball" ]]; then
86+
echo "Found downloaded tools artifact; unpacking..."
87+
rm -rf "${{ inputs.path }}"
88+
mkdir -p "${{ inputs.path }}"
89+
if tar -xzf "$tarball" -C "${{ inputs.path }}" \
90+
&& [[ -x "${{ inputs.path }}/.lake/build/bin/cache" ]]; then
91+
toolchain="$(cat "${{ inputs.path }}/lean-toolchain")"
92+
echo "Ensuring tools toolchain is installed: ${toolchain}"
93+
# `elan toolchain install` exits non-zero when the toolchain is already
94+
# present (the common case), so install best-effort and then confirm the
95+
# toolchain is available rather than trusting the install exit code.
96+
elan toolchain install "$toolchain" || true
97+
if elan toolchain list | awk '{print $1}' | grep -qxF "$toolchain"; then
98+
result=artifact
99+
else
100+
echo "WARNING: tools toolchain '${toolchain}' is not available; falling back to source build."
101+
fi
102+
else
103+
echo "WARNING: tools artifact unpack/validation failed; falling back to source build."
104+
fi
105+
else
106+
echo "No tools artifact available; will build from source."
107+
fi
108+
if [[ "$result" != "artifact" ]]; then
109+
rm -rf "${{ inputs.path }}"
110+
fi
111+
echo "Tools source: ${result}"
112+
echo "result=${result}" >> "$GITHUB_OUTPUT"
113+
114+
- name: Checkout tools branch (source build)
115+
if: ${{ steps.finalize.outputs.result == 'build' }}
116+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
117+
with:
118+
ref: ${{ inputs.tools_source_ref }}
119+
path: ${{ inputs.path }}
120+
121+
- name: Build tools from source
122+
if: ${{ steps.finalize.outputs.result == 'build' }}
123+
shell: bash # We're only building a trusted branch with the tools, so no need to run inside landrun.
124+
run: |
125+
cd "${{ inputs.path }}"
126+
lake build cache check-yaml graph
127+
ls .lake/build/bin/cache
128+
ls .lake/build/bin/check-yaml
129+
ls .lake/packages/importGraph/.lake/build/bin/graph

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ concurrency:
2424
permissions:
2525
contents: read
2626
id-token: write
27+
actions: read # Allow get-tools to download the prebuilt tools artifact from master's publish_tools runs
2728
pull-requests: write # Only allow PR comments/labels
2829
# All other permissions are implicitly 'none'
2930

.github/workflows/build_fork.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ concurrency:
2525
permissions:
2626
contents: read
2727
id-token: write
28+
actions: read # Allow get-tools to download the prebuilt tools artifact from master's publish_tools runs
2829
pull-requests: write # Only allow PR comments/labels
2930
# All other permissions are implicitly 'none'
3031

.github/workflows/build_template.yml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,6 @@ jobs:
9393
- name: 'Setup jq'
9494
uses: dcarbone/install-jq-action@b7ef57d46ece78760b4019dbc4080a1ba2a40b45 # v3.2.0
9595

96-
# Checkout a trusted branch to build the tooling from
97-
- name: Checkout tools branch
98-
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
99-
with:
100-
# Recall that on the `leanprover-community/mathlib4-nightly-testing` repository,
101-
# we don't maintain a `master` branch at all.
102-
# For PRs and pushes to this repository, we will use `nightly-testing-green` instead,
103-
# so that even when `nightly-testing` is broken, we can still build tools from a known good state.
104-
ref: ${{ inputs.tools_branch_ref != '' && inputs.tools_branch_ref || (github.repository == 'leanprover-community/mathlib4-nightly-testing' && 'nightly-testing-green' || 'master') }}
105-
path: tools-branch
106-
10796
- name: Checkout local actions
10897
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
10998
with:
@@ -208,14 +197,22 @@ jobs:
208197
# Set it as an environment variable for subsequent steps
209198
echo "LEAN_SRC_PATH=$LEAN_SRC_PATH" >> "$GITHUB_ENV"
210199
211-
- name: build tools-branch tools
212-
shell: bash # We're only building a trusted branch with the tools, so no need to run inside landrun.
213-
run: |
214-
cd tools-branch
215-
lake build cache check-yaml graph
216-
ls .lake/build/bin/cache
217-
ls .lake/build/bin/check-yaml
218-
ls .lake/packages/importGraph/.lake/build/bin/graph
200+
# Populate `tools-branch/` with the trusted CI tooling (the `cache` binary and
201+
# the `lake-build-*` helper scripts invoked by path below). On the common path
202+
# this downloads the prebuilt `tools-bin` artifact published from `master` by
203+
# `publish_tools.yml`; otherwise (bors/ci_dev overrides, nightly-testing, or any
204+
# download failure) it falls back to checking out and building from source.
205+
#
206+
# Recall that on the `leanprover-community/mathlib4-nightly-testing` repository,
207+
# we don't maintain a `master` branch at all. For PRs and pushes to this
208+
# repository, we build tools from `nightly-testing-green` instead, so that even
209+
# when `nightly-testing` is broken, we can still build tools from a known good state.
210+
- name: Get CI tools
211+
uses: ./workflow-actions/.github/actions/get-tools
212+
with:
213+
use_artifact: ${{ inputs.tools_branch_ref == '' && github.repository == 'leanprover-community/mathlib4' }}
214+
tools_source_ref: ${{ inputs.tools_branch_ref != '' && inputs.tools_branch_ref || (github.repository == 'leanprover-community/mathlib4-nightly-testing' && 'nightly-testing-green' || 'master') }}
215+
github_token: ${{ github.token }}
219216

220217
- name: download dependencies
221218
# We need network access to download dependencies

.github/workflows/labels_from_comment.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ jobs:
4545
inComment=""
4646
label="${labelArray[$i]}"
4747
printf $'\nProcessing label \'%s\'\n' "${label}"
48-
# extract the last line that, up to leading/trailing whitespace, matches the current label
49-
inComment="$(printf '%s' "${COMMENT}" | grep "[-]\?${label}$" | tail -1)"
48+
# extract the last line whose *entire* content (up to leading/trailing
49+
# whitespace, already stripped above) is the label, optionally preceded
50+
# by `-`. Anchoring both ends (not just `$`) is what stops bot directives
51+
# such as `!downstream-check FLT` — and the downstream-reports automation
52+
# comments — from being mistaken for a label request just because the line
53+
# happens to end in a label name.
54+
inComment="$(printf '%s' "${COMMENT}" | grep "^[-]\?${label}$" | tail -1)"
5055
if [ -n "${inComment}" ]
5156
then
5257
printf $'Found \'%s\'\n' "${inComment}"

Counterexamples/Phillips.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ theorem exists_discrete_support_nonpos (f : BoundedAdditiveMeasure α) :
283283
have I1 : ∀ n, ε / 2 ≤ f (↑(s (n + 1)) \ ↑(s n)) := by
284284
intro n
285285
rw [div_le_iff₀' (show (0 : ℝ) < 2 by simp), hε]
286-
convert hF (s n) u using 2
286+
convert! hF (s n) u using 2
287287
· ext x
288288
simp only [u, not_exists, mem_iUnion, mem_diff]
289289
tauto

Mathlib.lean

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3370,6 +3370,7 @@ public import Mathlib.CategoryTheory.Sites.Hypercover.SheafOfTypes
33703370
public import Mathlib.CategoryTheory.Sites.Hypercover.Subcanonical
33713371
public import Mathlib.CategoryTheory.Sites.Hypercover.Zero
33723372
public import Mathlib.CategoryTheory.Sites.Hypercover.ZeroFamily
3373+
public import Mathlib.CategoryTheory.Sites.InducedTopology
33733374
public import Mathlib.CategoryTheory.Sites.IsSheafFor
33743375
public import Mathlib.CategoryTheory.Sites.JointlySurjective
33753376
public import Mathlib.CategoryTheory.Sites.LeftExact
@@ -3860,6 +3861,7 @@ public import Mathlib.Data.Fin.Tuple.Take
38603861
public import Mathlib.Data.Fin.VecNotation
38613862
public import Mathlib.Data.FinEnum
38623863
public import Mathlib.Data.FinEnum.Option
3864+
public import Mathlib.Data.Finite.Card
38633865
public import Mathlib.Data.Finite.Defs
38643866
public import Mathlib.Data.Finite.Perm
38653867
public import Mathlib.Data.Finite.Prod
@@ -3978,6 +3980,7 @@ public import Mathlib.Data.Fintype.Shrink
39783980
public import Mathlib.Data.Fintype.Sigma
39793981
public import Mathlib.Data.Fintype.Sort
39803982
public import Mathlib.Data.Fintype.Sum
3983+
public import Mathlib.Data.Fintype.Units
39813984
public import Mathlib.Data.Fintype.Vector
39823985
public import Mathlib.Data.Fintype.WithTopBot
39833986
public import Mathlib.Data.FunLike.Basic
@@ -4090,14 +4093,19 @@ public import Mathlib.Data.List.TakeWhile
40904093
public import Mathlib.Data.List.ToFinsupp
40914094
public import Mathlib.Data.List.Triplewise
40924095
public import Mathlib.Data.List.Zip
4096+
public import Mathlib.Data.Matrix.Action
40934097
public import Mathlib.Data.Matrix.Auto
40944098
public import Mathlib.Data.Matrix.Basic
40954099
public import Mathlib.Data.Matrix.Basis
4100+
public import Mathlib.Data.Matrix.Bilinear
40964101
public import Mathlib.Data.Matrix.Block
4102+
public import Mathlib.Data.Matrix.Cartan
40974103
public import Mathlib.Data.Matrix.ColumnRowPartitioned
40984104
public import Mathlib.Data.Matrix.Composition
40994105
public import Mathlib.Data.Matrix.DMatrix
41004106
public import Mathlib.Data.Matrix.Diagonal
4107+
public import Mathlib.Data.Matrix.DualNumber
4108+
public import Mathlib.Data.Matrix.Invertible
41014109
public import Mathlib.Data.Matrix.Mul
41024110
public import Mathlib.Data.Matrix.PEquiv
41034111
public import Mathlib.Data.Matrix.Reflection
@@ -4273,6 +4281,7 @@ public import Mathlib.Data.QPF.Multivariate.Constructions.Sigma
42734281
public import Mathlib.Data.QPF.Univariate.Basic
42744282
public import Mathlib.Data.Quot
42754283
public import Mathlib.Data.Rat.BigOperators
4284+
public import Mathlib.Data.Rat.Cardinal
42764285
public import Mathlib.Data.Rat.Cast.CharZero
42774286
public import Mathlib.Data.Rat.Cast.Defs
42784287
public import Mathlib.Data.Rat.Cast.Lemmas
@@ -4285,16 +4294,21 @@ public import Mathlib.Data.Rat.Floor
42854294
public import Mathlib.Data.Rat.Init
42864295
public import Mathlib.Data.Rat.Lemmas
42874296
public import Mathlib.Data.Rat.NatSqrt.Defs
4297+
public import Mathlib.Data.Rat.NatSqrt.Real
42884298
public import Mathlib.Data.Rat.Sqrt
42894299
public import Mathlib.Data.Rat.Star
4300+
public import Mathlib.Data.Real.Archimedean
42904301
public import Mathlib.Data.Real.Basic
42914302
public import Mathlib.Data.Real.CompleteField
42924303
public import Mathlib.Data.Real.ConjExponents
42934304
public import Mathlib.Data.Real.ENatENNReal
42944305
public import Mathlib.Data.Real.Embedding
4306+
public import Mathlib.Data.Real.Hom
42954307
public import Mathlib.Data.Real.Pointwise
42964308
public import Mathlib.Data.Real.Sign
4309+
public import Mathlib.Data.Real.Sqrt
42974310
public import Mathlib.Data.Real.Star
4311+
public import Mathlib.Data.Real.StarOrdered
42984312
public import Mathlib.Data.Rel
42994313
public import Mathlib.Data.Rel.Cover
43004314
public import Mathlib.Data.Rel.Separated
@@ -4517,6 +4531,7 @@ public import Mathlib.FieldTheory.PerfectClosure
45174531
public import Mathlib.FieldTheory.PolynomialGaloisGroup
45184532
public import Mathlib.FieldTheory.PrimeField
45194533
public import Mathlib.FieldTheory.PrimitiveElement
4534+
public import Mathlib.FieldTheory.PurelyInseparable.AdjoinPthRoots
45204535
public import Mathlib.FieldTheory.PurelyInseparable.Basic
45214536
public import Mathlib.FieldTheory.PurelyInseparable.Exponent
45224537
public import Mathlib.FieldTheory.PurelyInseparable.PerfectClosure

Mathlib/Algebra/BigOperators/Pi.lean

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public import Mathlib.Algebra.Group.Action.Pi
1212
public import Mathlib.Algebra.Notation.Indicator
1313
public import Mathlib.Algebra.Ring.Pi
1414
public import Mathlib.Data.Fintype.Basic
15+
public import Mathlib.Data.FunLike.IsApply
1516

1617
/-!
1718
# Big operators for Pi Types
@@ -230,3 +231,21 @@ theorem eqOn_fun_finsetProd {ι α β : Type*} [CommMonoid α]
230231
convert! eqOn_finsetProd h v <;> simp
231232

232233
end EqOn
234+
235+
section FunLike
236+
237+
variable {F α β ι : Type*} [FunLike F α β] [CommMonoid β] [CommMonoid F]
238+
[IsOneApply F α β] [IsMulApply F α β]
239+
240+
open Classical in
241+
@[to_additive (attr := simp, grind =)]
242+
theorem prod_apply (s : Finset ι) (f : ι → F) (x : α) : (∏ i ∈ s, f i) x = ∏ i ∈ s, f i x := by
243+
induction s using Finset.induction_on with
244+
| empty => simp
245+
| insert i s his h => simp [his, h]
246+
247+
@[to_additive (attr := norm_cast)]
248+
theorem FunLike.coe_prod (s : Finset ι) (f : ι → F) : ↑(∏ i ∈ s, f i) = ∏ i ∈ s, (f i : α → β) := by
249+
ext; simp
250+
251+
end FunLike

Mathlib/Algebra/Group/End.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ instance : Inhabited (Function.End α) := ⟨1⟩
6363

6464
namespace Equiv.Perm
6565

66-
attribute [to_additive_dont_translate] Perm
66+
attribute [to_additive_dont_translate] Perm Equiv
6767

6868
instance instOne : One (Perm α) where one := Equiv.refl _
6969
instance instMul : Mul (Perm α) where mul f g := Equiv.trans g f

0 commit comments

Comments
 (0)