Skip to content

Commit

Permalink
chore: use boolean predicates in List.filter
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-em committed Sep 9, 2024
1 parent c96fbdd commit 7f86ff1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Init/Data/Array/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ theorem get_modify {arr : Array α} {x i} (h : i < arr.size) :
| cons => split <;> simp [*]

@[simp] theorem filter_filter (q) (l : Array α) :
filter p (filter q l) = filter (fun a => p a q a) l := by
filter p (filter q l) = filter (fun a => p a && q a) l := by
apply ext'
simp only [filter_data, List.filter_filter]

Expand Down
2 changes: 1 addition & 1 deletion src/Init/Data/List/Count.lean
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ theorem IsSuffix.countP_le (s : l₁ <:+ l₂) : countP p l₁ ≤ countP p l₂
theorem IsInfix.countP_le (s : l₁ <:+: l₂) : countP p l₁ ≤ countP p l₂ := s.sublist.countP_le _

theorem countP_filter (l : List α) :
countP p (filter q l) = countP (fun a => p a q a) l := by
countP p (filter q l) = countP (fun a => p a && q a) l := by
simp only [countP_eq_length_filter, filter_filter]

@[simp] theorem countP_true {l : List α} : (l.countP fun _ => true) = l.length := by
Expand Down
2 changes: 1 addition & 1 deletion src/Init/Data/List/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ theorem forall_mem_filter {l : List α} {p : α → Bool} {P : α → Prop} :

@[deprecated forall_mem_filter (since := "2024-07-25")] abbrev forall_mem_filter_iff := @forall_mem_filter

@[simp] theorem filter_filter (q) : ∀ l, filter p (filter q l) = filter (fun a => p a q a) l
@[simp] theorem filter_filter (q) : ∀ l, filter p (filter q l) = filter (fun a => p a && q a) l
| [] => rfl
| a :: l => by by_cases hp : p a <;> by_cases hq : q a <;> simp [hp, hq, filter_filter _ l]

Expand Down

0 comments on commit 7f86ff1

Please sign in to comment.