Skip to content

Commit afa9c43

Browse files
committed
Merge branch 'nightly-with-mathlib' of https://github.com/leanprover/lean4 into joachim/issue11342
2 parents 39c0ed0 + fb6c96e commit afa9c43

32 files changed

+2793
-2075
lines changed

.claude/commands/release.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ These comments explain the scripts' behavior, which repositories get special han
3939

4040
## Important Notes
4141

42+
- **NEVER merge PRs autonomously** - always wait for the user to merge PRs themselves
4243
- The `release_steps.py` script is idempotent - it's safe to rerun
4344
- The `release_checklist.py` script is idempotent - it's safe to rerun
4445
- Some repositories depend on others (e.g., mathlib4 depends on batteries, aesop, etc.)

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- name: Checkout
5353
uses: actions/checkout@v5
5454
# don't schedule nightlies on forks
55-
if: github.event_name == 'schedule' && github.repository == 'leanprover/lean4' || inputs.action == 'release nightly'
55+
if: github.event_name == 'schedule' && github.repository == 'leanprover/lean4' || inputs.action == 'release nightly' || (startsWith(github.ref, 'refs/tags/') && github.repository == 'leanprover/lean4')
5656
- name: Set Nightly
5757
if: github.event_name == 'schedule' && github.repository == 'leanprover/lean4' || inputs.action == 'release nightly'
5858
id: set-nightly
@@ -115,7 +115,7 @@ jobs:
115115
CMAKE_MAJOR=$(grep -E "^set\(LEAN_VERSION_MAJOR " src/CMakeLists.txt | grep -oE '[0-9]+')
116116
CMAKE_MINOR=$(grep -E "^set\(LEAN_VERSION_MINOR " src/CMakeLists.txt | grep -oE '[0-9]+')
117117
CMAKE_PATCH=$(grep -E "^set\(LEAN_VERSION_PATCH " src/CMakeLists.txt | grep -oE '[0-9]+')
118-
CMAKE_IS_RELEASE=$(grep -E "^set\(LEAN_VERSION_IS_RELEASE " src/CMakeLists.txt | grep -oE '[0-9]+')
118+
CMAKE_IS_RELEASE=$(grep -m 1 -E "^set\(LEAN_VERSION_IS_RELEASE " src/CMakeLists.txt | grep -oE '[0-9]+')
119119
120120
# Expected values from tag parsing
121121
TAG_MAJOR="${{ steps.set-release.outputs.LEAN_VERSION_MAJOR }}"

doc/dev/release_checklist.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ We'll use `v4.6.0` as the intended release version as a running example.
6969
- `repl`:
7070
There are two copies of `lean-toolchain`/`lakefile.lean`:
7171
in the root, and in `test/Mathlib/`. Edit both, and run `lake update` in both directories.
72+
- `lean-fro.org`:
73+
After updating the toolchains and running `lake update`, you must run `scripts/update.sh` to regenerate
74+
the site content. This script updates generated files that depend on the Lean version.
75+
The `release_steps.py` script handles this automatically.
7276
- An awkward situation that sometimes occurs (e.g. with Verso) is that the `master`/`main` branch has already been moved
7377
to a nightly toolchain that comes *after* the stable toolchain we are
7478
targeting. In this case it is necessary to create a branch `releases/v4.6.0` from the last commit which was on

