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: tensor algebra of free module over integral domain is a domain #9890
Conversation
Provide instances: * `Nontrivial (TensorAlgebra R M)` when `M` is a module over a nontrivial semiring `R` * `NoZeroDivisors (MonoidAlgebra R (FreeMonoid X))` when `R` is a semiring and `X` a type with decidable equality * `NoZeroDivisors (TensorAlgebra R M)` when `M` is a module over a commutative semiring `R` with no zero-divisors * `IsDomain (TensorAlgebra R M)` when `M` is a module over an integral domain
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.
LGTM! I'll maybe give @adomani time to come give this a final look before merging
(and of course, you should look at it when it's not super late in case you had any more ideas)
This is all very nice, thanks! I wonder whether this result should be more "generic" in terms of In fact, using a Lex order on Lists and an arbitrary linear order on the underlying type |
This should indeed work for |
Ah, I see! What about exploiting a little of TwoUniqueSums.of_covariant_left, since FreeMonoid is cancellative? |
I tried that, but it needs a linear order. Indeed, there should be some common result that both the instance in this PR and the one you refer to can be constructed from. |
I'll try this when I have some more time. What I had in mind was to use a lex ordering on Lists and any linear order on the base type In the multiset case, I think that you are also extracting both the min and the max for a lex order on any linear extension. Anyway, I may have some time to try this out tonight or tomorrow, but this is just a way of golfing further the PR: I am happy with the results, even if I think that the proofs can be streamlined. |
Reviewers, thank you very much for your work on this. It's been an education. Do you have any further suggestions?
|
No more improvements have come to mind. @eric-wieser, any suggestions? Do you think this should be merged, and do you think it's ready? Anything else I should do (like ask another person to review)? |
@adomani Do you remember why you called this lemma
|
I've completed a refactor that cuts 18 lines off the PR and proves the more general
Feel free to merge! |
Merged. |
I think that your name is indeed better. I suspect that the name that I gave referred to an older version of the lemma that might have contained an image... |
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.
Thanks! I wouldn't have thought of the condition hf
without you extracting of_graded_mul
; my hf
is simply a weakened form of your hinj
that assumes f b = f d
in addition. What I observed is that in
theorem of_graded_mul {X G : Type*} [Mul X] [Add G] [IsRightCancelAdd G] [LinearOrder G]
[CovariantClass G G (· + ·) (· < ·)] [CovariantClass G G (Function.swap (· + ·)) (· < ·)]
{f : X → G} (hf : ∀ x y : X, f (x * y) = f x + f y)
(hinj : ∀ a b c d : X, a * b = c * d → f a = f c → a = c ∧ b = d) :
TwoUniqueProds X where
(let's pretend everything is multiplicative) hf
is saying that f
is a MulHom, and the conditions on G guarantees that G has TwoUniqueProds by TwoUniqueProds.of_covariant_right. Once I realized these it's natural to come up with of_mulHom
.
This PR looks good to me now, but I just noticed no one ever added any labels to it? I added two and I'll wait a day for comments before sending it to maintainers.
theorem of_injective_mulHom (f : H →ₙ* G) (hf : Function.Injective f) (_ : UniqueProds G) : | ||
UniqueProds H := of_mulHom f (fun _ _ _ _ _ ↦ .imp (hf ·) (hf ·)) | ||
|
||
/-- `UniqueProd` is preserved under multiplicative equivalences. -/ | ||
@[to_additive "`UniqueSums` is preserved under additive equivalences."] | ||
theorem mulHom_image_iff (f : G ≃* H) : | ||
UniqueProds G ↔ UniqueProds H := | ||
⟨mulHom_image_of_injective f.symm f.symm.injective, mulHom_image_of_injective f f.injective⟩ | ||
theorem _root_.MulEquiv.uniqueProds_iff (f : G ≃* H) : UniqueProds G ↔ UniqueProds H := | ||
⟨of_injective_mulHom f.symm f.symm.injective, of_injective_mulHom f f.injective⟩ |
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.
Since we renamed mulHom_image_of_injective
, I've now also renamed mulHom_image_iff
for consistency.
-- deprecated 2024-02-04 | ||
@[deprecated] alias UniqueProds.mulHom_image_of_injective := UniqueProds.of_injective_mulHom | ||
@[deprecated] alias UniqueSums.addHom_image_of_injective := UniqueSums.of_injective_addHom | ||
@[deprecated] alias UniqueProds.mulHom_image_iff := MulEquiv.uniqueProds_iff | ||
@[deprecated] alias UniqueSums.addHom_image_iff := AddEquiv.uniqueSums_iff | ||
@[deprecated] alias TwoUniqueProds.mulHom_image_of_injective := TwoUniqueProds.of_injective_mulHom | ||
@[deprecated] alias TwoUniqueSums.addHom_image_of_injective := TwoUniqueSums.of_injective_addHom | ||
@[deprecated] alias TwoUniqueProds.mulHom_image_iff := MulEquiv.twoUniqueProds_iff | ||
@[deprecated] alias TwoUniqueSums.addHom_image_iff := AddEquiv.twoUniqueSums_iff |
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.
And added deprecated aliases. (I doubt anyone is using them, but still ...)
maintainer merge |
🚀 Pull request has been placed on the maintainer queue by alreadydone. |
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.
Thanks 🎉
bors merge
…9890) Provide instances * `Nontrivial (TensorAlgebra R M)` when `M` is a module over a nontrivial semiring `R` * `NoZeroDivisors (FreeAlgebra R X)` when `R` is a commutative semiring with no zero-divisors and `X` any type * `IsDomain (FreeAlgebra R X)` when `R` is an integral domain and `X` is any type * `TwoUniqueProds (FreeMonoid X)` where `X` is any type (this provides `NoZeroDivisors (MonoidAlgebra R (FreeMonoid X))` when `R` is a semiring and `X` any type, via `TwoUniqueProds.toUniqueProds` and `MonoidAlgebra.instNoZeroDivisorsOfUniqueProds`) * `NoZeroDivisors (TensorAlgebra R M)` when `M` is a free module over a commutative semiring `R` with no zero-divisors * `IsDomain (TensorAlgebra R M)` when `M` is a free module over an integral domain `R` In Algebra.Group.UniqueProds: * Rename `UniqueProds.mulHom_image_of_injective` to `UniqueProds.of_injective_mulHom`. * New lemmas `UniqueMul.of_mulHom_image`, `UniqueProds.of_mulHom`, `TwoUniqueProds.of_mulHom` show the relevant property holds in the domain of a multiplicative homomorphism if it holds in the codomain, under a certain hypothesis on the homomorphism. Co-authored-by: Richard Copley <rcopley@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Junyan Xu <junyanxu.math@gmail.com>
Pull request successfully merged into master. Build succeeded: |
…9890) Provide instances * `Nontrivial (TensorAlgebra R M)` when `M` is a module over a nontrivial semiring `R` * `NoZeroDivisors (FreeAlgebra R X)` when `R` is a commutative semiring with no zero-divisors and `X` any type * `IsDomain (FreeAlgebra R X)` when `R` is an integral domain and `X` is any type * `TwoUniqueProds (FreeMonoid X)` where `X` is any type (this provides `NoZeroDivisors (MonoidAlgebra R (FreeMonoid X))` when `R` is a semiring and `X` any type, via `TwoUniqueProds.toUniqueProds` and `MonoidAlgebra.instNoZeroDivisorsOfUniqueProds`) * `NoZeroDivisors (TensorAlgebra R M)` when `M` is a free module over a commutative semiring `R` with no zero-divisors * `IsDomain (TensorAlgebra R M)` when `M` is a free module over an integral domain `R` In Algebra.Group.UniqueProds: * Rename `UniqueProds.mulHom_image_of_injective` to `UniqueProds.of_injective_mulHom`. * New lemmas `UniqueMul.of_mulHom_image`, `UniqueProds.of_mulHom`, `TwoUniqueProds.of_mulHom` show the relevant property holds in the domain of a multiplicative homomorphism if it holds in the codomain, under a certain hypothesis on the homomorphism. Co-authored-by: Richard Copley <rcopley@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Junyan Xu <junyanxu.math@gmail.com>
…9890) Provide instances * `Nontrivial (TensorAlgebra R M)` when `M` is a module over a nontrivial semiring `R` * `NoZeroDivisors (FreeAlgebra R X)` when `R` is a commutative semiring with no zero-divisors and `X` any type * `IsDomain (FreeAlgebra R X)` when `R` is an integral domain and `X` is any type * `TwoUniqueProds (FreeMonoid X)` where `X` is any type (this provides `NoZeroDivisors (MonoidAlgebra R (FreeMonoid X))` when `R` is a semiring and `X` any type, via `TwoUniqueProds.toUniqueProds` and `MonoidAlgebra.instNoZeroDivisorsOfUniqueProds`) * `NoZeroDivisors (TensorAlgebra R M)` when `M` is a free module over a commutative semiring `R` with no zero-divisors * `IsDomain (TensorAlgebra R M)` when `M` is a free module over an integral domain `R` In Algebra.Group.UniqueProds: * Rename `UniqueProds.mulHom_image_of_injective` to `UniqueProds.of_injective_mulHom`. * New lemmas `UniqueMul.of_mulHom_image`, `UniqueProds.of_mulHom`, `TwoUniqueProds.of_mulHom` show the relevant property holds in the domain of a multiplicative homomorphism if it holds in the codomain, under a certain hypothesis on the homomorphism. Co-authored-by: Richard Copley <rcopley@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Junyan Xu <junyanxu.math@gmail.com>
Provide instances
Nontrivial (TensorAlgebra R M)
whenM
is a module overa nontrivial semiring
R
NoZeroDivisors (FreeAlgebra R X)
whenR
is a commutativesemiring with no zero-divisors and
X
any typeIsDomain (FreeAlgebra R X)
whenR
is an integral domainand
X
is any typeTwoUniqueProds (FreeMonoid X)
whereX
is any type(this provides
NoZeroDivisors (MonoidAlgebra R (FreeMonoid X))
when
R
is a semiring andX
any type,via
TwoUniqueProds.toUniqueProds
and
MonoidAlgebra.instNoZeroDivisorsOfUniqueProds
)NoZeroDivisors (TensorAlgebra R M)
whenM
is a free moduleover a commutative semiring
R
with no zero-divisorsIsDomain (TensorAlgebra R M)
whenM
is a free module overan integral domain
R
In Algebra.Group.UniqueProds:
UniqueProds.mulHom_image_of_injective
toUniqueProds.of_injective_mulHom
.UniqueMul.of_mulHom_image
,UniqueProds.of_mulHom
,TwoUniqueProds.of_mulHom
show the relevant property holds in thedomain of a multiplicative homomorphism if it holds in the codomain,
under a certain hypothesis on the homomorphism.