On Tue, Feb 28, 2012 at 10:10:24PM +0100, Ralf Hemmecke wrote:
> On 02/28/2012 06:24 PM, Serge D. Mechveliani wrote:
>> For f := (x^2 - 1) :: UP(x,INT)
>>
>> factor f
>> yields
>> (12) (x - 1)(x + 1)
>> Type: Factored(UnivariatePolynomial(x,Integer)),
>>
>> and prime?(f) $UP(x,INT)
>
> That's funny. HyperDoc (and the code) says that factor only exists if
> the coefficient domain has PolynomialFactorizationExplicit. One can
> easily check that *no* domain in FriCAS exports this category
> unconditionally. Strange that FriCAS finds a factorization routine at
> all.
This is somow against classical algorithmic algebra.
1) Classical algebra says that
Z[x] is an unique factorization domain with an algorithmic factorization.
2) Axiom announces that it has polynomial factorization, over Integer too.
3) UniqueFactorizationDomain has `factor' and `prime?' among its operations.
Hence it is natural for Axiom to provide `factor' and `prime?' for Z[x]
for all its representations given in Axiom for UP, SUP, POLY, etc.
Because as it is done for POLY(..INT..), it is easy to spread them also
to UP(x,INT) too.
Probably, it does this, but it is difficult to find.
> Looking at MULTFACT reveals that this only applies to very special
> situation.
> [..]
> ==============================================================
> MultivariateFactorize(OV,E,R,P) : C == T
> where
> R : Join(EuclideanDomain, CharacteristicZero)
> -- with factor on R[x]
> OV : OrderedSet
> E : OrderedAbelianMonoidSup
> P : PolynomialCategory(R,E,OV)
>
> [..]
Thank you.
This looks like some hint.
But to tell it simply: how to factor in UP(x,INT) ?
There are many people who know that a polynomial f with integer
coefficients can be factored and do not know the meaning of the scripts
like
> R : Join(EuclideanDomain, CharacteristicZero)
> -- with factor on R[x]
> OV : OrderedSet
> E : OrderedAbelianMonoidSup
They just have f := x^3 -1 : UP(x,INT),
and nothing else.
Now: do they need to call in Spad
factor(f) $ MultivariateFactorize(OV,E,R,P)
and to cleverly decide what to put for OV, E and P ?
Also may be, to consider convertion from INT to Fraction INT.
This invesigation will, probably, take a week.
I suspect that there exists a simple way for this in Spad.
I am looking into
"Browse -- factor -- Operations -- Origins"
(in the same time as e-mailing this question)
and trying to choose ...
May be, GenUFactorize(INT)
fits?
I try in Spad:
f() : Factored SUP ==
X := monomial(1 ::INT, 1 ::NNI) $UPol
y := X pretend SUP
f := (4*y^2 - 1) :: SUP
factor(f) $GenUFactorize(INT)
It works!
Is this a reasonable approach?
And what about `prime?' ? We need to search a package ...
Generally, it is very difficult to find the needed package and also
often difficult to put a correct parameter values.
May be, there is possible import AllFactorization
?
(in order to apply `factor' without specification,
and let the compiler give a warning:
such and such variants for `factor' fit this particular piece of code).
And there is something strange in this total necessity for the user to
search cleverly among tons of packages.
The compiler knows itself that SUP INT has UniqueFactorizationDomain,
and that `factor' and `prime?' are operations from
UniqueFactorizationDomain. The user program needs not to mention this
knowledge. Hence, for
factor(f :: SUP INT) :: Factored SUP INT
it must know itself what `factor' signature variant fits this piece of
code. Often such is unique. For example, the compiler knows that `factor'
of @Boolean does not fit the above expression. In this case, the thing
is compiled.
If more than one implementation signatures fit, the compiler could give
a warning: choose among implementations in these packages ...
In Haskell + glasgow-ext (DoCon), it is much simpler.
In most cases the choice is unique. In other cases (of several class
instances that overlap at this type of f) the compiler needs to choose
an instance of an operation (say, `factor') among a finite set of intances
for this particular type of the argument, say, f :: UPol R.
The compiler chooses the instance the most specific by the type parameter
substitution. If such does not exist, reports the error.
For example,
If Integer has Foo, then the type UPol Integer
is obtained by a substitution from Foo rR => UPol rR.
Hence the instance of `factor' is taken from the implementatiion given
for UPol Integer, it is more specific than the genetal one of
Foo rR => UPol rR, and it overrides. Such is an agreement for the
language (this can be generalized).
And it occurs that the user needs only to specify the type of f, and
the compiler finds all the rest
-- with respect to the program _modules_ imported by the compiled module
(modules are like packages in Spad, only without parameters).
The instances for the same type may be given in many modules.
There is possible nested import. And DoCon allows
import DExport -- import all open items DoCon --
-- all items exported from all DoCon modules.
Axiom is larger, so this may be several large blocks, say,
import AllFactorization AllPlottingGraphis
Thanks,
------
Sergei
[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.