Skip to content

Commit 9022c1d

Browse files
Merge branch 'leanprover:master' into toInt-smod
2 parents 56508db + 9982bab commit 9022c1d

File tree

668 files changed

+189020
-180939
lines changed

Some content is hidden

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

668 files changed

+189020
-180939
lines changed

.github/workflows/awaiting-mathlib.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,26 @@ jobs:
1414
uses: actions/github-script@v7
1515
with:
1616
script: |
17-
const { labels } = context.payload.pull_request;
18-
if (labels.some(label => label.name == "awaiting-mathlib") && !labels.some(label => label.name == "builds-mathlib")) {
19-
core.setFailed('PR is marked "awaiting-mathlib" but "builds-mathlib" label has not been applied yet by the bot');
17+
const { labels, number: prNumber } = context.payload.pull_request;
18+
const hasAwaiting = labels.some(label => label.name == "awaiting-mathlib");
19+
const hasBreaks = labels.some(label => label.name == "breaks-mathlib");
20+
const hasBuilds = labels.some(label => label.name == "builds-mathlib");
21+
22+
if (hasAwaiting && hasBreaks) {
23+
core.setFailed('PR has both "awaiting-mathlib" and "breaks-mathlib" labels.');
24+
} else if (hasAwaiting && !hasBreaks && !hasBuilds) {
25+
// Create a neutral check run (yellow circle)
26+
const octokit = github.getOctokit(process.env.GITHUB_TOKEN);
27+
await octokit.rest.checks.create({
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
name: "awaiting-mathlib label check",
31+
head_sha: context.payload.pull_request.head.sha,
32+
status: "completed",
33+
conclusion: "neutral",
34+
output: {
35+
title: "Awaiting mathlib",
36+
summary: 'PR is marked "awaiting-mathlib" but neither "breaks-mathlib" nor "builds-mathlib" labels are present.'
37+
}
38+
});
2039
}

.github/workflows/update-stage0.yml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,34 +40,24 @@ jobs:
4040
run: |
4141
git config --global user.name "Lean stage0 autoupdater"
4242
git config --global user.email "<>"
43-
# Would be nice, but does not work yet:
44-
# https://github.com/DeterminateSystems/magic-nix-cache/issues/39
45-
# This action does not run that often and building runs in a few minutes, so ok for now
46-
#- if: env.should_update_stage0 == 'yes'
47-
# uses: DeterminateSystems/magic-nix-cache-action@v2
48-
- if: env.should_update_stage0 == 'yes'
49-
name: Restore Build Cache
50-
uses: actions/cache/restore@v4
51-
with:
52-
path: nix-store-cache
53-
key: Nix Linux-nix-store-cache-${{ github.sha }}
54-
# fall back to (latest) previous cache
55-
restore-keys: |
56-
Nix Linux-nix-store-cache
57-
- if: env.should_update_stage0 == 'yes'
58-
name: Further Set Up Nix Cache
59-
shell: bash -euxo pipefail {0}
60-
run: |
61-
# Nix seems to mutate the cache, so make a copy
62-
cp -r nix-store-cache nix-store-cache-copy || true
6343
- if: env.should_update_stage0 == 'yes'
6444
name: Install Nix
6545
uses: DeterminateSystems/nix-installer-action@main
66-
with:
67-
extra-conf: |
68-
substituters = file://${{ github.workspace }}/nix-store-cache-copy?priority=10&trusted=true https://cache.nixos.org
46+
- name: Open Nix shell once
47+
if: env.should_update_stage0 == 'yes'
48+
run: true
49+
shell: 'nix develop -c bash -euxo pipefail {0}'
50+
- name: Set up NPROC
51+
if: env.should_update_stage0 == 'yes'
52+
run: |
53+
echo "NPROC=$(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo 4)" >> $GITHUB_ENV
54+
shell: 'nix develop -c bash -euxo pipefail {0}'
55+
- if: env.should_update_stage0 == 'yes'
56+
run: cmake --preset release
57+
shell: 'nix develop -c bash -euxo pipefail {0}'
6958
- if: env.should_update_stage0 == 'yes'
70-
run: nix run .#update-stage0-commit
59+
run: make -j$NPROC -C build/release update-stage0-commit
60+
shell: 'nix develop -c bash -euxo pipefail {0}'
7161
- if: env.should_update_stage0 == 'yes'
7262
run: git show --stat
7363
- if: env.should_update_stage0 == 'yes' && github.event_name == 'push'

src/Init/Control/Lawful/Basic.lean

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Authors: Sebastian Ullrich, Leonardo de Moura, Mario Carneiro
66
module
77

88
prelude
9+
import Init.Ext
910
import Init.SimpLemmas
1011
import Init.Meta
1112

@@ -241,13 +242,23 @@ theorem LawfulMonad.mk' (m : Type u → Type v) [Monad m]
241242

242243
namespace Id
243244

244-
@[simp] theorem map_eq (x : Id α) (f : α → β) : f <$> x = f x := rfl
245-
@[simp] theorem bind_eq (x : Id α) (f : α → id β) : x >>= f = f x := rfl
246-
@[simp] theorem pure_eq (a : α) : (pure a : Id α) = a := rfl
245+
@[ext] theorem ext {x y : Id α} (h : x.run = y.run) : x = y := h
247246

248247
instance : LawfulMonad Id := by
249248
refine LawfulMonad.mk' _ ?_ ?_ ?_ <;> intros <;> rfl
250249

250+
@[simp] theorem run_map (x : Id α) (f : α → β) : (f <$> x).run = f x.run := rfl
251+
@[simp] theorem run_bind (x : Id α) (f : α → Id β) : (x >>= f).run = (f x.run).run := rfl
252+
@[simp] theorem run_pure (a : α) : (pure a : Id α).run = a := rfl
253+
@[simp] theorem run_seqRight (x y : Id α) : (x *> y).run = y.run := rfl
254+
@[simp] theorem run_seqLeft (x y : Id α) : (x <* y).run = x.run := rfl
255+
@[simp] theorem run_seq (f : Id (α → β)) (x : Id α) : (f <*> x).run = f.run x.run := rfl
256+
257+
-- These lemmas are bad as they abuse the defeq of `Id α` and `α`
258+
@[deprecated run_map (since := "2025-03-05")] theorem map_eq (x : Id α) (f : α → β) : f <$> x = f x := rfl
259+
@[deprecated run_bind (since := "2025-03-05")] theorem bind_eq (x : Id α) (f : α → id β) : x >>= f = f x := rfl
260+
@[deprecated run_pure (since := "2025-03-05")] theorem pure_eq (a : α) : (pure a : Id α) = a := rfl
261+
251262
end Id
252263

253264
/-! # Option -/

src/Init/Data/Array/Basic.lean

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ Examples:
544544
-/
545545
@[inline]
546546
def modify (xs : Array α) (i : Nat) (f : α → α) : Array α :=
547-
Id.run <| modifyM xs i f
547+
Id.run <| modifyM xs i (pure <| f ·)
548548

549549
set_option linter.indexVariables false in -- Changing `idx` causes bootstrapping issues, haven't investigated.
550550
/--
@@ -1059,7 +1059,7 @@ Examples:
10591059
-/
10601060
@[inline]
10611061
def foldl {α : Type u} {β : Type v} (f : β → α → β) (init : β) (as : Array α) (start := 0) (stop := as.size) : β :=
1062-
Id.run <| as.foldlM f init start stop
1062+
Id.run <| as.foldlM (pure <| f · ·) init start stop
10631063

10641064
/--
10651065
Folds a function over an array from the right, accumulating a value starting with `init`. The
@@ -1076,7 +1076,7 @@ Examples:
10761076
-/
10771077
@[inline]
10781078
def foldr {α : Type u} {β : Type v} (f : α → β → β) (init : β) (as : Array α) (start := as.size) (stop := 0) : β :=
1079-
Id.run <| as.foldrM f init start stop
1079+
Id.run <| as.foldrM (pure <| f · ·) init start stop
10801080

10811081
/--
10821082
Computes the sum of the elements of an array.
@@ -1124,7 +1124,7 @@ Examples:
11241124
-/
11251125
@[inline]
11261126
def map {α : Type u} {β : Type v} (f : α → β) (as : Array α) : Array β :=
1127-
Id.run <| as.mapM f
1127+
Id.run <| as.mapM (pure <| f ·)
11281128

11291129
instance : Functor Array where
11301130
map := map
@@ -1139,7 +1139,7 @@ valid.
11391139
-/
11401140
@[inline]
11411141
def mapFinIdx {α : Type u} {β : Type v} (as : Array α) (f : (i : Nat) → α → (h : i < as.size) → β) : Array β :=
1142-
Id.run <| as.mapFinIdxM f
1142+
Id.run <| as.mapFinIdxM (pure <| f · · ·)
11431143

11441144
/--
11451145
Applies a function to each element of the array along with the index at which that element is found,
@@ -1150,7 +1150,7 @@ is valid.
11501150
-/
11511151
@[inline]
11521152
def mapIdx {α : Type u} {β : Type v} (f : Nat → α → β) (as : Array α) : Array β :=
1153-
Id.run <| as.mapIdxM f
1153+
Id.run <| as.mapIdxM (pure <| f · ·)
11541154

11551155
/--
11561156
Pairs each element of an array with its index, optionally starting from an index other than `0`.
@@ -1198,7 +1198,7 @@ some 10
11981198
-/
11991199
@[inline]
12001200
def findSome? {α : Type u} {β : Type v} (f : α → Option β) (as : Array α) : Option β :=
1201-
Id.run <| as.findSomeM? f
1201+
Id.run <| as.findSomeM? (pure <| f ·)
12021202

12031203
/--
12041204
Returns the first non-`none` result of applying the function `f` to each element of the
@@ -1232,7 +1232,7 @@ Examples:
12321232
-/
12331233
@[inline]
12341234
def findSomeRev? {α : Type u} {β : Type v} (f : α → Option β) (as : Array α) : Option β :=
1235-
Id.run <| as.findSomeRevM? f
1235+
Id.run <| as.findSomeRevM? (pure <| f ·)
12361236

12371237
/--
12381238
Returns the last element of the array for which the predicate `p` returns `true`, or `none` if no
@@ -1244,7 +1244,7 @@ Examples:
12441244
-/
12451245
@[inline]
12461246
def findRev? {α : Type} (p : α → Bool) (as : Array α) : Option α :=
1247-
Id.run <| as.findRevM? p
1247+
Id.run <| as.findRevM? (pure <| p ·)
12481248

12491249
/--
12501250
Returns the index of the first element for which `p` returns `true`, or `none` if there is no such
@@ -1383,7 +1383,7 @@ Examples:
13831383
-/
13841384
@[inline]
13851385
def any (as : Array α) (p : α → Bool) (start := 0) (stop := as.size) : Bool :=
1386-
Id.run <| as.anyM p start stop
1386+
Id.run <| as.anyM (pure <| p ·) start stop
13871387

13881388
/--
13891389
Returns `true` if `p` returns `true` for every element of `as`.
@@ -1401,7 +1401,7 @@ Examples:
14011401
-/
14021402
@[inline]
14031403
def all (as : Array α) (p : α → Bool) (start := 0) (stop := as.size) : Bool :=
1404-
Id.run <| as.allM p start stop
1404+
Id.run <| as.allM (pure <| p ·) start stop
14051405

14061406
/--
14071407
Checks whether `a` is an element of `as`, using `==` to compare elements.
@@ -1670,7 +1670,7 @@ Example:
16701670
-/
16711671
@[inline]
16721672
def filterMap (f : α → Option β) (as : Array α) (start := 0) (stop := as.size) : Array β :=
1673-
Id.run <| as.filterMapM f (start := start) (stop := stop)
1673+
Id.run <| as.filterMapM (pure <| f ·) (start := start) (stop := stop)
16741674

16751675
/--
16761676
Returns the largest element of the array, as determined by the comparison `lt`, or `none` if

src/Init/Data/Array/BasicAux.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ pointer equality, and does not allocate a new array if the result of each functi
8888
pointer-equal to its argument.
8989
-/
9090
@[inline] def Array.mapMono (as : Array α) (f : α → α) : Array α :=
91-
Id.run <| as.mapMonoM f
91+
Id.run <| as.mapMonoM (pure <| f ·)

src/Init/Data/Array/BinSearch.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,6 @@ Examples:
129129
* `#[].binInsert (· < ·) 1 = #[1]`
130130
-/
131131
@[inline] def binInsert {α : Type u} (lt : α → α → Bool) (as : Array α) (k : α) : Array α :=
132-
Id.run <| binInsertM lt (fun _ => k) (fun _ => k) as k
132+
Id.run <| binInsertM lt (fun _ => pure k) (fun _ => pure k) as k
133133

134134
end Array

0 commit comments

Comments
 (0)