Skip to content

Commit 49bda9e

Browse files
author
leanprover-community-mathlib4-bot
committed
Update lean-toolchain for leanprover/lean4#12481
2 parents a6eed6b + 4458780 commit 49bda9e

25 files changed

+131
-498
lines changed

.github/workflows/nightly_bump_toolchain.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ jobs:
2929

3030
- name: Get latest release tag from leanprover/lean4-nightly
3131
id: get-latest-release
32+
env:
33+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
3234
run: |
33-
RELEASE_TAG=$(curl -s "https://api.github.com/repos/leanprover/lean4-nightly/releases" | jq -r '.[0].tag_name')
35+
RELEASE_TAG=$(gh api -X GET repos/leanprover/lean4-nightly/releases \
36+
-f per_page=1 --jq '.[0].tag_name')
37+
if [ -z "$RELEASE_TAG" ] || [ "$RELEASE_TAG" = "null" ]; then
38+
echo "::error::Could not determine latest lean4-nightly release"
39+
exit 1
40+
fi
3441
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
3542
3643
- name: Update lean-toolchain file

.github/workflows/test_mathlib.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
./elan-init -y --default-toolchain none
6060
echo "$HOME/.elan/bin" >> "${GITHUB_PATH}"
6161
62-
- name: Check if tag exists
62+
- name: Check if branch exists
6363
if: steps.pr-info.outputs.pullRequestNumber != '' && steps.pr-info.outputs.targetBranch == 'main'
6464
id: check_mathlib_tag
6565
env:
@@ -75,7 +75,7 @@ jobs:
7575
BASE=master
7676
echo "Using base tag: $BASE"
7777
78-
EXISTS="$(git ls-remote --heads origin batteries-pr-testing-$PR_NUMBER | wc -l)"
78+
EXISTS="$(git ls-remote --heads nightly-testing batteries-pr-testing-$PR_NUMBER | wc -l)"
7979
echo "Branch exists: $EXISTS"
8080
if [ "$EXISTS" = "0" ]; then
8181
echo "Branch does not exist, creating it."

Batteries/Classes/SatisfiesM.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ theorem SatisfiesM_ReaderT_eq [Monad m] :
193193
(exists_congr fun a => by exact ⟨fun eq _ => eq ▸ rfl, funext⟩).trans Classical.skolem.symm
194194

