Canonical

4 views
Skip to first unread message

Ralf Hemmecke

unread,
Aug 23, 2022, 10:51:04 AM8/23/22
to fricas-devel
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".

Ralf

Waldek Hebisch

unread,
Aug 28, 2022, 1:58:03 PM8/28/22
to fricas...@googlegroups.com
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.

--
Waldek Hebisch

Ralf Hemmecke

unread,
Aug 28, 2022, 2:21:18 PM8/28/22
to fricas...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages