Zulip Chat Archive
Stream: general
Topic: FinEnum
Shreyas Srinivas (Jul 31 2024 at 14:18):
Love this. Since you are writing about discrete mathematics, I was wondering if the book could guide users on how to move between Finsets and finite maps. When it is advisable to use Fintype
, FinEnum
, and just Fin n
and so on.
Eric Wieser (Jul 31 2024 at 14:19):
(I think docs#FinEnum is probably not currently that useful for anything, and could be redesigned from scratch)
Shreyas Srinivas (Jul 31 2024 at 14:19):
Well, I used it in finite graphs.
Shreyas Srinivas (Jul 31 2024 at 14:20):
It was easy to extract an ordering of neighbours from a Finset.
Shreyas Srinivas (Jul 31 2024 at 14:20):
Shreyas Srinivas (Jul 31 2024 at 14:22):
Fintype
only gives you a Finset
. Not great when you want to write a computation iterating over it, which can be the case for a lot of proofs in discrete math.
Bhavik Mehta (Jul 31 2024 at 14:33):
Shreyas Srinivas said:
Fintype
only gives you aFinset
. Not great when you want to write a computation iterating over it, which can be the case for a lot of proofs in discrete math.
With regards to discrete maths, it is absolutely true that FinEnum is pretty useless, a Finset is indeed plenty when you want to have a proof with iteration. The difference happens only when you want to work with a finset together with a specific ordering, which is a rare (non-existent?) situation in discrete mathematics.
Shreyas Srinivas (Jul 31 2024 at 14:43):
Well. Here is an easy example: round robin algorithm for finding EF 1 allocations of indivisible goods
Shreyas Srinivas (Jul 31 2024 at 14:43):
You start by allocating goods ( to say two agents) in some order determined by their valuation functions
Shreyas Srinivas (Jul 31 2024 at 14:44):
This is used to prove the existence of EF1 allocations
Bhavik Mehta (Jul 31 2024 at 14:47):
I think this discussion is not on topic any more, but - just going off the wikipedia description - the way this is typically done in mathlib is picking an ordering of the elements (wikipedia's step 1: "Number the people arbitrarily from 1 to n") by taking a list representative of the given finset, and running step 2 with a list fold. This immediately gives you the existence of EF1 allocations that you ask for.
Shreyas Srinivas (Jul 31 2024 at 14:48):
How is the ordering of the elements chosen? FinEnum gives one directly.
Shreyas Srinivas (Jul 31 2024 at 14:49):
Anyway, this is the kind of confusion that beginners like me tend to have
Bhavik Mehta (Jul 31 2024 at 14:50):
Shreyas Srinivas said:
Anyway, this is the kind of confusion that beginners like me tend to have
Right, I think this is a great example of why mentioning FinEnum increases the confusion! Let's continue the EF1 discussion elsewhere
Shreyas Srinivas (Jul 31 2024 at 14:55):
Can some selection messages be moved to a different thread? EF1 is just one example. I am thinking of all the problems whose solutions are some dynamic programming style recurrence.
Yaël Dillies (Jul 31 2024 at 15:17):
Yes, somehow file#Combinatorics/Enumerative/DoubleCounting is a stupidly easy but very crucial file
Patrick Massot (Jul 31 2024 at 18:25):
Shreyas, this is probably a nice example but not relevant to MIL which is about mathematics.
Jeremy Avigad (Jul 31 2024 at 20:45):
@Shreyas Srinivas For verifying combinatorial computation, you want to choose efficient representations and use the mathematical objects as ideal references to state and prove correctness. I agree that Finset
and Fintype
are not good for computation! As Patrick says, that's out of scope for MIL, though it is a good topic for lots of papers and tutorial.
Notification Bot (Jul 31 2024 at 23:07):
25 messages were moved here from #general > Finset vs Finite by Kim Morrison.
Kim Morrison (Jul 31 2024 at 23:12):
I have moved messages here, to try to increase the signal to noise ratio of the other thread.
(Avoiding the need for this in the first place may have been helpful!)
Shreyas Srinivas (Aug 01 2024 at 09:17):
@Kim Morrison : Apologies, I didn't want to side track that discussion. My primary goal was to bring up the kind of confusion that beginners face with finite types. Also, there is such a huge overlap between discrete mathematics and theoretical CS (especially complexity and algorithms theory) that I didnt quite see these topics as "not math". In fact the example I picked comes from social choice theory where mathematicians (Nash, Gale, Shapley, Steinhaus etc) have contributed a lot.
Shreyas Srinivas (Aug 01 2024 at 09:23):
@Jeremy Avigad : I am not trying to write efficient combinatorial procedures. Just prove things. Some proofs are just most elegantly described as recursive procedures upon which we do induction. I recall that this is also sometimes true in pure mathematics from Halmos' proof of the Steinitz lemma in his FDVS book. In such cases there is a "choose some ordering of elements" step, and my point is FinEnum does that for free.
Eric Wieser (Aug 01 2024 at 10:17):
Shreyas Srinivas said:
Fintype
only gives you aFinset
. Not great when you want to write a computation iterating over it, which can be the case for a lot of proofs in discrete math.
My claim is not that "FinEnum
is a useless idea", but rather "FinEnum
is a poorly-executed idea". The API works in terms of bijections with Fin
, but every instance goes back and forth with lists, making many things O(n) which should be O(1)
Last updated: May 02 2025 at 03:31 UTC