Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

[Merged by Bors] - refactor(ring_theory/ideal/quotient): extract a ring_con structure #17833

Closed
wants to merge 15 commits into from

Conversation

eric-wieser
Copy link
Member

@eric-wieser eric-wieser commented Dec 6, 2022

The intent here is to remove some duplication with ring_quot.

I've only copied across the basic lemmas from group_theory/congruence; I imagine most of the rest won't be that useful, and that if we do want them, we should look for a means to deduplicate them.

Note that ring_con.quotient can be used to take quotients of semirings.


Open in Gitpod

@eric-wieser eric-wieser added WIP Work in progress RFC Request for comment t-algebra Algebra (groups, rings, fields etc) labels Dec 6, 2022
@eric-wieser eric-wieser added awaiting-review The author would like community review of the PR and removed WIP Work in progress RFC Request for comment labels Dec 10, 2022
Comment on lines 125 to 184
section data

section add_mul
variables [has_add R] [has_mul R] (c : ring_con R)
instance : has_add c.quotient := c.to_add_con.has_add
@[simp, norm_cast] lemma coe_add (x y : R) : (↑(x + y) : c.quotient) = ↑x + ↑y := rfl
instance : has_mul c.quotient := c.to_con.has_mul
@[simp, norm_cast] lemma coe_mul (x y : R) : (↑(x * y) : c.quotient) = ↑x * ↑y := rfl
end add_mul

section zero
variables [add_zero_class R] [has_mul R] (c : ring_con R)
instance : has_zero c.quotient := c.to_add_con^.quotient.has_zero
@[simp, norm_cast] lemma coe_zero : (↑(0 : R) : c.quotient) = 0 := rfl
end zero

section one
variables [has_add R] [mul_one_class R] (c : ring_con R)
instance : has_one c.quotient := c.to_con^.quotient.has_one
@[simp, norm_cast] lemma coe_one : (↑(1 : R) : c.quotient) = 1 := rfl
end one

section neg_sub_zsmul
variables [add_group R] [has_mul R] (c : ring_con R)
instance : has_neg c.quotient := c.to_add_con^.has_neg
@[simp, norm_cast] lemma coe_neg (x : R) : (↑(-x) : c.quotient) = -x := rfl
instance : has_sub c.quotient := c.to_add_con^.has_sub
@[simp, norm_cast] lemma coe_sub (x y : R) : (↑(x - y) : c.quotient) = x - y := rfl
instance has_zsmul : has_smul ℤ c.quotient := c.to_add_con^.quotient.has_zsmul
@[simp, norm_cast] lemma coe_zsmul (z : ℤ) (x : R) : (↑(z • x) : c.quotient) = z • x := rfl
end neg_sub_zsmul

section nsmul
variables [add_monoid R] [has_mul R] (c : ring_con R)
instance has_nsmul : has_smul ℕ c.quotient := c.to_add_con^.quotient.has_nsmul
@[simp, norm_cast] lemma coe_nsmul (n : ℕ) (x : R) : (↑(n • x) : c.quotient) = n • x := rfl
end nsmul

section pow
variables [has_add R] [monoid R] (c : ring_con R)
instance : has_pow c.quotient ℕ := c.to_con^.nat.has_pow
@[simp, norm_cast] lemma coe_pow (x : R) (n : ℕ) : (↑(x ^ n) : c.quotient) = x ^ n := rfl
end pow

section nat_cast
variables [add_monoid_with_one R] [has_mul R] (c : ring_con R)
instance : has_nat_cast c.quotient := ⟨λ n, ↑(n : R)⟩
@[simp, norm_cast] lemma coe_nat_cast (n : ℕ) : (↑(n : R) : c.quotient) = n := rfl
end nat_cast

section int_cast
variables [add_group_with_one R] [has_mul R] (c : ring_con R)
instance : has_int_cast c.quotient := ⟨λ z, ↑(z : R)⟩
@[simp, norm_cast] lemma coe_int_cast (n : ℕ) : (↑(n : R) : c.quotient) = n := rfl
end int_cast

instance [inhabited R] [has_add R] [has_mul R] (c : ring_con R) : inhabited c.quotient :=
⟨↑(default : R)⟩

end data
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that we'd normally put blank lines here, but there's so little actualy going on (copy an existing instance, write the lemma unfolding it) that it feels like a waste of space.

@eric-wieser eric-wieser changed the title refactor(ring_theory/ideal/quotient): abstract a ring_con structure refactor(ring_theory/ideal/quotient): extract a ring_con structure Dec 10, 2022
@mathlib-dependent-issues-bot mathlib-dependent-issues-bot added the blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. label Dec 10, 2022
@mathlib-dependent-issues-bot mathlib-dependent-issues-bot removed the blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. label Dec 10, 2022
@mathlib-dependent-issues-bot
Copy link
Collaborator

@Vierkantor Vierkantor self-assigned this Dec 14, 2022
Copy link
Collaborator

@Vierkantor Vierkantor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't immediately see how this would make it easier to work with ring_quot: it looks like this is basically just a reimplementation of ring_quot that doesn't yet have as many lemmas. Is the point to (nearly) replace all of ring_quot with quotient (ring_con.r _)?

src/ring_theory/congruence.lean Outdated Show resolved Hide resolved
src/ring_theory/congruence.lean Show resolved Hide resolved
src/ring_theory/congruence.lean Show resolved Hide resolved
src/ring_theory/congruence.lean Outdated Show resolved Hide resolved
@Vierkantor Vierkantor added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Dec 14, 2022
@eric-wieser
Copy link
Member Author

I don't immediately see how this would make it easier to work with ring_quot: it looks like this is basically just a reimplementation of ring_quot that doesn't yet have as many lemmas

The main advantages are that:

  • It matches what we did for group_theory, and the general preference in mathlib to use quotient instead of quot
  • We can unify ideal.quotient with ring_quot
  • We could use it in future to golf cau_seq_completion

@eric-wieser eric-wieser added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Dec 22, 2022
@Vierkantor
Copy link
Collaborator

Thanks!

bors d+

@bors
Copy link

bors bot commented Dec 22, 2022

✌️ eric-wieser can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@github-actions github-actions bot added delegated The PR author may merge after reviewing final suggestions. and removed awaiting-review The author would like community review of the PR labels Dec 22, 2022
@eric-wieser
Copy link
Member Author

bors merge

@github-actions github-actions bot added the ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) label Dec 22, 2022
bors bot pushed a commit that referenced this pull request Dec 22, 2022
…17833)

The intent here is to remove some duplication with `ring_quot`.

I've only copied across the basic lemmas from `group_theory/congruence`; I imagine most of the rest won't be that useful, and that if we do want them, we should look for a means to deduplicate them.


Note that `ring_con.quotient` can be used to take quotients of semirings.
@bors
Copy link

bors bot commented Dec 22, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title refactor(ring_theory/ideal/quotient): extract a ring_con structure [Merged by Bors] - refactor(ring_theory/ideal/quotient): extract a ring_con structure Dec 22, 2022
@bors bors bot closed this Dec 22, 2022
@bors bors bot deleted the eric-wieser/ring_con branch December 22, 2022 21:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
delegated The PR author may merge after reviewing final suggestions. ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) t-algebra Algebra (groups, rings, fields etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants