All Exercises
#46 Filter is Idempotent
live.lean-lang.org
Pure Lean 4 · No Mathlib
MediumLists

46. Filter is Idempotent

Prove that filtering a list twice with the same boolean predicate `p : α → Bool` produces the exact same result as filtering it once.

Target Theorem
theorem list_filter_idem {α : Type} (p : α → Bool) (xs : List α) : (xs.filter p).filter p = xs.filter p
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).