Zulip Chat Archive
Stream: general
Topic: Iterate through every function from fintype to fintype
Jihoon Hyun (Oct 05 2024 at 11:46):
As in the title, I'd like to iterate through all possible functions f : α → β
where Fintype α
and Fintype β
.
The goal is to return true
if there is no f
which g : (α → β) → Bool
returns false
, or false
otherwise.
How should I achieve this?
Yaël Dillies (Oct 05 2024 at 11:53):
Are you looking for docs#Pi.fintype ?
Jihoon Hyun (Oct 05 2024 at 11:55):
That's not a primary goal, but it seems like I can just use Fintype.elems
from there. Still, is there a more direct way?
Yaël Dillies (Oct 05 2024 at 11:59):
Does that fit the bill?
import Mathlib.Data.Fintype.Pi
def allTrue {α β : Type*} [DecidableEq α] [Fintype α] [Fintype β] (g : (α → β) → Bool) : Bool :=
∀ f, g f
Jihoon Hyun (Oct 05 2024 at 12:04):
Yes, that does the work! Thanks!
Last updated: May 02 2025 at 03:31 UTC