I have no concrete usage for Canonical, just realised that it is basically unused. There is "shallowlyMutable" that declares a domain to be updatable.

Canonical just means for me that if two elements are equal, I would just have to compare the data structure. So as we already have for

  Fraction S

this is Canonical

"if S has Canonical and S has GcdDomain and S has canonicalUnitNormal"

Yes, actually for hashes it makes sense to require the key domain to be Canonical. That mutating the elements makes hashes invalid, is another problem and I expect a user to know that after destructively changing a hashed element s/he cannot expect everything to work.

So, I do not think that declaring a domain to be Canonical must mean that its elements are immutable. Just that two equal elements have an identically looking datastructure with the "leave" being equal (in the sense that they are not only equal in the mathematical sense but also their hashes are equal.

Before your mail I haven't thought deeply about Canonical, just figured that it's pretty unused and therefore quite useless in FriCAS. I thought that having a canonical representation is quite an important concept in Computer Algebra and actually quite many of the domains in FriCAS should have a canonical representation and that we could show by declaring them to be Canonical.

Ralf

On 28.08.22 19:58, Waldek Hebisch wrote:
On Tue, Aug 23, 2022 at 04:51:02PM +0200, Ralf Hemmecke wrote:
Shouldn't that be true? Is this an oversight in the implementation?

(159) -> SparseUnivariatePolynomial(Integer) has Canonical

    (159)  false

Same for UnivariatePolynomial('x, Integer).

Should I open an issue for this? Basically we currently ignore "Canonical".

Well, it would be easy to add Canonical to more domains.  OTOH
currenty Canonical is essentially unused, more precisly it is
only used to propagate itself.

What do you want to do with Canonical?  Basically the only use
I can think of is in definition of hash functions.  But
mutation can invalidate hashes.  So in narrow interpretation
Canonical should mean that values are immutable.  But
SparseUnivariatePolynomial has pomopo! so would be disqualified.

Of course, one can declare that users should not mutate values put
in hash tables and allow domains allowing mutation.  But I think
we should clarify possible uses of Canonical befor we go on.

If you have some plan for Canonical, then say what you want to
do and if it looks OK we can annotate several domains.


--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/6f8b5e24-6cd9-7cf1-8e09-23e4220b05be%40hemmecke.org.

Reply via email to