Skip to content

Commit 5bd4781

Browse files
kim-emleanprover-community-mathlib4-botmathlib4-botleanprover-community-mathlib4-botjcommelin
authored
chore: bump toolchain to v4.25.0-rc1 (#1472)
Co-authored-by: leanprover-community-mathlib4-bot <129911861+leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: mathlib4-bot <github-mathlib4-bot@leanprover.zulipchat.com> Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Johan Commelin <johan@commelin.net> Co-authored-by: Matthew Ballard <matt@mrb.email> Co-authored-by: Markus Himmel <markus@lean-fro.org> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: Mario Carneiro <di.gama@gmail.com> Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch> Co-authored-by: Joachim Breitner <mail@joachim-breitner.de> Co-authored-by: Mac Malone <mac@lean-fro.org> Co-authored-by: Rob23oba <152706811+Rob23oba@users.noreply.github.com> Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Paul Reichert <6992158+datokrat@users.noreply.github.com> Co-authored-by: Parth Shastri <31370288+cppio@users.noreply.github.com> Co-authored-by: Joseph Rotella <7482866+jrr6@users.noreply.github.com> Co-authored-by: François G. Dorais <fgdorais@gmail.com> Co-authored-by: Sebastian Graf <sgraf1337@gmail.com> Co-authored-by: Marc Huisinga <mhuisi@protonmail.com>
1 parent 8da40b7 commit 5bd4781

30 files changed

+469
-456
lines changed

Batteries/CodeAction/Misc.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def casesExpand : TacticCodeAction := fun _ snap ctx _ node => do
299299
let targets := discrInfos.map (·.expr)
300300
match using_ with
301301
| none =>
302-
if Tactic.tactic.customEliminators.get (← getOptions) then
302+
if tactic.customEliminators.get (← getOptions) then
303303
if let some elimName ← getCustomEliminator? targets induction then
304304
return some (← getElimExprNames (← getConstInfo elimName).type)
305305
matchConstInduct (← whnf (← inferType discr₀.expr)).getAppFn
@@ -341,7 +341,7 @@ def casesExpand : TacticCodeAction := fun _ snap ctx _ node => do
341341
(doc.meta.text.utf8PosToLspPos stx'.getTailPos?.get!, "")
342342
else (endPos, " with")
343343
let fallback := if let some ⟨startPos, endPos⟩ := fallback then
344-
doc.meta.text.source.extract startPos endPos
344+
String.Pos.Raw.extract doc.meta.text.source startPos endPos
345345
else
346346
"sorry"
347347
let newText := Id.run do

Batteries/Control/OptionT.lean

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,63 +14,12 @@ This file contains lemmas about the behavior of `OptionT` and `OptionT.run`.
1414

1515
namespace OptionT
1616

17-
@[ext] theorem ext {x x' : OptionT m α} (h : x.run = x'.run) : x = x' := h
18-
19-
@[simp] theorem run_mk {m : Type _ → Type _} (x : m (Option α)) :
20-
OptionT.run (OptionT.mk x) = x := rfl
21-
22-
@[simp] theorem run_pure (a) [Monad m] : (pure a : OptionT m α).run = pure (some a) := rfl
23-
24-
@[simp] theorem run_bind (f : α → OptionT m β) [Monad m] :
25-
(x >>= f).run = Option.elimM x.run (pure none) (run ∘ f) := by
26-
change x.run >>= _ = _
27-
simp [Option.elimM]
28-
exact bind_congr fun |some _ => rfl | none => rfl
29-
30-
@[simp] theorem run_map (x : OptionT m α) (f : α → β) [Monad m] [LawfulMonad m] :
31-
(f <$> x).run = Option.map f <$> x.run := by
32-
rw [← bind_pure_comp _ x.run]
33-
change x.run >>= _ = _
34-
exact bind_congr fun |some _ => rfl | none => rfl
35-
3617
@[simp] theorem run_monadLift [Monad m] [LawfulMonad m] [MonadLiftT n m] (x : n α) :
3718
(monadLift x : OptionT m α).run = some <$> (monadLift x : m α) := (map_eq_pure_bind _ _).symm
3819

3920
@[simp] theorem run_mapConst [Monad m] [LawfulMonad m] (x : OptionT m α) (y : β) :
4021
(Functor.mapConst y x).run = Option.map (Function.const α y) <$> x.run := run_map _ _
4122

42-
instance (m) [Monad m] [LawfulMonad m] : LawfulMonad (OptionT m) :=
43-
LawfulMonad.mk'
44-
(id_map := by
45-
intros; apply OptionT.ext; simp only [OptionT.run_map]
46-
rw [map_congr, id_map]
47-
intro a; cases a <;> rfl)
48-
(bind_assoc := by
49-
refine fun _ _ _ => OptionT.ext ?_
50-
simp only [run_bind, Option.elimM, bind_assoc]
51-
refine bind_congr fun | some x => by simp [Option.elimM] | none => by simp)
52-
(pure_bind := by intros; apply OptionT.ext; simp)
53-
54-
@[simp] theorem run_failure [Monad m] : (failure : OptionT m α).run = pure none := rfl
55-
56-
@[simp] theorem run_orElse [Monad m] (x : OptionT m α) (y : OptionT m α) :
57-
(x <|> y).run = Option.elimM x.run y.run (pure ∘ some) :=
58-
bind_congr fun | some _ => rfl | none => rfl
59-
60-
@[simp] theorem run_seq [Monad m] [LawfulMonad m] (f : OptionT m (α → β)) (x : OptionT m α) :
61-
(f <*> x).run = Option.elimM f.run (pure none) (fun f => Option.map f <$> x.run) := by
62-
simp only [seq_eq_bind, run_bind, run_map, Function.comp_def]
63-
64-
@[simp] theorem run_seqLeft [Monad m] [LawfulMonad m] (x : OptionT m α) (y : OptionT m β) :
65-
(x <* y).run = Option.elimM x.run (pure none)
66-
(fun x => Option.map (Function.const β x) <$> y.run) := by
67-
simp [seqLeft_eq, seq_eq_bind, Option.elimM, Function.comp_def]
68-
69-
@[simp] theorem run_seqRight [Monad m] [LawfulMonad m] (x : OptionT m α) (y : OptionT m β) :
70-
(x *> y).run = Option.elimM x.run (pure none) (Function.const α y.run) := by
71-
simp only [seqRight_eq, run_seq, run_map, Option.elimM_map]
72-
refine bind_congr (fun | some _ => by simp [Option.elim] | none => by simp [Option.elim])
73-
7423
@[simp] theorem run_monadMap {n} [MonadFunctorT n m] (f : ∀ {α}, n α → n α) :
7524
(monadMap (@f) x : OptionT m α).run = monadMap (@f) x.run := rfl
7625

Batteries/Data/Array/Match.lean

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def PrefixTable.extend [BEq α] (t : PrefixTable α) (x : α) : PrefixTable α w
6161
def mkPrefixTable [BEq α] (xs : Array α) : PrefixTable α := xs.foldl (·.extend) default
6262

6363
/-- Make prefix table from a pattern stream -/
64-
partial def mkPrefixTableOfStream [BEq α] [Stream σ α] (stream : σ) : PrefixTable α :=
64+
partial def mkPrefixTableOfStream [BEq α] [Std.Stream σ α] (stream : σ) : PrefixTable α :=
6565
loop default stream
6666
where
6767
/-- Inner loop for `mkPrefixTableOfStream` -/
@@ -82,15 +82,15 @@ def Matcher.ofArray [BEq α] (pat : Array α) : Matcher α where
8282
table := mkPrefixTable pat
8383

8484
/-- Make a KMP matcher for a given a pattern stream -/
85-
def Matcher.ofStream [BEq α] [Stream σ α] (pat : σ) : Matcher α where
85+
def Matcher.ofStream [BEq α] [Std.Stream σ α] (pat : σ) : Matcher α where
8686
table := mkPrefixTableOfStream pat
8787

8888
/-- Find next match from a given stream
8989
9090
Runs the stream until it reads a sequence that matches the sought pattern, then returns the stream
9191
state at that point and an updated matcher state.
9292
-/
93-
partial def Matcher.next? [BEq α] [Stream σ α] (m : Matcher α) (stream : σ) :
93+
partial def Matcher.next? [BEq α] [Std.Stream σ α] (m : Matcher α) (stream : σ) :
9494
Option (σ × Matcher α) :=
9595
match Stream.next? stream with
9696
| none => none
@@ -126,7 +126,8 @@ private def modifyStep [BEq α] (m : Matcher α) [Iterator σ n α]
126126
instance [Monad n] [BEq α] (m : Matcher α) [Iterator σ n α] :
127127
Iterator (m.Iterator σ n α) n σ where
128128
IsPlausibleStep it step := ∃ step', m.modifyStep it step' = step
129-
step it := it.internalState.inner.step >>= fun step => pure ⟨m.modifyStep _ _, step, rfl⟩
129+
step it := it.internalState.inner.step >>=
130+
fun step => pure (.deflate ⟨m.modifyStep _ _, step.inflate, rfl⟩)
130131

131132
private def finitenessRelation [Monad n] [BEq α] (m : Matcher α) [Iterator σ n α] [Finite σ n] :
132133
FinitenessRelation (m.Iterator σ n α) n where

Batteries/Data/Array/Pairwise.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ instance (R : α → α → Prop) [DecidableRel R] (as) : Decidable (Pairwise R
3232
· intro h ⟨j, hj⟩ ⟨i, hlt⟩; exact h i j (Nat.lt_trans hlt hj) hj hlt
3333
decidable_of_iff _ this
3434

35-
@[grind]
35+
@[grind]
3636
theorem pairwise_empty : #[].Pairwise R := by
3737
unfold Pairwise; exact List.Pairwise.nil
3838

39-
@[grind]
39+
@[grind]
4040
theorem pairwise_singleton (R : α → α → Prop) (a) : #[a].Pairwise R := by
4141
unfold Pairwise; exact List.pairwise_singleton ..
4242

Batteries/Data/AssocList.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ def pop? : AssocList α β → Option ((α × β) × AssocList α β)
252252
| nil => none
253253
| cons a b l => some ((a, b), l)
254254

255-
instance : ToStream (AssocList α β) (AssocList α β) := ⟨fun x => x⟩
256-
instance : Stream (AssocList α β) (α × β) := ⟨pop?⟩
255+
instance : Std.ToStream (AssocList α β) (AssocList α β) := ⟨fun x => x⟩
256+
instance : Std.Stream (AssocList α β) (α × β) := ⟨pop?⟩
257257

258258
/-- Converts a list into an `AssocList`. This is the inverse function to `AssocList.toList`. -/
259259
@[simp] def _root_.List.toAssocList : List (α × β) → AssocList α β

Batteries/Data/BinomialHeap/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def ofArray (le : α → α → Bool) (as : Array α) : BinomialHeap α le := as
532532
| none => none
533533
| some (a, tl) => some (a, ⟨tl, b.2.deleteMin eq⟩)
534534

535-
instance : Stream (BinomialHeap α le) α := ⟨deleteMin⟩
535+
instance : Std.Stream (BinomialHeap α le) α := ⟨deleteMin⟩
536536

537537
/--
538538
`O(n log n)`. Implementation of `for x in (b : BinomialHeap α le) ...` notation,

Batteries/Data/BitVec/Lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace BitVec
3636
simp only [BitVec.toInt, Int.ofBits, toNat_ofFnLE, Int.subNatNat_eq_coe]; rfl
3737

3838
-- TODO: consider these for global `grind` attributes.
39-
attribute [local grind] Fin.succ Fin.rev Fin.last Fin.zero_eta
39+
attribute [local grind =] Fin.succ Fin.rev Fin.last Fin.zero_eta
4040

4141
theorem getElem_ofFnLEAux (f : Fin n → Bool) (i) (h : i < n) (h' : i < m) :
4242
(ofFnLEAux m f)[i] = f ⟨i, h⟩ := by

Batteries/Data/ByteArray.lean

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,8 @@ theorem getElem_eq_data_getElem (a : ByteArray) (h : i < a.size) : a[i] = a.data
2222

2323
@[simp] theorem data_mkEmpty (cap) : (emptyWithCapacity cap).data = #[] := rfl
2424

25-
@[simp] theorem data_empty : empty.data = #[] := rfl
26-
27-
@[simp] theorem size_empty : empty.size = 0 := rfl
28-
2925
/-! ### push -/
3026

31-
@[simp] theorem data_push (a : ByteArray) (b : UInt8) : (a.push b).data = a.data.push b := rfl
32-
3327
@[simp] theorem size_push (a : ByteArray) (b : UInt8) : (a.push b).size = a.size + 1 :=
3428
Array.size_push ..
3529

@@ -42,9 +36,6 @@ theorem get_push_lt (a : ByteArray) (x : UInt8) (i : Nat) (h : i < a.size) :
4236

4337
/-! ### set -/
4438

45-
@[simp] theorem data_set (a : ByteArray) (i : Fin a.size) (v : UInt8) :
46-
(a.set i v).data = a.data.set i v i.isLt := rfl
47-
4839
@[simp] theorem size_set (a : ByteArray) (i : Fin a.size) (v : UInt8) :
4940
(a.set i v).size = a.size :=
5041
Array.size_set ..
@@ -68,15 +59,6 @@ theorem set_set (a : ByteArray) (i : Fin a.size) (v v' : UInt8) :
6859

6960
/-! ### append -/
7061

71-
@[simp] theorem append_eq (a b) : ByteArray.append a b = a ++ b := rfl
72-
73-
@[simp] theorem data_append (a b : ByteArray) : (a ++ b).data = a.data ++ b.data := by
74-
rw [←append_eq]; simp [ByteArray.append, size]
75-
rw [Array.extract_empty_of_stop_le_start (h:=Nat.le_add_right ..), Array.append_empty]
76-
77-
theorem size_append (a b : ByteArray) : (a ++ b).size = a.size + b.size := by
78-
simp only [size, append_eq, data_append]; exact Array.size_append ..
79-
8062
theorem get_append_left {a b : ByteArray} (hlt : i < a.size)
8163
(h : i < (a ++ b).size := size_append .. ▸ Nat.lt_of_lt_of_le hlt (Nat.le_add_right ..)) :
8264
(a ++ b)[i] = a[i] := by
@@ -89,17 +71,6 @@ theorem get_append_right {a b : ByteArray} (hle : a.size ≤ i) (h : i < (a ++ b
8971

9072
/-! ### extract -/
9173

92-
@[simp] theorem data_extract (a : ByteArray) (start stop) :
93-
(a.extract start stop).data = a.data.extract start stop := by
94-
simp [extract]
95-
match Nat.le_total start stop with
96-
| .inl h => simp [h, Nat.add_sub_cancel']
97-
| .inr h => simp [h, Nat.sub_eq_zero_of_le, Array.extract_empty_of_stop_le_start]
98-
99-
@[simp] theorem size_extract (a : ByteArray) (start stop) :
100-
(a.extract start stop).size = min stop a.size - start := by
101-
simp [size]
102-
10374
theorem get_extract_aux {a : ByteArray} {start stop} (h : i < (a.extract start stop).size) :
10475
start + i < a.size := by
10576
apply Nat.add_lt_of_lt_sub'; apply Nat.lt_of_lt_of_le h
@@ -115,15 +86,15 @@ theorem get_extract_aux {a : ByteArray} {start stop} (h : i < (a.extract start s
11586
@[inline] def ofFn (f : Fin n → UInt8) : ByteArray :=
11687
Fin.foldl n (fun acc i => acc.push (f i)) (emptyWithCapacity n)
11788

118-
@[simp] theorem ofFn_zero (f : Fin 0 → UInt8) : ofFn f = empty := rfl
89+
@[simp] theorem ofFn_zero (f : Fin 0 → UInt8) : ofFn f = empty := by simp [ofFn]
11990

12091
theorem ofFn_succ (f : Fin (n+1) → UInt8) :
12192
ofFn f = (ofFn fun i => f i.castSucc).push (f (Fin.last n)) := by
12293
simp [ofFn, Fin.foldl_succ_last, emptyWithCapacity]
12394

12495
@[simp] theorem data_ofFn (f : Fin n → UInt8) : (ofFn f).data = .ofFn f := by
12596
induction n with
126-
| zero => rfl
97+
| zero => simp
12798
| succ n ih => simp [ofFn_succ, Array.ofFn_succ, ih, Fin.last]
12899

129100
@[simp] theorem size_ofFn (f : Fin n → UInt8) : (ofFn f).size = n := by

Batteries/Data/ByteSlice.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ where
4949
instance : ForIn m ByteSlice UInt8 where
5050
forIn := ByteSlice.forIn
5151

52-
instance : Stream ByteSlice UInt8 where
52+
instance : Std.Stream ByteSlice UInt8 where
5353
next? s := s[0]? >>= (·, s.popFront)
5454

5555
instance : Coe ByteArray ByteSlice where
@@ -167,7 +167,7 @@ where
167167
instance : ForIn m ByteSubarray UInt8 where
168168
forIn := ByteSubarray.forIn
169169

170-
instance : Stream ByteSubarray UInt8 where
170+
instance : Std.Stream ByteSubarray UInt8 where
171171
next? s := s[0]? >>= fun x => (x, s.popFront)
172172

173173
end Batteries.ByteSubarray

Batteries/Data/Char/Basic.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Authors: Jannis Limperg, François G. Dorais
66
import Batteries.Classes.Order
77

88
-- Forward port of lean4#9515
9-
@[grind]
9+
@[grind]
1010
theorem List.mem_finRange (x : Fin n) : x ∈ finRange n := by
1111
simp [finRange]
1212

@@ -53,12 +53,12 @@ Number of valid character code points.
5353
-/
5454
protected abbrev count := Char.max - Char.maxSurrogate + Char.minSurrogate
5555

56-
@[grind] theorem toNat_le_max (c : Char) : c.toNat ≤ Char.max := by
56+
@[grind .] theorem toNat_le_max (c : Char) : c.toNat ≤ Char.max := by
5757
match c.valid with
5858
| .inl h => simp only [toNat_val] at h; grind
5959
| .inr ⟨_, h⟩ => simp only [toNat_val] at h; grind
6060

61-
@[grind] theorem toNat_not_surrogate (c : Char) :
61+
@[grind .] theorem toNat_not_surrogate (c : Char) :
6262
¬(Char.minSurrogate ≤ c.toNat ∧ c.toNat ≤ Char.maxSurrogate) := by
6363
match c.valid with
6464
| .inl h => simp only [toNat_val] at h; grind

0 commit comments

Comments
 (0)