Skip to content

Commit bddb9bd

Browse files
author
Sebastian Graf
committed
Rebase and fix
1 parent 4c07cf3 commit bddb9bd

File tree

7 files changed

+26
-25
lines changed

7 files changed

+26
-25
lines changed

src/Init/Data/Array/Lemmas.lean

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3482,15 +3482,15 @@ theorem foldrM_append [Monad m] [LawfulMonad m] {f : α → β → m β} {b} {xs
34823482
@[simp] theorem foldr_append' {f : α → β → β} {b} {xs ys : Array α} {start : Nat}
34833483
(w : start = xs.size + ys.size) :
34843484
(xs ++ ys).foldr f b start 0 = xs.foldr f (ys.foldr f b) :=
3485-
foldrM_append' _ _ _ _ w
3485+
foldrM_append' w
34863486

34873487
@[grind _=_]theorem foldl_append {β : Type _} {f : β → α → β} {b} {xs ys : Array α} :
34883488
(xs ++ ys).foldl f b = ys.foldl f (xs.foldl f b) :=
3489-
foldlM_append _ _ _ _
3489+
foldlM_append
34903490

34913491
@[grind _=_] theorem foldr_append {f : α → β → β} {b} {xs ys : Array α} :
34923492
(xs ++ ys).foldr f b = xs.foldr f (ys.foldr f b) :=
3493-
foldrM_append _ _ _ _
3493+
foldrM_append
34943494

34953495
@[simp] theorem foldl_flatten' {f : β → α → β} {b} {xss : Array (Array α)} {stop : Nat}
34963496
(w : stop = xss.flatten.size) :
@@ -3520,21 +3520,21 @@ theorem foldrM_append [Monad m] [LawfulMonad m] {f : α → β → m β} {b} {xs
35203520
@[simp] theorem foldl_reverse' {xs : Array α} {f : β → α → β} {b} {stop : Nat}
35213521
(w : stop = xs.size) :
35223522
xs.reverse.foldl f b 0 stop = xs.foldr (fun x y => f y x) b :=
3523-
foldlM_reverse' _ _ _ w
3523+
foldlM_reverse' w
35243524

35253525
/-- Variant of `foldr_reverse` with a side condition for the `start` argument. -/
35263526
@[simp] theorem foldr_reverse' {xs : Array α} {f : α → β → β} {b} {start : Nat}
35273527
(w : start = xs.size) :
35283528
xs.reverse.foldr f b start 0 = xs.foldl (fun x y => f y x) b :=
3529-
foldrM_reverse' _ _ _ w
3529+
foldrM_reverse' w
35303530

35313531
@[grind] theorem foldl_reverse {xs : Array α} {f : β → α → β} {b} :
35323532
xs.reverse.foldl f b = xs.foldr (fun x y => f y x) b :=
3533-
foldlM_reverse _ _ _
3533+
foldlM_reverse
35343534

35353535
@[grind] theorem foldr_reverse {xs : Array α} {f : α → β → β} {b} :
35363536
xs.reverse.foldr f b = xs.foldl (fun x y => f y x) b :=
3537-
foldrM_reverse _ _ _
3537+
foldrM_reverse
35383538

35393539
theorem foldl_eq_foldr_reverse {xs : Array α} {f : β → α → β} {b} :
35403540
xs.foldl f b = xs.reverse.foldr (fun x y => f y x) b := by simp
@@ -4049,15 +4049,16 @@ abbrev all_mkArray := @all_replicate
40494049
/-! ### modify -/
40504050

40514051
@[simp] theorem size_modify {xs : Array α} {i : Nat} {f : α → α} : (xs.modify i f).size = xs.size := by
4052-
unfold modify modifyM Id.run
4052+
unfold modify modifyM
40534053
split <;> simp
40544054

40554055
theorem getElem_modify {xs : Array α} {j i} (h : i < (xs.modify j f).size) :
40564056
(xs.modify j f)[i] = if j = i then f (xs[i]'(by simpa using h)) else xs[i]'(by simpa using h) := by
4057-
simp only [modify, modifyM, Id.run, Id.pure_eq]
4057+
simp only [modify, modifyM]
40584058
split
4059-
· simp only [Id.bind_eq, getElem_set]; split <;> simp [*]
4060-
· rw [if_neg (mt (by rintro rfl; exact h) (by simp_all))]
4059+
· simp only [getElem_set, Id.run_pure, Id.run_bind]; split <;> simp [*]
4060+
· simp only [Id.run_pure]
4061+
rw [if_neg (mt (by rintro rfl; exact h) (by simp_all))]
40614062

40624063
@[simp] theorem toList_modify {xs : Array α} {f : α → α} {i : Nat} :
40634064
(xs.modify i f).toList = xs.toList.modify i f := by

src/Init/Data/Array/Monadic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ theorem forIn'_eq_foldlM [Monad m] [LawfulMonad m]
185185
{xs : Array α} (f : (a : α) → a ∈ xs → β → Id β) (init : β) :
186186
(forIn' xs init (fun a m b => .yield <$> f a m b)).run =
187187
xs.attach.foldl (fun b ⟨a, h⟩ => f a h b |>.run) init :=
188-
forIn'_pure_yield_eq_foldl _ _ _
188+
forIn'_pure_yield_eq_foldl _ _
189189

190190
@[simp] theorem forIn'_map [Monad m] [LawfulMonad m]
191191
{xs : Array α} (g : α → β) (f : (b : β) → b ∈ xs.map g → γ → m (ForInStep γ)) :
@@ -226,7 +226,7 @@ theorem forIn_eq_foldlM [Monad m] [LawfulMonad m]
226226
{xs : Array α} (f : α → β → Id β) (init : β) :
227227
(forIn xs init (fun a b => .yield <$> f a b)).run =
228228
xs.foldl (fun b a => f a b |>.run) init :=
229-
forIn_pure_yield_eq_foldl _ _ _
229+
forIn_pure_yield_eq_foldl _ _
230230

231231
@[simp] theorem forIn_map [Monad m] [LawfulMonad m]
232232
{xs : Array α} {g : α → β} {f : β → γ → m (ForInStep γ)} :

src/Init/Data/List/Lemmas.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,10 +2549,10 @@ theorem foldr_eq_foldrM {f : α → β → β} {b : β} {l : List α} :
25492549
simp
25502550

25512551
theorem id_run_foldlM {f : β → α → Id β} {b : β} {l : List α} :
2552-
Id.run (l.foldlM f b) = l.foldl (f · · |>.run) b := (foldl_eq_foldlM f b l).symm
2552+
Id.run (l.foldlM f b) = l.foldl (f · · |>.run) b := foldl_eq_foldlM.symm
25532553

25542554
theorem id_run_foldrM {f : α → β → Id β} {b : β} {l : List α} :
2555-
Id.run (l.foldrM f b) = l.foldr (f · · |>.run) b := (foldr_eq_foldrM f b l).symm
2555+
Id.run (l.foldrM f b) = l.foldr (f · · |>.run) b := foldr_eq_foldrM.symm
25562556

25572557
@[simp] theorem foldlM_reverse [Monad m] {l : List α} {f : β → α → m β} {b : β} :
25582558
l.reverse.foldlM f b = l.foldrM (fun x y => f y x) b := rfl

src/Init/Data/List/Monadic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ theorem forIn'_eq_foldlM [Monad m] [LawfulMonad m]
343343
(l : List α) (f : (a : α) → a ∈ l → β → Id β) (init : β) :
344344
(forIn' l init (fun a m b => .yield <$> f a m b)).run =
345345
l.attach.foldl (fun b ⟨a, h⟩ => f a h b |>.run) init :=
346-
forIn'_pure_yield_eq_foldl _ _ _
346+
forIn'_pure_yield_eq_foldl _ _
347347

348348
@[simp] theorem forIn'_map [Monad m] [LawfulMonad m]
349349
{l : List α} (g : α → β) (f : (b : β) → b ∈ l.map g → γ → m (ForInStep γ)) :
@@ -395,7 +395,7 @@ theorem forIn_eq_foldlM [Monad m] [LawfulMonad m]
395395
(l : List α) (f : α → β → Id β) (init : β) :
396396
(forIn l init (fun a b => .yield <$> f a b)).run =
397397
l.foldl (fun b a => f a b |>.run) init :=
398-
forIn_pure_yield_eq_foldl _ _ _
398+
forIn_pure_yield_eq_foldl _ _
399399

400400
@[simp] theorem forIn_map [Monad m] [LawfulMonad m]
401401
{l : List α} {g : α → β} {f : β → γ → m (ForInStep γ)} :

src/Init/Data/Vector/Lemmas.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,10 +2481,10 @@ theorem foldr_map_hom {g : α → β} {f : α → α → α} {f' : β → β →
24812481
simp
24822482

24832483
@[simp, grind _=_] theorem foldl_append {β : Type _} {f : β → α → β} {b} {xs : Vector α n} {ys : Vector α k} :
2484-
(xs ++ ys).foldl f b = ys.foldl f (xs.foldl f b) := foldlM_append _ _ _ _
2484+
(xs ++ ys).foldl f b = ys.foldl f (xs.foldl f b) := foldlM_append
24852485

24862486
@[simp, grind _=_] theorem foldr_append {f : α → β → β} {b} {xs : Vector α n} {ys : Vector α k} :
2487-
(xs ++ ys).foldr f b = xs.foldr f (ys.foldr f b) := foldrM_append _ _ _ _
2487+
(xs ++ ys).foldr f b = xs.foldr f (ys.foldr f b) := foldrM_append
24882488

24892489
@[simp, grind] theorem foldl_flatten {f : β → α → β} {b} {xss : Vector (Vector α m) n} :
24902490
(flatten xss).foldl f b = xss.foldl (fun b xs => xs.foldl f b) b := by
@@ -2498,7 +2498,7 @@ theorem foldr_map_hom {g : α → β} {f : α → α → α} {f' : β → β →
24982498

24992499
@[simp, grind] theorem foldl_reverse {xs : Vector α n} {f : β → α → β} {b} :
25002500
xs.reverse.foldl f b = xs.foldr (fun x y => f y x) b :=
2501-
foldlM_reverse _ _ _
2501+
foldlM_reverse
25022502

25032503
@[simp, grind] theorem foldr_reverse {xs : Vector α n} {f : α → β → β} {b} :
25042504
xs.reverse.foldr f b = xs.foldl (fun x y => f y x) b :=

src/Init/Data/Vector/Monadic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ theorem forIn'_eq_foldlM [Monad m] [LawfulMonad m]
147147
{xs : Vector α n} (f : (a : α) → a ∈ xs → β → Id β) (init : β) :
148148
(forIn' xs init (fun a m b => .yield <$> f a m b)).run =
149149
xs.attach.foldl (fun b ⟨a, h⟩ => f a h b |>.run) init :=
150-
forIn'_pure_yield_eq_foldl _ _ _
150+
forIn'_pure_yield_eq_foldl _ _
151151

152152
@[simp] theorem forIn'_map [Monad m] [LawfulMonad m]
153153
{xs : Vector α n} (g : α → β) (f : (b : β) → b ∈ xs.map g → γ → m (ForInStep γ)) :
@@ -188,7 +188,7 @@ theorem forIn_eq_foldlM [Monad m] [LawfulMonad m]
188188
{xs : Vector α n} (f : α → β → Id β) (init : β) :
189189
(forIn xs init (fun a b => .yield <$> f a b)).run =
190190
xs.foldl (fun b a => f a b |>.run) init :=
191-
forIn_pure_yield_eq_foldl _ _ _
191+
forIn_pure_yield_eq_foldl _ _
192192

193193
@[simp] theorem forIn_map [Monad m] [LawfulMonad m]
194194
{xs : Vector α n} (g : α → β) (f : β → γ → m (ForInStep γ)) :

src/Std/Data/ExtDHashMap/Lemmas.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ theorem insertMany_cons [EquivBEq α] [LawfulHashable α]
965965
m.insertMany (p :: l) = (m.insert p.1 p.2).insertMany l := by
966966
rcases p with ⟨k, v⟩
967967
unfold insertMany
968-
simp only [Id.pure_eq, Id.bind_eq, Id.run, List.forIn_yield_eq_foldl, List.foldl_cons]
968+
simp only [bind_pure_comp, map_pure, List.forIn_pure_yield_eq_foldl, List.foldl_cons, Id.run_pure]
969969
refine Eq.trans ?_ (Eq.symm ?_ : l.foldl (fun b a => b.insert a.1 a.2) (m.insert k v) = _)
970970
exact (List.foldl_hom (f := Subtype.val) fun x y => rfl).symm
971971
exact (List.foldl_hom (f := Subtype.val) fun x y => rfl).symm
@@ -1228,7 +1228,7 @@ theorem insertMany_cons [EquivBEq α] [LawfulHashable α] {l : List (α × β)}
12281228
insertMany m (p :: l) = insertMany (m.insert p.1 p.2) l := by
12291229
rcases p with ⟨k, v⟩
12301230
unfold insertMany
1231-
simp only [Id.pure_eq, Id.bind_eq, Id.run, List.forIn_yield_eq_foldl, List.foldl_cons]
1231+
simp only [bind_pure_comp, map_pure, List.forIn_pure_yield_eq_foldl, List.foldl_cons, Id.run_pure]
12321232
refine Eq.trans ?_ (Eq.symm ?_ : l.foldl (fun b a => b.insert a.1 a.2) (m.insert k v) = _)
12331233
exact (List.foldl_hom (f := Subtype.val) fun x y => rfl).symm
12341234
exact (List.foldl_hom (f := Subtype.val) fun x y => rfl).symm
@@ -1492,7 +1492,7 @@ theorem insertManyIfNewUnit_list_singleton [EquivBEq α] [LawfulHashable α] {k
14921492
theorem insertManyIfNewUnit_cons [EquivBEq α] [LawfulHashable α] {l : List α} {k : α} :
14931493
insertManyIfNewUnit m (k :: l) = insertManyIfNewUnit (m.insertIfNew k ()) l := by
14941494
unfold insertManyIfNewUnit
1495-
simp only [Id.pure_eq, Id.bind_eq, Id.run, List.forIn_yield_eq_foldl, List.foldl_cons]
1495+
simp only [bind_pure_comp, map_pure, List.forIn_pure_yield_eq_foldl, List.foldl_cons, Id.run_pure]
14961496
refine Eq.trans ?_ (Eq.symm ?_ : l.foldl (fun b a => b.insertIfNew a ()) (m.insertIfNew k ()) = _)
14971497
exact (List.foldl_hom (f := Subtype.val) fun x y => rfl).symm
14981498
exact (List.foldl_hom (f := Subtype.val) fun x y => rfl).symm

0 commit comments

Comments
 (0)