Zulip Chat Archive
Stream: Is there code for X?
Topic: finsupp.pi
Yaël Dillies (Dec 19 2021 at 13:59):
Do we have anything close to a finset.pi
-like definition for finsupp
? Here's how far I got
import data.finsupp.basic
open finset
open_locale pointwise
variables {ι α : Type*}
namespace finsupp
variables [decidable_eq ι] [has_zero α]
/-- Given a finitely supported function `f : ι →₀ finset α`, one can define the finset
`f.pi` of all finitely supported functions whose value at `i` is in `f i` for all `i`. -/
def pi (f : ι →₀ finset α) : finset (ι →₀ α) :=
begin
refine (f.support.pi (λ i, f i)).preimage (λ g i _, g i) (λ a ha b hb h, _),
rw [set.mem_preimage, mem_coe, mem_pi] at ha hb,
ext i,
by_cases hi : i ∈ f.support,
{ convert _root_.congr_fun (_root_.congr_fun h i) hi },
{
}
end
end finsupp
Kevin Buzzard (Dec 19 2021 at 14:02):
Wait a second -- if iota is infinite then for some i you have f i = empty (assuming 0=bot) so the set you're considering is also empty. Is that what you mean?
Yaël Dillies (Dec 19 2021 at 14:05):
Yes
Yaël Dillies (Dec 19 2021 at 14:05):
Wait, no, you're misunderstanding docs#finset.has_zero.
Yaël Dillies (Dec 19 2021 at 14:07):
0 : finset α
is not the empty set, but {0}
. By what seems to me like a lucky coincidence, linear algebra forced upon us a definition of 0 : finset α
which is precisely the one I want in this seemingly unrelated context.
Eric Wieser (Dec 19 2021 at 14:08):
I think that should be called finset.finsupp not finsupp.pi
Eric Wieser (Dec 19 2021 at 14:09):
Because what you're doing is replacing the A → B
(pi) in finset.pi with A →₀ B
(finsupp)
Yaël Dillies (Dec 19 2021 at 14:10):
But... dot notation
Eric Wieser (Dec 19 2021 at 14:13):
You could rename finset.pi
to pi.finset
to keep dot notation as finsupp.finset
Yaël Dillies (Dec 19 2021 at 14:14):
Anyway, the sorried goal is false. Do you have any idea how to fix this?
Eric Wieser (Dec 19 2021 at 14:15):
I see no sorry
;)
Yaël Dillies (Dec 19 2021 at 14:17):
Okay, I have excused myself now.
Eric Wieser (Dec 19 2021 at 14:22):
Can you add the statement of mem_pi
that you want? x ∈ finsupp.pi f ↔ _
Yaël Dillies (Dec 19 2021 at 15:35):
This is what I want
@[simp] lemma mem_pi {f : ι →₀ finset α} {g : ι →₀ α} : g ∈ f.pi ↔ ∀ i, g i ∈ f i :=
I'm thinking I need finsupp.extend
, which apparently doesn't exist?
Yaël Dillies (Dec 19 2021 at 15:41):
Ahah! finsupp.map_domain
is what I want.
Yaël Dillies (Dec 19 2021 at 17:52):
Sorry, it's me again. I'm still stuck at the same place, but this time with a slightly different definition.
vimport data.finsupp.basic
variables {ι α : Type*}
namespace finset
variables [decidable_eq ι] [decidable_eq α] [has_zero α]
def finsupp (s : finset ι) (t : ι → finset α) : finset (ι →₀ α) :=
(s.pi t).map sorry
@[simp] lemma mem_finsupp {s : finset ι} {t : ι → finset α} {f : ι →₀ α} :
f ∈ s.finsupp t ↔ ∀ i ∈ s, f i ∈ t i :=
sorry
end finset
Yaël Dillies (Dec 19 2021 at 17:53):
I need the injection (Π (a : ι), a ∈ s → α) ↪ ι →₀ α
which adds zeroes outside of s
.
Eric Wieser (Dec 19 2021 at 18:10):
Isn't that docs#finsupp.on_finset?
Yaël Dillies (Dec 19 2021 at 18:11):
Yeah, that's what I'm figuring out now. I'm working through it.
Yaël Dillies (Dec 19 2021 at 18:14):
However, it's not quite bundled in the way I want. Do you mind if I refactor finsupp.on_finset
to be
def on_finset (s : finset α) (f : ∀ a ∈ s, M) : α →₀ M :=
Eric Wieser (Dec 19 2021 at 18:35):
Is docs#dfinsupp.mk more similar?
Yaël Dillies (Dec 19 2021 at 18:51):
Yeah
Yaël Dillies (Dec 19 2021 at 18:52):
Should I just define finsupp.mk
, then? I don't really know much this bit of the library, so it's hard to judge.
Eric Wieser (Dec 19 2021 at 19:26):
docs#finsupp.mk already exists and is a constructor!
Yaël Dillies (Dec 19 2021 at 19:28):
Ah of course! How should I name it then?
Eric Wieser (Dec 19 2021 at 19:29):
I think maybe extend
is a good name after all
Eric Wieser (Dec 19 2021 at 19:29):
Is docs#function.extend similar?
Eric Wieser (Dec 19 2021 at 19:30):
No...
Eric Wieser (Dec 19 2021 at 19:30):
Yaël Dillies (Dec 19 2021 at 19:38):
Why not finsupp.indicator
after all.
Last updated: Dec 20 2023 at 11:08 UTC