195195
theorem SatisfiesM_StateRefT_eq [Monad m] :
196-
SatisfiesM (m := StateRefT' ω σ m) p x ↔ ∀ s, SatisfiesM p (x s) := by
197-
simp [SatisfiesM_ReaderT_eq, ReaderT.run]
196+
SatisfiesM (m := StateRefT' ω σ m) p x ↔ ∀ s, SatisfiesM p (x s) :=
197+
SatisfiesM_ReaderT_eq
198198

199199
theorem SatisfiesM_StateT_eq [Monad m] [LawfulMonad m] :
200200
SatisfiesM (m := StateT ρ m) (α := α) p x ↔ ∀ s, SatisfiesM (m := m) (p ·.1) (x.run s) := by

Batteries/Control/AlternativeMonad.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ instance [AlternativeMonad m] : AlternativeMonad (StateRefT' ω σ m) where
197197

198198
instance [AlternativeMonad m] [LawfulAlternative m] :
199199
LawfulAlternative (StateRefT' ω σ m) :=
200-
inferInstanceAs (LawfulAlternative (ReaderT _ _))
200+
inferInstanceAs (LawfulAlternative (ReaderT (ST.Ref ω σ) m))
201201

202202
instance [AlternativeMonad m] : LawfulAlternativeLift m (StateRefT' ω σ m) :=
203-
inferInstanceAs (LawfulAlternativeLift m (ReaderT _ _))
203+
inferInstanceAs (LawfulAlternativeLift m (ReaderT (ST.Ref ω σ) m))
204204

205205
end StateRefT'

Batteries/Control/LawfulMonadState.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,4 @@ instance {m σ ρ} [Monad m] [LawfulMonad m] [MonadStateOf σ m] [LawfulMonadSta
222222

223223
instance {m ω σ} [Monad m] [LawfulMonad m] [MonadStateOf σ m] [LawfulMonadStateOf σ m] :
224224
LawfulMonadStateOf σ (StateRefT' ω σ m) :=
225-
inferInstanceAs (LawfulMonadStateOf σ (ReaderT _ _))
225+
inferInstanceAs (LawfulMonadStateOf σ (ReaderT (ST.Ref ω σ) m))

Batteries/Data/Array/Basic.lean

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Arthur Paulino, Floris van Doorn, Jannis Limperg
55
-/
66
module
77
import Batteries.Tactic.Alias
8+
import Batteries.Data.UInt
89

910
@[expose] public section
1011

@@ -140,12 +141,6 @@ May be asserted to be true in an unsafe context via `Array.unsafe_sizeFitsUsize`
140141
-/
141142
private abbrev SizeFitsUSize (a : Array α) : Prop := a.size < USize.size
142143

143-
@[grind .]
144-
private theorem SizeFitsUSize.toNat_ofNat_eq {n : Nat} {a : Array α}
145-
(h : a.SizeFitsUSize) (hn : n ≤ a.size) :
146-
(USize.ofNat n).toNat = n :=
147-
USize.toNat_ofNat_of_lt' (Nat.lt_of_le_of_lt ‹_› ‹_›)
148-
149144
/-
150145
This is guaranteed by the Array docs but it is unprovable.
151146
Can be used in unsafe functions to write more efficient implementations
@@ -224,13 +219,13 @@ private theorem scanlM_loop_eq_scanlMFast_loop [Monad m]
224219
{h_stop : stop ≤ as.size} {acc : Array β} :
225220
scanlM.loop f init as start stop h_stop acc
226221
= scanlMFast.loop f init as (USize.ofNat start) (USize.ofNat stop)
227-
(by rw [USize.toNat_ofNat_of_lt' (Nat.lt_of_le_of_lt h_stop h_size)]; exact h_stop) acc := by
222+
(by rw [USize.toNat_ofNat_of_le_of_lt h_size h_stop]; exact h_stop) acc := by
228223
generalize h_n : stop - start = n
229224
induction n using Nat.strongRecOn generalizing start acc init
230225
rename_i n ih
231226
rw [scanlM.loop, scanlMFast.loop]
232-
have h_stop_usize := h_size.toNat_ofNat_eq h_stop
233-
have h_start_usize := h_size.toNat_ofNat_eq h_start
227+
have h_stop_usize := USize.toNat_ofNat_of_le_of_lt h_size h_stop
228+
have h_start_usize := USize.toNat_ofNat_of_le_of_lt h_size h_start
234229
split
235230
case isTrue h_lt =>
236231
simp_all only [USize.toNat_ofNat', ↓reduceDIte, uget,
@@ -239,7 +234,7 @@ private theorem scanlM_loop_eq_scanlMFast_loop [Monad m]
239234
intro next
240235
have h_start_succ : USize.ofNat start + 1 = USize.ofNat (start + 1) := by
241236
simp_all only [← USize.toNat_inj, USize.toNat_add]
242-
grind only [USize.size_eq, SizeFitsUSize.toNat_ofNat_eq]
237+
grind only [USize.size_eq, USize.toNat_ofNat_of_le_of_lt]
243238
rw [h_start_succ]
244239
apply ih (stop - (start + 1)) <;> omega
245240
case isFalse h_nlt => grind [USize.lt_iff_toNat_lt]
@@ -265,7 +260,7 @@ private def scanrMFast [Monad m] (f : α → β → m β) (init : β) (as : Arra
265260
(start := USize.ofNat start) (stop := USize.ofNat stop)
266261
(h_start := by grind only [USize.size_eq, USize.ofNat_eq_iff_mod_eq_toNat, = Nat.min_def])
267262
(acc := Array.replicate (start - stop + 1) init)
268-
(by grind only [!Array.size_replicate, = Nat.min_def, SizeFitsUSize.toNat_ofNat_eq])
263+
(by grind only [!Array.size_replicate, = Nat.min_def, USize.toNat_ofNat_of_le_of_lt])
269264
where
270265
@[specialize]
271266
loop (f : α → β → m β) (init : β) (as : Array α)

Batteries/Data/Array/Scan.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Prove basic results about `Array.scanl`, `Array.scanr`, `Array.scanlM` and `Arra
1919
-/
2020
namespace Array
2121

22+
set_option backward.isDefEq.respectTransparency false in
2223
theorem scanlM.loop_toList [Monad m] [LawfulMonad m]
2324
{f : β → α → m β} {stop : Nat} (h : stop ≤ as.size) :
2425
Array.toList <$> scanlM.loop f init as start stop h acc =
@@ -152,7 +153,8 @@ theorem scanl_eq_scanlM {f : β → α → β} {as: Array α} :
152153

153154
theorem scanl_eq_scanl_toList {f: β → α → β} {as : Array α} :
154155
as.scanl f init = (as.toList.scanl f init).toArray := by
155-
simp only [scanl_eq_scanlM, scanlM_eq_scanlM_toList, List.scanl, pure, Id.run_map]
156+
simp only [scanl_eq_scanlM, scanlM_eq_scanlM_toList]
157+
simp [List.idRun_scanlM]
156158

157159
@[simp, grind =]
158160
theorem toList_scanl {f : β → α → β} {as: Array α} :
@@ -244,7 +246,7 @@ theorem scanr_eq_scanrM {f : α → β → β} {as : Array α} :
244246
theorem scanr_eq_scanr_toList {f : α → β → β} {as : Array α} :
245247
as.scanr f init = (as.toList.scanr f init).toArray := by
246248
simp only [scanr_eq_scanrM, scanrM_eq_scanrM_toList]
247-
simp [List.scanr]
249+
simp [List.idRun_scanrM]
248250

249251
@[simp, grind =]
250252
theorem toList_scanr {f : α → β → β} {as : Array α} :

Batteries/Data/ByteArray.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ theorem get_extract_aux {a : ByteArray} {start stop} (h : i < (a.extract start s
7878

7979
@[simp] theorem get_extract {a : ByteArray} {start stop} (h : i < (a.extract start stop).size) :
8080
(a.extract start stop)[i] = a[start+i]'(get_extract_aux h) := by
81-
simp [getElem_eq_data_getElem]
81+
simp [getElem_eq_data_getElem]; rfl
8282

8383
/-! ### ofFn -/
8484

Batteries/Data/Fin/Fold.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ theorem dfoldrM_loop_zero [Monad m] (f : (i : Fin n) → α i.succ → m (α i.c
2020
theorem dfoldrM_loop_succ [Monad m] (f : (i : Fin n) → α i.succ → m (α i.castSucc)) (x) :
2121
dfoldrM.loop n α f (i+1) h x = f ⟨i, by omega⟩ x >>= dfoldrM.loop n α f i (by omega) := rfl
2222

23+
-- TODO: This proof needs adjustment for lean4#12179 (backward.isDefEq.respectTransparency)
24+
set_option backward.isDefEq.respectTransparency false in
2325
theorem dfoldrM_loop [Monad m] [LawfulMonad m] (f : (i : Fin (n+1)) → α i.succ → m (α i.castSucc))
2426
(x) : dfoldrM.loop (n+1) α f (i+1) h x =
2527
dfoldrM.loop n (α ∘ succ) (f ·.succ) i (by omega) x >>= f 0 := by
@@ -77,7 +79,7 @@ theorem dfoldlM_loop_lt [Monad m] (f : ∀ (i : Fin n), α i.castSucc → m (α
7779

7880
theorem dfoldlM_loop_eq [Monad m] (f : ∀ (i : Fin n), α i.castSucc → m (α i.succ)) (x) :
7981
dfoldlM.loop n α f n (Nat.le_refl _) x = pure x := by
80-
rw [dfoldlM.loop, dif_neg (Nat.lt_irrefl _), cast_eq]
82+
rw [dfoldlM.loop, dif_neg (Nat.lt_irrefl _)]; rfl
8183

8284
@[simp] theorem dfoldlM_zero [Monad m] (f : (i : Fin 0) → α i.castSucc → m (α i.succ)) (x) :
8385
dfoldlM 0 α f x = pure x := by simp [dfoldlM, dfoldlM.loop]
@@ -93,7 +95,7 @@ theorem dfoldlM_loop [Monad m] (f : (i : Fin (n+1)) → α i.castSucc → m (α
9395
cases Nat.le_antisymm (Nat.le_of_lt_succ h) (Nat.not_lt.1 h')
9496
rw [dfoldlM_loop_lt _ h]
9597
congr; funext
96-
rw [dfoldlM_loop_eq, dfoldlM_loop_eq]
98+
rw [dfoldlM_loop_eq, dfoldlM_loop_eq]; rfl
9799

98100
theorem dfoldlM_succ [Monad m] (f : (i : Fin (n+1)) → α i.castSucc → m (α i.succ)) (x) :
99101
dfoldlM (n+1) α f x = f 0 x >>= (dfoldlM n (α ∘ succ) (f ·.succ ·) .) :=

Batteries/Data/List/Basic.lean

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -194,42 +194,6 @@ where
194194
| [], last, acc => pure <| last :: acc
195195
| x :: xs, last, acc => do go xs (← f last x) (last :: acc)
196196

197-
/--
198-
Folds a monadic function over a list from the left, accumulating partial results starting with
199-
`init`. The accumulated values are combined with the each element of the list in order, using `f`.
200-
-/
201-
@[inline]
202-
def scanlM [Monad m] (f : β → α → m β) (init : β) (l : List α) : m (List β) :=
203-
List.reverse <$> scanAuxM f init l
204-
205-
/--
206-
Folds a monadic function over a list from the right, accumulating partial results starting with
207-
`init`. The accumulated values are combined with the each element of the list in order, using `f`.
208-
-/
209-
@[inline]
210-
def scanrM [Monad m] (f : α → β → m β) (init : β) (xs : List α) : m (List β) :=
211-
scanAuxM (flip f) init xs.reverse
212-
213-
/--
214-
Fold a function `f` over the list from the left, returning the list of partial results.
215-
```
216-
scanl (+) 0 [1, 2, 3] = [0, 1, 3, 6]
217-
```
218-
-/
219-
@[inline]
220-
def scanl (f : β → α → β) (init : β) (as : List α) : List β :=
221-
Id.run <| as.scanlM (pure <| f · ·) init
222-
223-
/--
224-
Fold a function `f` over the list from the right, returning the list of partial results.
225-
```
226-
scanr (+) 0 [1, 2, 3] = [6, 5, 3, 0]
227-
```
228-
-/
229-
@[inline]
230-
def scanr (f : α → β → β) (init : β) (as : List α) : List β :=
231-
Id.run <| as.scanrM (pure <| f · ·) init
232-
233197
/--
234198
Fold a list from left to right as with `foldl`, but the combining function
235199
also receives each element's index added to an optional parameter `start`

0 commit comments

Comments
 (0)