Hi Martin, On 2 Jul., 09:50, Martin Raum <[email protected]> wrote: > Yesterday and today I spend my time on adapting some classes in psage > to the changes that Simon has made to the categories and functors. In > particular, the codomain is now enforced and that drew my a attention > to the following: > > sage: FreeModule(QQ, 3) in Modules(ZZ) > False
Yes, that is rather unfortunate. > The only reason why the functor VectorSpace, which enforces the > codomain, does not crash is that its domain is > CommutativeAdditiveGroups(). More precisely: The reason for chosing that codomain is the fact that there seems to be no category of modules. There is only "category of R- modules", where R is a specific ring. > That is of cause true, however, it is > quite weak. In the particular case I was dealing with it would have > been of some use to have the codomain Modules(some fancy ring) or at > least Modules(ZZ), The problem is that the functor can not know the base rings in advance. > The first would demand for something like an automatic restriction of > functions, and I don't think it is what we want globally. The latter, > though, would simply need > > sage: FreeModule(QQ, 3) in Modules(ZZ) > True > > which is the mathematically correct answer. One would need to find the > coercion from ZZ to QQ and then conclude that this leads to a faithful > functor from Modules(QQ) to Modules(ZZ). Normally, each category provides a (finite) list of immediate super- categories, for example: sage: C = Modules(QQ['t']) sage: C.super_categories() [Category of bimodules over Univariate Polynomial Ring in t over Rational Field on the left and Univariate Polynomial Ring in t over Rational Field on the right] >From those lists, the list of all super-categories is inferred by recursion. Now, for categories C1 and C2, C1.is_subcategory(C2) essentially tests whether C2 belongs to the list of super categories of C1. But for categories with base ring (Modules, algebras, etc. pp) the list returned by C.super_cateogories() will always have the same base ring. Some random thoughts on solving that problem: One may introduce categories without base ring for each category WITH base ring. I don't know whether this is provided by the "abstract categories". Then, domain and codomain of a functor could be a base- ring-free category. Another way: Modify is_subcategory, so that coercion of base rings is taken into account. For example, if C1 and C2 have base rings B1 and B2, then we can not have C1.is_subcategory(C2) if B2 does not coerce into B1. IF B2 coerces into B1, then one could create a version C1b of C1 with base ring B2 (see below), and then test whether C2 appears in the list of super categories of C1b. One may introduce a method "restrict_base_ring" for all categories C with a base ring: If B2 coerces into B1 then, say, Modules(B1).restrict_base_ring(B1) would return Modules(B2). Cheers, Simon -- To post to this group, send an email to [email protected] To unsubscribe from this group, send an email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
