-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - feat(Algebra/Ring/Ext): prove extensionality lemmas for Ring and similar typeclasses #9511
Conversation
This is based on discussion in the Zulip thread https://leanprover.zulipchat.com/stream/287929-mathlib4/topic/Ring.20is.20determined.20by.20Semiring. Note that this commit introduce `sorry`s into the codebase. It is a WIP.
Prove `Semiring.ext` and `Semiring.ext_iff` lemmas, as well as that `Semiring.toNonUnitalSemiring` and `Semiring.toNonAssocSemiring` are injective.
Prove the injectivity lemma in terms of the `ext` lemma, as the former goes through showing that `h_add` and `h_mul` hold anyway.
Prove that `NonAssocSemiring.toNonUnitalNonAssocSemiring` is injective.
Prove an `ext` lemma and use it to show that `NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring` is injective as well as an `ext_iff` lemma.
…emiring` Show that `NonUnitalNonAssocSemiring.toDistrib` is injective.
One exception: leave the `h` in `fun h ↦` in `ext_iff` proofs, for (marginally) more readability.
Prove that `Semiring.toNonAssocSemiring` is injective.
For each of the three typeclasses, state the `ext` lemma with a sorried proof and prove the consequences (injectivity and `ext_iff` lemmas).
Highlight the locations in the file where something mathematically non-trivial is proved: namely that some operation is determined by others. (There are essentially only two such.)
Change `a`, `b` to `x`, `y` in accordance with https://leanprover-community.github.io/contribute/style.html#variable-conventions. Additionally, remove an unnecessary `'` from a variable `inst`.
Co-authored-by: Anne Baanen <[email protected]>
WARNING: this commit is NOT error-free.
WARNING: this commit is NOT error-free.
WARNING: this commit is NOT error-free.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late response, this dropped somewhat off my radar. The code looks good to me. Still have some small remarks about the comments.
bors d+
✌️ raghuram-13 can now approve this pull request. To approve and merge a pull request, simply reply with |
Ring
and similar typeclassesBased on review suggestions https://github.com/leanprover-community/mathlib4/pull/9511/files#r1574231108, https://github.com/leanprover-community/mathlib4/pull/9511/files#r1574232858. Co-authored-by: Anne Baanen <[email protected]>
bors r+ |
…lar typeclasses (#9511) Add a 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.
Build failed: |
Specifically, replace `← Int.coe_nat_eq` with `Int.ofNat_eq_coe`.
bors r+ |
…lar typeclasses (#9511) Add a 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.
Pull request successfully merged into master. Build succeeded: |
…lar typeclasses (#9511) Add a 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.
…lar typeclasses (#9511) Add a 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.
Add a file
Algebra/Ring/Ext
, provingext
lemmas for all of the ring-like classes (for example, anything fromNonUnitalNonAssocSemiring
toCommRing
), 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:
HasDistribNeg
.Comm
variants (currently it's just fromComm
variant to non-Comm
variant for each).A natural next step would be to extend this to
DivisionSemiring
,DivisionRing
,Semifield
andField
.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
ext
andext_iff
lemmas, eliminating even more boilerplate.It should be possible to extend that command to be more general (such as allowing
declModifiers
andterminationSuffix
clauses, 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.