Zulip Chat Archive
Stream: general
Topic: Social Choice in mathlib
Andrew Souther (Nov 20 2021 at 18:04):
I would like to start a conversation about PRing my work on Social Choice Theory in Lean. Right now, my repo has two main files:
-
In the
basic
file, I have been slowly formalizing the first chapter of Collective Choice and Social Welfare by Amartya Sen. I have just been working through and formalizing each definition and lemma as they come, without much thought yet towards building a user-friendly library. -
In the
arrows_theorem
file, I have formalized a proof of Arrow's Impossibility Theorem.
Some maintainers have expressed interest in getting this work on mathlib. What should a PR look like for this work? Should I start with Arrow's Theorem and then PR bit-by-bit from there if people are interested in more? Where should I even plan to put these files?
@Scott Morrison once suggested putting social choice theory and combinatorial game theory in their own home. I have long-term hopes to formalize more results in social choice theory, game theory, and microeconomic theory if that affects how we think about this.
Yaël Dillies (Nov 20 2021 at 18:10):
Start by opening some PR for the preliminary lemmas. Then you can PR Arrow's theorem in several go. I don't quite know where it belongs. combinatorics.social
or order.social
both sound like decent places to me.
Andrew Souther (Nov 20 2021 at 18:12):
Also, I have been in contact with Eric Pacuit and Wesley Holliday who wrote this paper on Voting Theory in Lean. In the next few months, we plan to merge our code into one unified framework. They are real experts in social choice theory (I am not), and they have offered to help guide the conversation about design choices for a useful social choice library going forward.
Yaël Dillies (Nov 20 2021 at 18:20):
Then I would advise you to coordinate with them first. You do not have a huge amount of code, so PRing to mathlib should go smoothly. I see Eric Pacuit is already here, by the way!
Adrien Champion (Sep 06 2023 at 08:34):
@Andrew Souther I have a proof of arrow's theorem from Sen's book as well (so, the first three chapters) in Lean 4 where I made everything I could computable. What's the status on your work?
Adrien Champion (Sep 06 2023 at 08:34):
As far as I can tell it's not in mathlib 4 is it?
Andrew Souther (Sep 06 2023 at 12:30):
I haven't worked on this project much since I was a student in 2021. You're right, it never made it into mathlib. It's just sitting in an old GitHub repo. Congrats on your proof!
Adrien Champion (Sep 06 2023 at 13:50):
I see thanks! I'm working towards publishing my version but I want to clean it up first, I'll update this thread once I have
Adrien Champion (Sep 06 2023 at 13:50):
@Bolton Bailey don't be sad there's a brand new proof in Lean 4 :grinning:
Yury G. Kudryashov (Sep 07 2023 at 04:02):
Are you going to PR it?
Adrien Champion (Sep 08 2023 at 18:22):
Well once I improve the presentation and documentation I'd rather get feedback first. This is my first time working a proof that big, so I'm not sure it'll be up to mathlib's standards
Adrien Champion (Sep 08 2023 at 18:24):
I'm actually very confident it won't, starting with the syntax as I did not try to follow mathlib's conventions mostly because I don't know them
Anatole Dedecker (Sep 08 2023 at 19:46):
Actually the best way to get your code to mathlib standards is probably to open a pull request. Of course it’s better if you can start the job on your own, but you’ll probably get a lot more feedback by opening PRs than by sending some code on Zulip
Adrien Champion (Sep 09 2023 at 08:59):
It just hit me that, since I'm doing the whole book (well, just the first three chapters currently), I'm using mostly custom typeclasses. For preorder/quasi-order/order for instance (though they imply mathlib's). So instead of cleaning everything I did I should probably just rewrite Arrow without custom classes
Adrien Champion (Sep 09 2023 at 09:01):
In particular I have a custom notion of Finite
-ness, as I struggled to get a computable one from Mathlib. The main issue here is that it's my first time using Mathlib at all, in everything else I did I depended only on core and sometimes std4
Adrien Champion (Sep 09 2023 at 09:16):
What I'm saying is that I realize now we will probably never merge anything based on what I have right now, but I can try to write a version that's more Mathlib-friendly. The issue being time/energy/actual job :confused:
Adrien Champion (Sep 09 2023 at 09:22):
My repository is public now. It's far from where I wanted it to be before sharing it, but hopefully it will make the conversation easier
Eric Rodriguez (Sep 09 2023 at 13:04):
For finite, was Fintype
(maybe with decidable_eq and such) not good enough for you?
Adrien Champion (Sep 09 2023 at 15:45):
Well the thing is, I needed a notion of finiteness early on and at that point I was still avoiding to depend on Mathlib...
Adrien Champion (Sep 09 2023 at 15:48):
In any case, I'll try my best to write a Mathlib-friendly version as soon as I find enough time, most likely using Fintype
since my Finite
class is kind of based on it
Adrien Champion (Apr 30 2024 at 11:14):
Adrien Champion said:
In any case, I'll try my best to write a Mathlib-friendly version as soon as I find enough time, most likely using
Fintype
since myFinite
class is kind of based on it
I'm currently working on this, but I'm struggling to get familiar enough with Fintype
, Finset
, Multiset
, Quot
... to write what I want, in particular computable definitions
Adrien Champion (Apr 30 2024 at 11:16):
I could use some mentoring on these things, maybe @Eric Rodriguez or @Yury G. Kudryashov ?
Shreyas Srinivas (Apr 30 2024 at 17:06):
There is a Finite
type in mathlib
Shreyas Srinivas (Apr 30 2024 at 17:26):
But in general if you want to enumerate the finite set, Fintype
is the best bet.
Yury G. Kudryashov (May 01 2024 at 04:27):
I'm pretty busy at my day job these days. I can answer specific questions (preferrably with some specific result you want to formalize).
Yury G. Kudryashov (May 01 2024 at 04:33):
Generally,
- if you need cardinality, then
Fintype.card
/Finset.card
have more API than noncomputableNat.card
/Set.ncard
(though improvements forNat.card
/Set.ncard
are welcome); - if you don't need
[Fintype]
to state the theorem, then you can assumeFinite
, then docases nonempty_fintype α
, if you need it for the proof.
Adrien Champion (May 01 2024 at 11:59):
I'm looking for mentoring in the general approach, I don't have a lot of experience writing complex proofs. My original proof was very "dev-oriented", for instance to show that a max exists in a (finite) quasi-preorder I would just fold over the list of elements and retrieve a max (see here)
Adrien Champion (May 01 2024 at 12:01):
But now that I'd like to write a mathlib version, I'm wondering whether it is idiomatic both for mathlib in general and w.r.t. how Fintype
is supposed to be used in particular
Adrien Champion (May 01 2024 at 14:21):
To replace the previous, dev-oriented version, I currently have this
Adrien Champion (May 01 2024 at 14:23):
I'd like to get on the least-wrong track early to hopefully merge something in mathlib eventually, but as I'm very much a total noob in proof architecture it's proving difficult; not to mention I'm not super familiar with mathlib
Eric Rodriguez (May 04 2024 at 17:32):
Hi Adrien, similarly to Yury I'm pretty busy sorry to say. Your code formatting is a little un-idiomatic - we tend not to indent for namespace
, for example; #style may be a good place to start there. It seems to me you wrote stuff in a very constructive way - is this your aim?
Yury G. Kudryashov (May 04 2024 at 17:47):
Note that most of Mathlib
is non-constructive.
Adrien Champion (May 06 2024 at 13:40):
It seems to me you wrote stuff in a very constructive way - is this your aim?
Yes, as mentioned several times above being constructive whenever possible was a goal when I wrote the original version.
Adrien Champion (May 06 2024 at 13:42):
Yury G. Kudryashov said:
Note that most of
Mathlib
is non-constructive.
Yes that's why I was wondering whether my approach made sense for merging in mathlib. Sadly it doesn't, and I don't have the skills nor the interest to do a non-constructive version. Would be a different story if I had infinite time/money as I wouldn't mind acquiring these skills, but I don't have infinite time/money so... :confused:
Eric Wieser (May 06 2024 at 14:05):
I think your Finite
is mathlib's docs#FinEnum?
Eric Wieser (May 06 2024 at 14:06):
Also, I think things would be easier for you if you dropped ProtoOrder
and use docs#Preorder instea
Adrien Champion (May 06 2024 at 14:07):
Eric Wieser said:
I think your
Finite
is mathlib'sFinEnum
?
First time hearing about it, sounds right, thanks!
Eric Wieser (May 06 2024 at 14:07):
Though unless your computation is really order-dependent, you should be able to use Fintype
instead
Eric Wieser (May 06 2024 at 14:07):
(but if you want to remain constructive, you should indeed avoid Mathlib's Finite
)
Adrien Champion (May 06 2024 at 14:08):
That's what the new version draft does
Bulhwi Cha (May 06 2024 at 15:45):
@Adrien Champion Would you like to see a constructive version of Mathlib?
Adrien Champion (May 06 2024 at 15:46):
I don't think so no, I'm not sure it makes sense for most things in mathlib, does it?
Bulhwi Cha (May 06 2024 at 15:48):
I think Lean's library of constructive mathematics should be separated from Mathlib.
Shreyas Srinivas (May 06 2024 at 15:49):
In social choice theory, being constructive in some places is helpful since quite a few proofs are just algorithms
Shreyas Srinivas (May 06 2024 at 15:51):
But generally it is nice to pick and choose, since there are indeed existential results. For example the proof of existence EF1 indivisible allocations is constructive, while the proof of existence of envy free connected continuous cake division is existential
Bulhwi Cha (May 06 2024 at 15:54):
If you keep the constructive version of your work, perhaps we can include it in ConsMath (Lean's constructive mathematics library) later.
Last updated: May 02 2025 at 03:31 UTC