What is a "category" in Sage?

7 views
Skip to first unread message

Simon King

unread,
Feb 6, 2008, 4:34:16 AM2/6/08
to sage-support
Dear Sage team,

i am confused about the use of the notion "category" in Sage.

I defined M=Modules(PolynomialRing(QQ,'x,y,z')), and then i expected
that "M?"or dir(M) would provide me with informations on how to
construct objects of that category and morphisms between them, and
also tensor products. But i found nothing.

The Sage Tutorial and Programming Guide were not helpful (BTW, I'm
missing an index or a "search" functionality for both of them!).

The index of Sage Constructions holds no entry "category" or "tensor
product".

The Reference Manual provides some entries "category()", but they do
not explain what a category is ("Return the category of x." is not
exactly an explanation of the notion "category").

The Reference Manual describes a tensor product for graphs (something
that i am not familiar with), but not for modules over commutative
rings.

Are there other Sage manuals that i forgot to include into my
bookmarks?

Can you tell me what a "category" is in Sage, and how to construct
modules over a polynomial ring, module homomorphisms and tensor
products (actually i just need it for free modules)?

Yours sincerely
Simon

William Stein

unread,
Feb 6, 2008, 4:55:32 AM2/6/08
to sage-s...@googlegroups.com

Unfortunately there is no useful functionality for modules over a polynomial
ring directly in Sage, even over k[x] where k is a field, since nobody
contributed an implementation of Hermite Normal Form in that context yet.

Here's what you would do to create a module over a polynomial ring
then a submodule:

sage: R.<x> = QQ[]
sage: W = R^5; W
Ambient free module of rank 5 over the principal ideal domain
Univariate Polynomial Ring in x over Rational Field
sage: V = W.span([[x,0,0,2,1], [0,x,1,1,1]])

However, I just noticed that somebody (I think malb recently) appears
to have defined "echelon form"
for matrices over a polynomial ring (it should be Hermite Normal
Form), so instead
of getting NotImplementedErrors, a bunch of functions for modules over
polynomial
rings return False answers:

sage: V # wrong
Free module of degree 5 and rank 2 over Univariate Polynomial Ring in
x over Rational Field
Echelon basis matrix:
[ 1 0 0 2/x 1/x]
[ 0 1 1/x 1/x 1/x]
sage: [x,0,0,2,1] in V # wrong
False

Here's what you "would" do for a module over a poly ring in several variables.
At least this doesn't work:

sage: R.<x,y> = QQ[]
sage: W = R^5; W
Ambient free module of rank 5 over the integral domain Multivariate
Polynomial Ring in x, y over Rational Field
sage: V = W.span([[x,0,0,2,1], [0,x,1,1,y]]); V
---------------------------------------------------------------------------
<type 'exceptions.AttributeError'> Traceback (most recent call last)

/Users/was/<ipython console> in <module>()

<type 'exceptions.AttributeError'>: 'FreeModule_ambient_domain' object
has no attribute 'span'

http://trac.sagemath.org/sage_trac/ticket/2075

-- William

Simon King

unread,
Feb 6, 2008, 6:45:58 AM2/6/08
to sage-support
Dear William

On 6 Feb., 10:55, "William Stein" <wst...@gmail.com> wrote:
<snip>
> sage: R.<x> = QQ[]
> sage: W = R^5; W
> Ambient free module of rank 5 over the principal ideal domain
> Univariate Polynomial Ring in x over Rational Field
<snip>

Good! Thank you! This is the start of what i was looking for. In fact
i am happy with just having free modules, and the method W.hom
provides a construction of homomorphisms.

However, the following questions remain for me:

1. Let f_1 and f_2 be two homomorphisms between free modules. Is there
a method that constructs the tensor product f_1\otimes f_2, or need i
defining it myself?
2. Are there Sage tutorials that i should add to my bookmarks (in
addition to those listed on http://modular.math.washington.edu/sage/doc/html/index.html)?
3. What is a "category" in Sage, and (if it resembles the categories
in "Category Theory") how can it be used?

Best regards
Simon

William Stein

unread,
Feb 6, 2008, 1:12:52 PM2/6/08
to sage-s...@googlegroups.com
On Feb 6, 2008 3:45 AM, Simon King <ki...@mathematik.uni-jena.de> wrote:
>
> Dear William
>
> On 6 Feb., 10:55, "William Stein" <wst...@gmail.com> wrote:
> <snip>
> > sage: R.<x> = QQ[]
> > sage: W = R^5; W
> > Ambient free module of rank 5 over the principal ideal domain
> > Univariate Polynomial Ring in x over Rational Field
> <snip>
>
> Good! Thank you! This is the start of what i was looking for. In fact
> i am happy with just having free modules, and the method W.hom
> provides a construction of homomorphisms.
>
> However, the following questions remain for me:
>
> 1. Let f_1 and f_2 be two homomorphisms between free modules. Is there
> a method that constructs the tensor product f_1\otimes f_2, or need i
> defining it myself?

There is no such method yet. Implement it and send me a patch.

> 2. Are there Sage tutorials that i should add to my bookmarks (in
> addition to those listed on http://modular.math.washington.edu/sage/doc/html/index.html)?

Not well organized. There should be. Get one of your students to write one :-)

> 3. What is a "category" in Sage, and (if it resembles the categories
> in "Category Theory") how can it be used?

A category is to a ring or module (or ?) as a ring or module is to an
element, e.g.,:

sage: V = QQ^5
sage: V
Vector space of dimension 5 over Rational Field
sage: x = V.0
sage: C = V.category()
sage: x in V
True
sage: V in C
True
sage: W = ZZ^5
sage: C(W)
Vector space of dimension 5 over Rational Field

Categories are mainly relevant for constructing homsets and generally
organizing things. They are _not_ used nearly as much as they might
be in Sage, which may or may not be a good thing.

-- William

Reply all
Reply to author
Forward
0 new messages