Ralf Hemmecke wrote:
> 
> Hi Waldek,
> 
> I need some hints.
> 
> After a few fixes wrt the aldor-interface, I am stuck with the following 
> error.
> 
> #1 (Error) Argument 2 of `FiniteDivisor' did not match any possible 
> parameter type.
>      The rejected type is UnivariatePolynomialCategory(#1 pretend Ring).
>      Expected type UnivariatePolynomialCategory(#2 pretend Field).
> 
> It steams from ap/PFO.ap. The original code is in pfo.spad.pamphlet 
> (copied below). What looks a bit strange and that is where this error 
> comes from is the translation of
> 
>    if R0 has CharacteristicZero and F has AlgebraicallyClosedField then
>      simplifyCoeffs : (FD, List K) -> N
> 
> into the .ap format. That's done via |makeAxExportForm| from ax.boot.
> (See generate-ax-file in src/aldor/gendepap.lsp.)
> 
> Only in this "if" body there appear |PretendTo| expressions (see below) 
> that seem to let the aldor compilation fail. For sure there must be some 
> technicalities to ensure that inside that "if" body R0 and F belong 
> additionally to other categories, but I don't quite understand why I see 
> "(|PretendTo| |#2| |Field|)" or (|PretendTo| |#1| |Ring|)".
> 
> I don't know exactly which part of the FriCAS code is responsible for 
> this, but I've the feeling that it is not ax.boot, since that is just 
> translating the available data structures.

AFAICS the relevant code in ax.boot is triggered by '$pretendFlag'.
You may try to see what happens when '$pretendFlag' is always false.
I am affraid this code is necessary: it looks that pretends try
tu say that arguments have expected types.  Assumung that Spad
compiler already checked arument types it is reasonable strategy.
However, it seems that 'axFormatType' function from ax.boot got
confused due to nesting and changing meaning of '#1', '#2', ...
Namely, we have

PointsOfFiniteOrder(R0, F, UP, UPUP, R): ...

here #1 is R0, #2 is F, #3 is UP.  But then we have:

FD  ==> FiniteDivisor(F, UP, UPUP, R)

FiniteDivisor has its own #1 which is F, #2 which is UP,...
This part seem to be handled correctly, 'axFormatType' substitutes
proper values for arguments of FiniteDivisor.  However, the
second argument of FiniteDivisor, that is UP is declared to be
of type 'UnivariatePolynomialCategory(#1)'.  Here '#1' refers
to first argument of FiniteDivisor, while apparenty 'axFormatType'
uses first argument of PointsOfFiniteOrder.

> Anyway, this generation even looks wrong to me. Let's suppose the 
> context is Foo: Cat1. Then
> 
>    if Foo has Cat2 then CODE
> 
> should mean that inside CODE we can claim Foo: Join(Cat1, Cat2).
> 
> But as you see below, it looks as if FriCAS just "|PretendTo| whatever 
> FiniteDivisor or UnivariatePolynomialCategory is originally defined.

No, IIUC arguments to types are pretended to be of correct type.
Conditions means that it is not entirely trivial to decide
if argument types are correct.  Minor difference between Spad
compiler and Aldor could lead to type error if you try to just
pass types 'as is'.

> Do you think the generated code is correct and Aldor simply shouldn't 
> fail? Or is the error rather on the FriCAS side?

As I wrote, I think that 'ax.boot' produced wrong code.

> ====================================
> from PFO.ap
> ====================================
> (|If| (|Test| (|Has| |#1| |CharacteristicZero|))
>                    (|If| (|Test| (|Has| |#2| |AlgebraicallyClosedField|))
>                     (|Declare| |simplifyCoeffs|
>                      (|Apply| ->
>                       (|Comma|
>                        (|Apply| |FiniteDivisor| (|PretendTo| |#2| |Field|)
>                         (|PretendTo| |#3|
>                          (|Apply| |UnivariatePolynomialCategory|
>                           (|PretendTo| |#1| |Ring|)))
                            ^^^^^^^^^^^^^^^^^^^^^^^^
This is wrong, insted we should have (|PretendTo| |#2| |Field|).

>                         (|PretendTo| |#4|
>                          (|Apply| |UnivariatePolynomialCategory|
>                           (|PretendTo|
>                            (|Apply| |Fraction|
>                             (|PretendTo| |#2| |IntegralDomain|))
>                            |Ring|)))
>                         (|PretendTo| |#5|
>                          (|Apply| |FunctionFieldCategory|
>                           (|PretendTo| |#1| |UniqueFactorizationDomain|)
>                           (|PretendTo| |#2|
>                            (|Apply| |UnivariatePolynomialCategory|
>                             (|PretendTo| |#1| |Ring|)))
>                           (|PretendTo| |#3|
>                            (|Apply| |UnivariatePolynomialCategory|
>                             (|PretendTo|
>                              (|Apply| |Fraction|
>                               (|PretendTo| |#2| |IntegralDomain|))
>                              |Ring|))))))
>                        (|Apply| |List|
>                         (|PretendTo|
>                          (|Apply| |Kernel| (|PretendTo| |#2| |Comparable|))
>                          |Type|)))
>                       |NonNegativeInteger|))
>                     NIL)
>                    NIL)
> 


-- 
                              Waldek Hebisch
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to