On Tue, Jun 10, 2025 at 11:56:28AM +0200, Grégory Vanuxem wrote:
> Hello,
>
> Le mar. 10 juin 2025 à 00:50, Waldek Hebisch <
de...@fricas.org> a écrit :
>
> > There are some bugs that I looked up, but ATM do not know how to
> > solve.
> >
> > 1)
> >
> > ((%i*t-1)*z*(z^2-3*t^2-3))/(sqrt(2)*sqrt(3)*(t^4+4*%i*t^3-6*t^2-4*%i*t+1))
> >
> > give type UnivariatePolynomial(t,Expression(Complex(Integer))). Result
> > is biggish, so I do not put it here, but one can see that t-s from
> > numerater are treated as variable in UnivariatePolynomial, while
> > t-s in denominator are treated as belonging to
> > Expression(Complex(Integer)).
> >
>
> That may be unsatisfactory but, comment out:
>
> t1 = '(AlgebraicNumber) and t2 is ['Complex,.] =>
> resolveTT1('(Expression (Integer)), t2)
>
> in resolveTTSpecial (line 176 of src/interp/i-resolve.boot) and let the
> user choose the type of arg(s) of sqrt and consort or coerce algebraic
> numbers himself. And, eventually, implement some specific
> coercion(s)/conversion(s) in Spad. Commenting this breaks for example
> operation between Complex(*) * AlgebraicNumber (sqrt(2)*complex(1,2).
Yes, this is unsatisfactory. The rule above is dubious, but
since we forbid Complex(AlgebraicNumber) the next possibilty
is Expression (Integer). Simply removing it breaks many
uses of %i.
> Or
>
> --- /home/greg/Tmp/fricas/src/interp/i-resolv.boot 2025-06-08
> 17:07:09.731630604 +0200
> +++ src/interp/i-resolv.boot 2025-06-10 11:34:56.189106604 +0200
> @@ -190,12 +190,15 @@
> t1 = '(AlgebraicNumber) and (t2 = ['Complex, $Float] or t2 = ['Complex,
> $DoubleFloat]) =>
> ['Expression, CADR t2]
>
> - t1 = '(AlgebraicNumber) and t2 is ['Complex,.] =>
> - resolveTT1('(Expression (Integer)), t2)
> -
> t1 = ['AlgebraicNumber] and t2 is ['Polynomial, ['Fraction, ['Integer]]]
> =>
> ['Polynomial, ['AlgebraicNumber]]
>
> + t1 = '(AlgebraicNumber) and t2 is ['Polynomial,.] =>
> + resolveTT1('(Expression (Integer)), t2)
> +
> + t1 = '(AlgebraicNumber) and t2 is ['Complex,.] =>
> + resolveTT1('(Expression (Integer)), t2)
> +
> t1 = ['AlgebraicNumber] and
> t2 is ['Fraction, ['Polynomial, ['Fraction, ['Integer]]]] =>
> ['Fraction, ['Polynomial, ['AlgebraicNumber]]]
Also, the rule
t1 = '(AlgebraicNumber) and t2 is ['Polynomial,.] =>
resolveTT1('(Expression (Integer)), t2)
in general is undesirable. We probably want rule
t1 = ['AlgebraicNumber] and t2 is ['Polynomial, t3] and
(t4 := resolveTT1(t1, t3)) => ['Polynomial, t4]
More generally, AFAICS core of the trouble is that resolve works
on subexpressions and commits to choice inside subexpressions,
without noting that choices in various parts are inconsistent.
We can tweak rules so that some specific cases work OK and
it makes sense to do so when there is no regression for other
cases. But this example seem to be too complicated for current
tactic.
--
Waldek Hebisch