@@ -95,14 +95,12 @@ theorem pmap_congr_left {p q : α → Prop} {f : ∀ a, p a → β} {g : ∀ a,
9595 | cons x l ih =>
9696 rw [pmap, pmap, h _ mem_cons_self, ih fun a ha => h a (mem_cons_of_mem _ ha)]
9797
98- @[grind =]
9998theorem map_pmap {p : α → Prop } {g : β → γ} {f : ∀ a, p a → β} {l : List α} (H) :
10099 map g (pmap f l H) = pmap (fun a h => g (f a h)) l H := by
101100 induction l
102101 · rfl
103102 · simp only [*, pmap, map]
104103
105- @[grind =]
106104theorem pmap_map {p : β → Prop } {g : ∀ b, p b → γ} {f : α → β} {l : List α} (H) :
107105 pmap g (map f l) H = pmap (fun a h => g (f a) h) l fun _ h => H _ (mem_map_of_mem h) := by
108106 induction l
@@ -285,13 +283,13 @@ theorem getElem_attach {xs : List α} {i : Nat} (h : i < xs.attach.length) :
285283 xs.attach[i] = ⟨xs[i]'(by simpa using h), getElem_mem (by simpa using h)⟩ :=
286284 getElem_attachWith h
287285
288- @[simp, grind = ] theorem pmap_attach {l : List α} {p : {x // x ∈ l} → Prop } {f : ∀ a, p a → β} (H) :
286+ @[simp] theorem pmap_attach {l : List α} {p : {x // x ∈ l} → Prop } {f : ∀ a, p a → β} (H) :
289287 pmap f l.attach H =
290288 l.pmap (P := fun a => ∃ h : a ∈ l, p ⟨a, h⟩)
291289 (fun a h => f ⟨a, h.1 ⟩ h.2 ) (fun a h => ⟨h, H ⟨a, h⟩ (by simp)⟩) := by
292290 apply ext_getElem <;> simp
293291
294- @[simp, grind = ] theorem pmap_attachWith {l : List α} {p : {x // q x} → Prop } {f : ∀ a, p a → β} (H₁ H₂) :
292+ @[simp] theorem pmap_attachWith {l : List α} {p : {x // q x} → Prop } {f : ∀ a, p a → β} (H₁ H₂) :
295293 pmap f (l.attachWith q H₁) H₂ =
296294 l.pmap (P := fun a => ∃ h : q a, p ⟨a, h⟩)
297295 (fun a h => f ⟨a, h.1 ⟩ h.2 ) (fun a h => ⟨H₁ _ h, H₂ ⟨a, H₁ _ h⟩ (by simpa)⟩) := by
@@ -349,26 +347,24 @@ theorem getElem_attach {xs : List α} {i : Nat} (h : i < xs.attach.length) :
349347 xs.attach.tail = xs.tail.attach.map (fun ⟨x, h⟩ => ⟨x, mem_of_mem_tail h⟩) := by
350348 cases xs <;> simp
351349
352- @[grind =]
353350theorem foldl_pmap {l : List α} {P : α → Prop } {f : (a : α) → P a → β}
354351 (H : ∀ (a : α), a ∈ l → P a) (g : γ → β → γ) (x : γ) :
355352 (l.pmap f H).foldl g x = l.attach.foldl (fun acc a => g acc (f a.1 (H _ a.2 ))) x := by
356353 rw [pmap_eq_map_attach, foldl_map]
357354
358- @[grind =]
359355theorem foldr_pmap {l : List α} {P : α → Prop } {f : (a : α) → P a → β}
360356 (H : ∀ (a : α), a ∈ l → P a) (g : β → γ → γ) (x : γ) :
361357 (l.pmap f H).foldr g x = l.attach.foldr (fun a acc => g (f a.1 (H _ a.2 )) acc) x := by
362358 rw [pmap_eq_map_attach, foldr_map]
363359
364- @[simp, grind = ] theorem foldl_attachWith
360+ @[simp] theorem foldl_attachWith
365361 {l : List α} {q : α → Prop } (H : ∀ a, a ∈ l → q a) {f : β → { x // q x } → β} {b} :
366362 (l.attachWith q H).foldl f b = l.attach.foldl (fun b ⟨a, h⟩ => f b ⟨a, H _ h⟩) b := by
367363 induction l generalizing b with
368364 | nil => simp
369365 | cons a l ih => simp [ih, foldl_map]
370366
371- @[simp, grind = ] theorem foldr_attachWith
367+ @[simp] theorem foldr_attachWith
372368 {l : List α} {q : α → Prop } (H : ∀ a, a ∈ l → q a) {f : { x // q x } → β → β} {b} :
373369 (l.attachWith q H).foldr f b = l.attach.foldr (fun a acc => f ⟨a.1 , H _ a.2 ⟩ acc) b := by
374370 induction l generalizing b with
@@ -407,18 +403,16 @@ theorem foldr_attach {l : List α} {f : α → β → β} {b : β} :
407403 | nil => simp
408404 | cons a l ih => rw [foldr_cons, attach_cons, foldr_cons, foldr_map, ih]
409405
410- @[grind =]
411406theorem attach_map {l : List α} {f : α → β} :
412407 (l.map f).attach = l.attach.map (fun ⟨x, h⟩ => ⟨f x, mem_map_of_mem h⟩) := by
413408 induction l <;> simp [*]
414409
415- @[grind =]
416410theorem attachWith_map {l : List α} {f : α → β} {P : β → Prop } (H : ∀ (b : β), b ∈ l.map f → P b) :
417411 (l.map f).attachWith P H = (l.attachWith (P ∘ f) (fun _ h => H _ (mem_map_of_mem h))).map
418412 fun ⟨x, h⟩ => ⟨f x, h⟩ := by
419413 induction l <;> simp [*]
420414
421- @[simp, grind = ] theorem map_attachWith {l : List α} {P : α → Prop } {H : ∀ (a : α), a ∈ l → P a}
415+ @[simp] theorem map_attachWith {l : List α} {P : α → Prop } {H : ∀ (a : α), a ∈ l → P a}
422416 {f : { x // P x } → β} :
423417 (l.attachWith P H).map f = l.attach.map fun ⟨x, h⟩ => f ⟨x, H _ h⟩ := by
424418 induction l <;> simp_all
@@ -444,7 +438,6 @@ theorem map_attach_eq_pmap {l : List α} {f : { x // x ∈ l } → β} :
444438 apply pmap_congr_left
445439 simp
446440
447- @[grind =]
448441theorem attach_filterMap {l : List α} {f : α → Option β} :
449442 (l.filterMap f).attach = l.attach.filterMap
450443 fun ⟨x, h⟩ => (f x).pbind (fun b m => some ⟨b, mem_filterMap.mpr ⟨x, h, m⟩⟩) := by
@@ -475,7 +468,6 @@ theorem attach_filterMap {l : List α} {f : α → Option β} :
475468 ext
476469 simp
477470
478- @[grind =]
479471theorem attach_filter {l : List α} (p : α → Bool) :
480472 (l.filter p).attach = l.attach.filterMap
481473 fun x => if w : p x.1 then some ⟨x.1 , mem_filter.mpr ⟨x.2 , w⟩⟩ else none := by
@@ -487,7 +479,7 @@ theorem attach_filter {l : List α} (p : α → Bool) :
487479
488480-- We are still missing here `attachWith_filterMap` and `attachWith_filter`.
489481
490- @[simp, grind = ]
482+ @[simp]
491483theorem filterMap_attachWith {q : α → Prop } {l : List α} {f : {x // q x} → Option β} (H) :
492484 (l.attachWith q H).filterMap f = l.attach.filterMap (fun ⟨x, h⟩ => f ⟨x, H _ h⟩) := by
493485 induction l with
@@ -496,7 +488,7 @@ theorem filterMap_attachWith {q : α → Prop} {l : List α} {f : {x // q x} →
496488 simp only [attachWith_cons, filterMap_cons]
497489 split <;> simp_all [Function.comp_def]
498490
499- @[simp, grind = ]
491+ @[simp]
500492theorem filter_attachWith {q : α → Prop } {l : List α} {p : {x // q x} → Bool} (H) :
501493 (l.attachWith q H).filter p =
502494 (l.attach.filter (fun ⟨x, h⟩ => p ⟨x, H _ h⟩)).map (fun ⟨x, h⟩ => ⟨x, H _ h⟩) := by
@@ -506,14 +498,13 @@ theorem filter_attachWith {q : α → Prop} {l : List α} {p : {x // q x} → Bo
506498 simp only [attachWith_cons, filter_cons]
507499 split <;> simp_all [Function.comp_def, filter_map]
508500
509- @[grind =]
510501theorem pmap_pmap {p : α → Prop } {q : β → Prop } {g : ∀ a, p a → β} {f : ∀ b, q b → γ} {l} (H₁ H₂) :
511502 pmap f (pmap g l H₁) H₂ =
512503 pmap (α := { x // x ∈ l }) (fun a h => f (g a h) (H₂ (g a h) (mem_pmap_of_mem a.2 ))) l.attach
513504 (fun a _ => H₁ a a.2 ) := by
514505 simp [pmap_eq_map_attach, attach_map]
515506
516- @[simp, grind = ] theorem pmap_append {p : ι → Prop } {f : ∀ a : ι, p a → α} {l₁ l₂ : List ι}
507+ @[simp] theorem pmap_append {p : ι → Prop } {f : ∀ a : ι, p a → α} {l₁ l₂ : List ι}
517508 (h : ∀ a ∈ l₁ ++ l₂, p a) :
518509 (l₁ ++ l₂).pmap f h =
519510 (l₁.pmap f fun a ha => h a (mem_append_left l₂ ha)) ++
@@ -530,50 +521,47 @@ theorem pmap_append' {p : α → Prop} {f : ∀ a : α, p a → β} {l₁ l₂ :
530521 l₁.pmap f h₁ ++ l₂.pmap f h₂ :=
531522 pmap_append _
532523
533- @[simp, grind = ] theorem attach_append {xs ys : List α} :
524+ @[simp] theorem attach_append {xs ys : List α} :
534525 (xs ++ ys).attach = xs.attach.map (fun ⟨x, h⟩ => ⟨x, mem_append_left ys h⟩) ++
535526 ys.attach.map fun ⟨x, h⟩ => ⟨x, mem_append_right xs h⟩ := by
536527 simp only [attach, attachWith, map_pmap, pmap_append]
537528 congr 1 <;>
538529 exact pmap_congr_left _ fun _ _ _ _ => rfl
539530
540- @[simp, grind = ] theorem attachWith_append {P : α → Prop } {xs ys : List α}
531+ @[simp] theorem attachWith_append {P : α → Prop } {xs ys : List α}
541532 {H : ∀ (a : α), a ∈ xs ++ ys → P a} :
542533 (xs ++ ys).attachWith P H = xs.attachWith P (fun a h => H a (mem_append_left ys h)) ++
543534 ys.attachWith P (fun a h => H a (mem_append_right xs h)) := by
544535 simp only [attachWith, pmap_append]
545536
546- @[simp, grind = ] theorem pmap_reverse {P : α → Prop } {f : (a : α) → P a → β} {xs : List α}
537+ @[simp] theorem pmap_reverse {P : α → Prop } {f : (a : α) → P a → β} {xs : List α}
547538 (H : ∀ (a : α), a ∈ xs.reverse → P a) :
548539 xs.reverse.pmap f H = (xs.pmap f (fun a h => H a (by simpa using h))).reverse := by
549540 induction xs <;> simp_all
550541
551- @[grind =]
552542theorem reverse_pmap {P : α → Prop } {f : (a : α) → P a → β} {xs : List α}
553543 (H : ∀ (a : α), a ∈ xs → P a) :
554544 (xs.pmap f H).reverse = xs.reverse.pmap f (fun a h => H a (by simpa using h)) := by
555545 rw [pmap_reverse]
556546
557- @[simp, grind = ] theorem attachWith_reverse {P : α → Prop } {xs : List α}
547+ @[simp] theorem attachWith_reverse {P : α → Prop } {xs : List α}
558548 {H : ∀ (a : α), a ∈ xs.reverse → P a} :
559549 xs.reverse.attachWith P H =
560550 (xs.attachWith P (fun a h => H a (by simpa using h))).reverse :=
561551 pmap_reverse ..
562552
563- @[grind =]
564553theorem reverse_attachWith {P : α → Prop } {xs : List α}
565554 {H : ∀ (a : α), a ∈ xs → P a} :
566555 (xs.attachWith P H).reverse = (xs.reverse.attachWith P (fun a h => H a (by simpa using h))) :=
567556 reverse_pmap ..
568557
569- @[simp, grind = ] theorem attach_reverse {xs : List α} :
558+ @[simp] theorem attach_reverse {xs : List α} :
570559 xs.reverse.attach = xs.attach.reverse.map fun ⟨x, h⟩ => ⟨x, by simpa using h⟩ := by
571560 simp only [attach, attachWith, reverse_pmap, map_pmap]
572561 apply pmap_congr_left
573562 intros
574563 rfl
575564
576- @[grind =]
577565theorem reverse_attach {xs : List α} :
578566 xs.attach.reverse = xs.reverse.attach.map fun ⟨x, h⟩ => ⟨x, by simpa using h⟩ := by
579567 simp only [attach, attachWith, reverse_pmap, map_pmap]
@@ -627,7 +615,7 @@ theorem countP_attachWith {p : α → Prop} {q : α → Bool} {l : List α} (H :
627615 (l.attachWith p H).countP (fun a : {x // p x} => q a) = l.countP q := by
628616 simp only [← Function.comp_apply (g := Subtype.val), ← countP_map, attachWith_map_subtype_val]
629617
630- @[simp]
618+ @[simp, grind = ]
631619theorem count_attach [BEq α] {l : List α} {a : {x // x ∈ l}} :
632620 l.attach.count a = l.count ↑a :=
633621 Eq.trans (countP_congr fun _ _ => by simp) <| countP_attach
0 commit comments