All Exercises
#45 Filter Cannot Increase Length
live.lean-lang.org
Pure Lean 4 · No Mathlib
EasyLists

45. Filter Cannot Increase Length

Prove that filtering a list with any boolean predicate `p : α → Bool` yields a list no longer than the original.

Target Theorem
theorem list_filter_length_le {α : Type} (p : α → Bool) (xs : List α) : (xs.filter p).length ≤ xs.length
Hints (0/3)

Stuck? Reveal hints one step at a time without spoiling the full proof.

Symbols:
Initializing Lean 4 editor…
Infoview & Diagnosticsline 1idle
Write your proof above and click Submit Proof (or open in live.lean-lang.org).