Zulip Chat Archive
Stream: new members
Topic: Decidable predicates
Martin Dvořák (Apr 04 2022 at 16:17):
How can I say that pred
has to be decidable in a way that is less awkward to write in Lean?
def f (pred : ℕ → Prop) [∀ x : ℕ, decidable (pred x)] (n : ℕ) : list ℕ :=
if pred n then [n] else []
Anne Baanen (Apr 04 2022 at 16:18):
You can use the docs#decidable_pred abbreviation:
def f (pred : ℕ → Prop) [decidable_pred pred] (n : ℕ) : list ℕ :=
if pred n then [n] else []
Last updated: Dec 20 2023 at 11:08 UTC