mathlib4
mathlib4 copied to clipboard
Prove extensionality lemmas for `Ring` and similar typeclasses
feat(Algebra/Ring/Ext): prove extensionality lemmas for Ring and similar typeclasses
Add file Algebra/Ring/Ext, proving ext lemmas for all of the ring-like classes (for example, anything from NonUnitalNonAssocSemiring to CommRing), stating that two instances of such a class are equal if they define the same addition and multiplication operations.
Also prove ext_iff variants for each class, and injectivity lemmas for projections from classes to parent classes.
Some notes:
-
Things I didn't do because they don't seem particularly necessary:
- I skipped
HasDistribNeg. - More injectivity lemmas could be proved between the
Commvariants (currently it's just fromCommvariant to non-Commvariant for each).
- I skipped
-
A natural next step would be to extend this to
DivisionSemiring,DivisionRing,SemifieldandField. -
I have introduced local notation to eliminate some boilerplate. I'm not sure if this is style-appropriate for Mathlib (although the notation is local to one file and (probably) never shows up when e.g. the types of lemmas are viewed, so that it's invisible to anyone not editing this file).
-
In another branch, I have used a (local) custom command to generate the
extandext_ifflemmas, eliminating even more boilerplate.It should be possible to extend that command to be more general (such as allowing
declModifiersandterminationSuffixclauses, allowing a custom theorem name defaulting toext, specifying the type for which an ext lemma is being proved, specifying the arguments, and letting the names be inaccessible by default while allowing them to be specified with a "with" clause), in which case it could become a useful command for writing extensionality lemmas (admittedly partially overlapping in functionality with putting an@[ext]on the type definition). -
I haven't written any tests — I'm not sure what to test or how to write tests.