John
One of the previous postings made me realise that I do not know
what a coercion in Sage is designed to do: are they morphisms
or are they functors? Once I realised that coercion was being
used to implement myriad possible functors, I became worried.
In my view, the ideal situation would be for objects to be
"strongly categorized", and coercion should only be canonical
morphisms within this category. Functors should exist and
be easily definable by users in order to map objects from one
category into another. The objects in that category might
admit a completely different set of morphisms. If one class
of objects simultaneously exists (or can be transformed by a
coercion functor) in more than one category, then one loses
control over what are valid morphisms, which is precisely the
advantage of the categorical structure.
Specifically I find the application of a forgetful functor by
coercion dangerous.
Similarly construction of the pushout (I would prefer [fibered]
coproduct or sum) in the category of embedded number fields is
questionable for the same reason. First, one has to create a
new object, which might be computationally expensive; this is
an objection on the basis of computational efficiency. Second,
it may be universal (well-defined up to unique isomorphism) but
noncanonical. The particular example of a category of embedded
fields is misleading. The homsets Hom(X,Y) have at most one
element, any two coproducts are canonically isomorphic (even
forgetting the X -> X \oplus Y and Y -> X \oplus Y). In general
this will not be true.
For number fields, in my view the "correct" category should not
be number fields but etale algebras over QQ (or another base
number field for a category of relative extensions), and the
coproduct should just be the tensor product (and this distinction
shows the relevance of a strong category). This keeps the
category closed under finite products and sums. However,
I wouldn't expect addition or multiplication of two elements in
different number fields to create this universal object for me.
I would expect an error so I could debug my code (the most
likely case in which such an addition or multiplication would
arise).
Certainly, for a number field X there is a canonical morphism
from QQ to X, so I'm not saying that no coercions should exist.
Cheers,
David
P.S. I am aware that Sage does not implement my "ideal situation"
above, as demonstrated by the following example:
sage: PZ.<x> = PolynomialRing(ZZ)
sage: a = QQ(1/2)
sage: a + x
x + 1/2
sage: parent(a + x)
Univariate Polynomial Ring in x over Rational Field
Yes, this worries me somewhat -- both pushout(L1,L2) and pushout(QQ,ZZ[t])
-- since they create new objects, which are basically defined by a functor
from the product category ComAlg x ComAlg to ComAlg (together with the
canonical morphisms of L1 and L2 into L1 \otimes L2). The coercion is
a morphism, to a functorially created object, and opens the question of
which pairs (A,B) do we create A \otimes B? The answer would seem to
be determined by a mix of computational efficiency, existence of an
implementation, and maybe some judgment of how canonical the result is
(based for example on the size of the automorphism group of the result).
--David