People,
I have the two questions.
1. Extracting agrument domain from under a constructor
------------------------------------------------------
Is it possible in Spad to extract an argument domain (type) from a
constructed domain?
For example,
F : Field := ...
And it is known that F = Fraction D for some D : IntegralDomain,
so that F pretend Field and F pretend QuotientField
are correct.
But D is not given in the scope.
Can D be extracted from F by some operations,
so that, for example, the operations `1 :: D', `(f^2) $UP(x, D)'
become possible?
I think of
F := ... pretend QuotientField
unD := denom (1 :: F) -- unity of the searched D
sD : SExpression := dom unD
D := pretend IntegralDomain
I do not know whether this will works, I shall see.
On the other hand, as F is constructed as Fraction D, may be, D
can be directly extracted from F ?
2. Canonic fraction
-------------------
For a mutually prime n, d : (D : IntegralDomain),
how to set fraction of n/d in Spad with avoiding gcd and also
obtaining a correct fraction?
Recall that (2, -3) are mutually prime in Integer, as well as (-2, 3), or
(-2,-3).
There is desirable a function which can be applied like this:
fraction(NoGCD, n, d).
In the DoCon library a polymorphic function
canFr :: GCDRing a => String -> a -> a -> Fraction a
canFr mode n d = ...
canonizes a fraction n:/d to n':/d' over a GCDRing a.
mode = "g" means to cancel the pair by gcd.
"i" to cancel by canonical invertible,
"gi" to cancel by both.
If the client knows that n:/d is canonical, he can write n:/d,
and this costs 1 (the constructor `:/' applied -- 1 step).
If he knows that n and d are mutually prime, and he does not know the
value of (canInv d) == 1, he can write canFr "i" n d.
For example,
canFr "i" 2 (-3 :: Integer) --> (-2):/3
(canInv (-3) = -1).
Otherwise, he writes canFr "gi" n d.
This is arranged so because gcd may cost much, for example, for
Integer[x,y,z,u].
May be, in some cases, canInv may cost much.
But currently I care only of the gcd cost.
When DoCon puts a string to Axiom, fractions are in their canonical form
by "gi". And it is desirable to avoid gcd when parsing (by dParse)
of such a fraction to Axiom.
After parsing n, d : D, dParse applies
CONS(n, d)$Lisp pretend Fraction D.
But there arises the question of the cancellation by canInv.
Because if Axioms has a different idea of canInv, this parsing may occur
incorrect.
I tried:
(CONS(-2, 3)$Lisp pretend Fraction INT) = ((-2)/3 :: Fraction INT)
-->
true
So, for Integer, Axiom has the same notion of the canonical invertible.
For R[x1..xn], GCDRing R, DoCon defines canInv via canInv for
the leading coefficient, in a natural way.
Can you please, comment the subject?
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.