script/release_steps.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- Special merging strategies for repositories with nightly-testing branches
2424
- Safety checks for repositories using bump branches
2525
- Custom build and test procedures
26+
- lean-fro.org: runs scripts/update.sh to regenerate site content
2627
2728
6. Commits the changes with message "chore: bump toolchain to {version}"
2829
@@ -412,20 +413,14 @@ def execute_release_steps(repo, version, config):
412413
run_command("lake update", cwd=repo_path, stream_output=True)
413414
print(blue("Running `lake update` in examples/hero..."))
414415
run_command("lake update", cwd=repo_path / "examples" / "hero", stream_output=True)
416+
417+
# Run scripts/update.sh to regenerate content
418+
print(blue("Running `scripts/update.sh` to regenerate content..."))
419+
run_command("scripts/update.sh", cwd=repo_path, stream_output=True)
420+
print(green("Content regenerated successfully"))
415421
elif repo_name == "cslib":
416422
print(blue("Updating lakefile.toml..."))
417423
run_command(f'perl -pi -e \'s/"v4\\.[0-9]+(\\.[0-9]+)?(-rc[0-9]+)?"/"' + version + '"/g\' lakefile.*', cwd=repo_path)
418-
419-
print(blue("Updating docs/lakefile.toml..."))
420-
run_command(f'perl -pi -e \'s/"v4\\.[0-9]+(\\.[0-9]+)?(-rc[0-9]+)?"/"' + version + '"/g\' lakefile.*', cwd=repo_path / "docs")
421-
422-
# Update lean-toolchain in docs
423-
print(blue("Updating docs/lean-toolchain..."))
424-
docs_toolchain = repo_path / "docs" / "lean-toolchain"
425-
with open(docs_toolchain, "w") as f:
426-
f.write(f"leanprover/lean4:{version}\n")
427-
print(green(f"Updated docs/lean-toolchain to leanprover/lean4:{version}"))
428-
429424
run_command("lake update", cwd=repo_path, stream_output=True)
430425
elif dependencies:
431426
run_command(f'perl -pi -e \'s/"v4\\.[0-9]+(\\.[0-9]+)?(-rc[0-9]+)?"/"' + version + '"/g\' lakefile.*', cwd=repo_path)

src/Init/Data/Nat/Bitwise/Basic.lean

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ Asserts that the `(n+1)`th least significant bit of `m` is not set.
144144
145145
(This definition is used by Lean internally for compact bitmaps.)
146146
-/
147-
@[expose, reducible] protected def hasNotBit (m n : Nat) : Prop :=
148-
1 &&& (m >>> n) ≠ 1
147+
@[expose] protected def hasNotBit (m n : Nat) : Prop :=
148+
Nat.land 1 (Nat.shiftRight m n) ≠ 1
149+
150+
@[grind =]
151+
theorem hasNotBit_eq (m n : Nat) : Nat.hasNotBit m n = (1 &&& (m >>> n) ≠ 1) := rfl
149152

150153
end Nat

