Skip to content
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

canonical_unit implementations differ from docs #1254

Open
lgoettgens opened this issue Jan 29, 2023 · 7 comments
Open

canonical_unit implementations differ from docs #1254

lgoettgens opened this issue Jan 29, 2023 · 7 comments

Comments

@lgoettgens
Copy link
Collaborator

I thought about adding some conformance checks for canonical_unit via adding

@test is_unit(canonical_unit(a))
@test equality(canonical_unit(a * b), canonical_unit(a) * canonical_unit(b))

after this line.
The reasoning comes from the documentation.

However, this fails for basically all rings, and is even worse for some others (cf. #1166). The main reason being canonical_unit(0 * something) = canonical_unit(0) = 1 != 1 * canonical_unit(something) = canonical_unit(0) * canonical_unit(something).

To circumvent this problem, one could change the conformance test to

@test is_unit(canonical_unit(a))
@test iszero(a * b) || equality(canonical_unit(a * b), canonical_unit(a) * canonical_unit(b))

This still fails for some rings, e.g. Matrix rings, due to the implementation there (link to implementation).

I would suggest either making the implementations compliant with the documentation or modifying the documentation.
Any thoughts on this?

@thofma
Copy link
Member

thofma commented Jan 29, 2023

Thanks for summing up the mismatch between the documentation and the reality. There are some other aspects of canonical_unit that require changes that would including fixing this. So I am not sure it is a good idea to spend time on fixing this.

(For example, the function should return the inverse of what it returns now and/or the caonicalized value. It should also be optional, probably using a trait like CanCanonicalize (like it is done in the iterator interface https://docs.julialang.org/en/v1/manual/interfaces/). But this now turns into a bigger overhaul that no one has time right now.)

@fieker
Copy link
Contributor

fieker commented Jan 30, 2023 via email

@fieker
Copy link
Contributor

fieker commented Jan 30, 2023 via email

@fieker
Copy link
Contributor

fieker commented Jan 30, 2023

OK, reading the doc, I think what is required/ suggested is that for a unit u, we have that
canonical_unit(a)u == canonical_unit(au) whic his trivially canonical_unit(a) * canonical_unit(u) since for units canonical_unit(u) == u always.

In general this is tricky: for a Ring R we consider a system of representatives of R modulo units and canonical_unit more of less picks the rep. So canonical_unit(u) == u just means that one rep is 1.
In geenral, I don't think one can impose any homomorphic properties on the representatives chosen....

@fingolfin
Copy link
Member

@lgoettgens where in the docs does it claim that canonical_unit is a homomorphism? I just couldn't find a place, but if there is one, it should indeed be fixed.

In the meantime, docs/src/ring_interface.md describes the identity @fieker mentions, where one factor is a unit.

@fieker
Copy link
Contributor

fieker commented Mar 10, 2023 via email

@lgoettgens
Copy link
Collaborator Author

@lgoettgens where in the docs does it claim that canonical_unit is a homomorphism? I just couldn't find a place, but if there is one, it should indeed be fixed.

In the meantime, docs/src/ring_interface.md describes the identity @fieker mentions, where one factor is a unit.

It comes from the same place in stable/ring_interface/#Canonicalisation @fieker mentioned. I think I read it that way since it is not stated that u is supposed to be a unit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants