Zulip Chat Archive
Stream: Is there code for X?
Topic: Finset of all functions from a fin type with image in finset
Bolton Bailey (Mar 08 2023 at 02:42):
Is there a function with the type signature def foo {A B : Type} [fintype A] (S : finset B) : finset (A -> B) := sorry
which returns the set of all functions with images subset of B?
Eric Wieser (Mar 08 2023 at 06:30):
By which you mean, ∀ f ∈ foo S, finset.univ.image f ⊆ S
?
Eric Wieser (Mar 08 2023 at 06:32):
(finset.univ : finset (A → S)).map ⟨(∘ coe), sorry⟩
should do the trick
Yakov Pechersky (Mar 08 2023 at 09:09):
docs#function.embedding.subtype for the map if that helps with the composition proof
Bolton Bailey (Mar 08 2023 at 15:54):
import data.mv_polynomial.basic
def foo (A B : Type) [fintype A] (S : finset B) : finset (A -> B) :=
(finset.univ : finset (A → S)).map ⟨(∘ coe), sorry⟩
What do I have to import to synthesize fintype (A → ↥S)
?
Alex J. Best (Mar 08 2023 at 16:01):
open_locale classical
or add some decidability assumptions, look at docs#pi.fintype.
import data.mv_polynomial.basic
open_locale classical
noncomputable
def foo (A B : Type) [fintype A] (S : finset B) : finset (A -> B) :=
(finset.univ : finset (A → S)).map ⟨λ f z, f z, sorry⟩
Bolton Bailey (Jul 26 2023 at 03:01):
For future reference, I found this way of writing it
def function_finset (A : Type) (B : Type) [DecidableEq A] [Fintype A] (S : Finset B) : Finset (A -> B) :=
Fintype.piFinset (fun _ => S)
Yaël Dillies (Jul 26 2023 at 13:05):
Yes, this is the canonical spelling.
Bolton Bailey (Aug 15 2023 at 21:33):
Is there interest in putting in a definition for this, or should I s/function_finset/Fintype.piFinset (fun _ => S)/g
my file?
Eric Wieser (Aug 15 2023 at 22:16):
I think probably the latter
Eric Wieser (Aug 15 2023 at 22:16):
You could use Fintype.piFInset (Function.const S)
if you prefer
Yaël Dillies (Aug 16 2023 at 07:05):
In LeanAPAP, we defined notation for it, but I really see no point in having a separate definition.
Last updated: Dec 20 2023 at 11:08 UTC