I am looking at problem reported by Kurt Pagani.  Direct reason
for trouble is that up to 1.3.6  FreeModuleCategory exported
retraction to base set.  This retraction is no longer present
in 1.3.7.  FreeModule still has such retraction, but
XPolynomialRing which inherits implementation from FreeModule
among other is of category FreeModuleCategory and no longer
exports this retraction.  XDistributedPolynomial which officially
exorts 'retract' used to inherit implementation from XPolynomialRing,
but in 1.3.7 XPolynomialRing has no 'retract' so also
XDistributedPolynomial has no implemetation of 'retract'.

At first glance this may look easy to fix.  But there is deeper
trouble.  Trying to export 'retract' from FreeModuleCategory
leads to trouble with polynomials.  Reason is easy to see:
various retractions are distinguished only by target type.
If we have several retractions with the same target type,
then overloading does not work (retractions have quite
different effects, but our overloading machinery gives no way
to choose right one).  In particular, for univariate polynomials
NNI is type of exponents, but also legal type for coefficients.
Worse, NNI is subtype of Integer and our retraction machinery
assumes that it can use retraction to Integer even when NNI is
requested.

Anyway, in general having retraction both to T1 and T2 is unsafe
unless we are sure that T1 is different than T2.  In case of
commutative polynomials currently we have retraction to variables
and retraction to coefficients.  AFAICS this is unsafe, as we can
form SparseMultivariatePolynomial(Integer, Integer), that
is Integer may serve both as coefficients and as variables.
More generally, any ordered commutatitve semiring may serve
such dual purpose.

In case of XDistributedPolynomial ATM there is only one exported
retraction, that is retraction to exponents.  However, is would be
natural to have retraction to coefficients (such retraction makes
sense for any algebra with unit).  For XDistributedPolynomial
this still is safe, as coefficients are required to be a ring
and exponents are FreeMonoid which is not a ring.  But
in case of XPolynomialRing in principle coefficients may be
the same as exponents (both can be a ring), so having two
retractions is unsafe.

I admit that ATM I am not sure what to do.  Inside algebra
probably most sensible solution is to keep retraction from
polynomials to coefficients (which is very fundamental) and
avoid use of other retractions.  It is less clear if we
should keep exporting extra retractions for use in user
code or ban them as potentially unsafe.

-- 
                              Waldek Hebisch

-- 
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 fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/20220429230317.GA2095%40fricas.math.uni.wroc.pl.

Reply via email to