src/Init/Data/Nat/Log2.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Examples:
3535
* `Nat.log2 7 = 2`
3636
* `Nat.log2 8 = 3`
3737
-/
38-
@[extern "lean_nat_log2"]
38+
@[expose, extern "lean_nat_log2"]
3939
def log2 (n : @& Nat) : Nat :=
4040
-- Lean "assembly"
4141
n.rec (fun _ => nat_lit 0) (fun _ ih n =>

src/Init/Grind/Lemmas.lean

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Leonardo de Moura
55
-/
66
module
7-
87
prelude
98
public import Init.ByCases
109
public import Init.Grind.Util
11-
10+
public import Init.Grind.Ring.Basic
1211
public section
13-
1412
namespace Lean.Grind
1513

1614
theorem rfl_true : true = true :=
@@ -193,6 +191,15 @@ theorem Nat.or_congr {a b : Nat} {k₁ k₂ k : Nat} (h₁ : a = k₁) (h₂ : b
193191
theorem Nat.shiftLeft_congr {a b : Nat} {k₁ k₂ k : Nat} (h₁ : a = k₁) (h₂ : b = k₂) : k == k₁ <<< k₂ → a <<< b = k := by simp_all
194192
theorem Nat.shiftRight_congr {a b : Nat} {k₁ k₂ k : Nat} (h₁ : a = k₁) (h₂ : b = k₂) : k == k₁ >>> k₂ → a >>> b = k := by simp_all
195193

196-
theorem Nat.hasNotBit_congr {a b : Nat} {k₁ k₂ : Nat} {k : Bool} (h₁ : a = k₁) (h₂ : b = k₂) : k == Nat.hasNotBit k₁ k₂ → Nat.hasNotBit a b = k := by simp_all
194+
/-! Semiring propagators -/
195+
196+
theorem Semiring.one_mul_congr {α} [Semiring α] {a b : α} (h : a = 1) : a*b = b := by
197+
simp [h, Semiring.one_mul]
198+
theorem Semiring.zero_mul_congr {α} [Semiring α] {a b : α} (h : a = 0) : a*b = 0 := by
199+
simp [h, Semiring.zero_mul]
200+
theorem Semiring.mul_one_congr {α} [Semiring α] {a b : α} (h : b = 1) : a*b = a := by
201+
simp [h, Semiring.mul_one]
202+
theorem Semiring.mul_zero_congr {α} [Semiring α] {a b : α} (h : b = 0) : a*b = 0 := by
203+
simp [h, Semiring.mul_zero]
197204

198205
end Lean.Grind

src/Init/Grind/Norm.lean

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ theorem smul_int_eq_mul {α} [Ring α] (i : Int) (a : α) : i • a = Int.cast i
152152
theorem Int.subNatNat_eq (a b : Nat) : Int.subNatNat a b = NatCast.natCast a - NatCast.natCast b := by
153153
apply Int.subNatNat_eq_coe
154154

155+
theorem Int.sign_eq (x : Int) : x.sign = if x > 0 then 1 else if x < 0 then -1 else 0 := by
156+
split; simp [*]
157+
split; simp [*]
158+
have : x = 0 := by omega
159+
simp [*]
160+
155161
-- Remark: for additional `grind` simprocs, check `Lean/Meta/Tactic/Grind`
156162
init_grind_norm
157163
/- Pre theorems -/
@@ -197,6 +203,11 @@ init_grind_norm
197203
Int.Linear.sub_fold Int.Linear.neg_fold
198204
-- Int divides
199205
Int.one_dvd Int.zero_dvd
206+
-- Int alternative div and mod. We just expand them
207+
Int.fdiv_eq_ediv Int.tdiv_eq_ediv
208+
Int.fmod_eq_emod Int.tmod_eq_emod Int.bmod_eq_emod
209+
-- Int sign. We just expand it
210+
Int.sign_eq
200211
-- Function composition
201212
Function.const_apply Function.comp_apply Function.const_comp
202213
Function.comp_const Function.true_comp Function.false_comp

src/Init/Grind/Tactics.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ theorems and helps prevent an excessive number of instantiations.
156156
- `grind only [<name>, ...]` is like `grind [<name>, ...]` but does not use theorems tagged with `@[grind]`.
157157
- `grind (gen := <num>)` sets the maximum generation.
158158
159-
### Linear integer arithmetic (`cutsat`)
159+
### Linear integer arithmetic (`lia`)
160160
161161
`grind` can solve goals that reduce to **linear integer arithmetic (LIA)** using an
162-
integrated decision procedure called **`cutsat`**. It understands
162+
integrated decision procedure called **`lia`**. It understands
163163
164164
* equalities   `p = 0`
165165
* inequalities  `p ≤ 0`
@@ -172,7 +172,7 @@ This *model-based* search is **complete for LIA**.
172172
173173
#### Key options:
174174
175-
* `grind -cutsat` disable the solver (useful for debugging)
175+
* `grind -lia` disable the solver (useful for debugging)
176176
* `grind +qlia` accept rational models (shrinks the search space but is incomplete for ℤ)
177177
178178
#### Examples:
@@ -297,7 +297,7 @@ syntax (name := grindTrace)
297297
/--
298298
`cutsat` solves linear integer arithmetic goals.
299299
300-
It is a implemented as a thin wrapper around the `grind` tactic, enabling only the `cutsat` solver.
300+
It is a implemented as a thin wrapper around the `grind` tactic, enabling only the `lia` solver.
301301
Please use `grind` instead if you need additional capabilities.
302302
303303
**Deprecated**: Use `lia` instead.
@@ -307,7 +307,7 @@ syntax (name := cutsat) "cutsat" optConfig : tactic
307307
/--
308308
`lia` solves linear integer arithmetic goals.
309309
310-
It is a implemented as a thin wrapper around the `grind` tactic, enabling only the `cutsat` solver.
310+
It is a implemented as a thin wrapper around the `grind` tactic, enabling only the `lia` solver.
311311
Please use `grind` instead if you need additional capabilities.
312312
-/
313313
syntax (name := lia) "lia" optConfig : tactic

src/Lean/Meta.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ public import Lean.Meta.BinderNameHint
5858
public import Lean.Meta.TryThis
5959
public import Lean.Meta.Hint
6060
public import Lean.Meta.MethodSpecs
61+
public import Lean.Meta.CtorIdxHInj

0 commit comments

Comments
 (0)