Declaring a parent in a category as a finite enumerated set

135 views
Skip to first unread message

Kwankyu Lee

unread,
Aug 23, 2016, 4:43:33 AM8/23/16
to sage-devel
I am not familiar with the category framework. My questions are

(1) I want certain parents in a category C to be also in the category of finite enumerated sets such that I can use .list() method. Not all objects in the category C is not finite. What is the standard way to implement that?

(2) All objects in a category D are finite, and I want .list() method usable for all the objects(parents). What is the standard way to implement that?

Please give me some guides. Thank you!

Vincent Delecroix

unread,
Aug 23, 2016, 10:11:26 AM8/23/16
to sage-...@googlegroups.com
For example, have a look at sage/combinat/free_module.py lines 1170-1175.

Kwankyu Lee

unread,
Aug 23, 2016, 10:42:25 AM8/23/16
to sage-devel
For example, have a look at sage/combinat/free_module.py lines 1170-1175.

Are you referring specifically the construct ".FiniteDimensional()" to get a subcategory? Then can I use ".FiniteEnumerable()" for my case? I guess not... On the other hand, in other examples, I see ".Finite()" give a finite set, but I want the category of finite enumerable set...

Kwankyu Lee

unread,
Aug 23, 2016, 10:48:22 AM8/23/16
to sage-devel
For (1): Joining categories works. However, this seems not a standard nor an elegant way... 

Vincent Delecroix

unread,
Aug 23, 2016, 10:49:20 AM8/23/16
to sage-...@googlegroups.com
Yes. In your case it will be one of .Finite() or .Finite().Enumerated()
or .Enumerated()

Kwankyu Lee

unread,
Aug 23, 2016, 10:59:05 AM8/23/16
to sage-devel
Yes. In your case it will be one of .Finite() or .Finite().Enumerated()
or .Enumerated()

Hmm. I get

{{{

sage: m=FreeModule(GF(2),2)

sage: c=m.category()

sage: c.Finite()

Category of finite finite dimensional vector spaces with basis over (finite fields and subquotients of monoids and quotients of semigroups)

sage: c.Enumerated()

---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

<ipython-input-35-aa8dfe4741d2> in <module>()

----> 1 c.Enumerated()


AttributeError: 'JoinCategory_with_category' object has no attribute 'Enumerated'

sage: c.Finite().Enumerated()

---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

<ipython-input-36-37828baa94f6> in <module>()

----> 1 c.Finite().Enumerated()


AttributeError: 'JoinCategory_with_category' object has no attribute 'Enumerated'

sage: 
}}} 

Kwankyu Lee

unread,
Aug 23, 2016, 11:01:31 AM8/23/16
to sage-devel
This is about so-called categories with axioms. Right? I think ".Finite().Enumerated()" is a nice construct. But this seems not implemented yet... Am I right?

Vincent Delecroix

unread,
Aug 23, 2016, 12:20:11 PM8/23/16
to sage-...@googlegroups.com
You are right, must be a join with EnumeratedSet (Finite is an axiom but
enumerated is not).

On 23/08/16 11:59, Kwankyu Lee wrote:
>
>>
>> Yes. In your case it will be one of .Finite() or .Finite().Enumerated()
>> or .Enumerated()
>
>
> Hmm. I get
>
> {{{
>
> sage: m=FreeModule(GF(*2*),*2*)

Nicolas M. Thiery

unread,
Aug 23, 2016, 12:20:34 PM8/23/16
to sage-...@googlegroups.com
This does not work because "Enumerated" is not an axiom (maybe it
should be; there are pros and cons). Anyway if you have a category,
and want to build the subcategory of objects that are also enumerated
(and possibly finite), you can do:

sage: C = Groups(); C
Category of groups

sage: D = C & EnumeratedSets()
Join of Category of groups and Category of enumerated sets

sage: D.Finite()
Join of Category of finite groups and Category of finite enumerated sets

Cheers,
Nicolas
--
Nicolas M. Thiéry "Isil" <nth...@users.sf.net>
http://Nicolas.Thiery.name/

Simon King

unread,
Aug 23, 2016, 12:49:19 PM8/23/16
to sage-...@googlegroups.com
Hi Kwankyu,

On 2016-08-23, Kwankyu Lee <ekwa...@gmail.com> wrote:
> For (1): Joining categories works. However, this seems not a standard nor
> an elegant way...

Why not? It is absolutely standard in mathematics to consider objects A
that belong to the category of rings and belong at the same time to the
category of modules over a ring R.

Cheers,
Simon

Kwankyu Lee

unread,
Aug 23, 2016, 3:38:35 PM8/23/16
to sage-devel
Right. Perhaps I was just thinking of "cosmetics". Lots of parents in Sage should be finite enumerated sets. If their category is a join of some category X and the category of finite enumerated sets, then it is printed as

Join of some category X and the category of finite enumerated sets.

I thought this is not "elegant"..., perhaps just a personal feeling.

Nicolas M. Thiery

unread,
Aug 26, 2016, 4:59:26 AM8/26/16
to sage-...@googlegroups.com
Yeah, I agree, that's not elegant. I would say that's about how join
categories though are output, rather than whether or not we want the
category to be a join in this case.

Output of join categories definitely could use some love. A first
improvement could be to use:

Category of X an enumerated sets.

should be trivial to implement, but will require updating doctests in
many places. Then, maybe we could devise further heuristics /
customization hooks to get better names.

Kwankyu Lee

unread,
Aug 26, 2016, 12:46:40 PM8/26/16
to sage-devel, Nicolas...@u-psud.fr
Output of join categories definitely could use some love.

:-)
 
A first improvement could be to use:

        Category of X an enumerated sets.

Alternatively:

Category of  enumerable X
 
should be trivial to implement.

Good news. But I have to study more of the internals of the category system to see it such...

Nicolas M. Thiery

unread,
Aug 28, 2016, 11:26:44 AM8/28/16
to sage-...@googlegroups.com
On Fri, Aug 26, 2016 at 09:46:40AM -0700, Kwankyu Lee wrote:
> A first improvement could be to use:
> Category of X an enumerated sets.

Oops, I just noticed a typo which may have been confusing. I really
meant:

Category of X and enumerated sets.

It's easy to implement, because it's just about changing the _repr_
method of join categories.

> Alternatively:
> Category of enumerable X

This one would be harder to implement (no different from the more
natural "Category of enumerated X"), as we would need to do something
specific for joins with an enumerated set.

Simon King

unread,
Aug 28, 2016, 1:09:33 PM8/28/16
to sage-...@googlegroups.com
Hi Nicolas,

On 2016-08-28, Nicolas M. Thiery <Nicolas...@u-psud.fr> wrote:
>> Alternatively:
>> Category of enumerable X
>
> This one would be harder to implement (no different from the more
> natural "Category of enumerated X"), as we would need to do something
> specific for joins with an enumerated set.

If a category "knows" that it is implementing an axiom, then it should
also know an adjective that decribes its axiom, and the _repr_ method of
join categories could (I guess) relatively easily detect which of its
axioms apply to what other categories, avoiding repititions. Hence, if
you join the category of rings and the category of modules and apply
"enumerated" and "commutative" axioms, the result would print as
"join of category of enumerated modules and commutative rings" or so.

But that's bike shedding, after all...
Cheers,
Simon

Kwankyu Lee

unread,
Aug 31, 2016, 7:47:32 PM8/31/16
to sage-devel, Nicolas...@u-psud.fr
I am playing with an experimental implementation of "enumerated" axiom. The results are interesting.

sage -t src/sage/combinat/posets/posets.py
**********************************************************************
File "src/sage/combinat/posets/posets.py", line 755, in sage.combinat.posets.posets.FinitePoset
Failed example:
    P.category()
Expected:
    Join of Category of finite posets and Category of finite enumerated sets
Got:
    Category of finite enumerated posets
**********************************************************************
File "src/sage/combinat/posets/posets.py", line 776, in sage.combinat.posets.posets.FinitePoset
Failed example:
    P.category()
Expected:
    Join of Category of finite posets and Category of finite enumerated sets
Got:
    Category of finite enumerated posets
**********************************************************************
File "src/sage/combinat/posets/posets.py", line 782, in sage.combinat.posets.posets.FinitePoset
Failed example:
    Q.category()
Expected:
    Join of Category of finite posets
        and Category of finite enumerated sets
        and Category of facade sets
Got:
    Category of facade finite enumerated posets
**********************************************************************
File "src/sage/combinat/posets/posets.py", line 793, in sage.combinat.posets.posets.FinitePoset
Failed example:
    PQ.category()
Expected:
    Join of Category of finite posets
        and Category of finite enumerated sets
        and Category of facade sets
Got:
    Category of facade finite enumerated posets
**********************************************************************
File "src/sage/combinat/posets/posets.py", line 805, in sage.combinat.posets.posets.FinitePoset
Failed example:
    QP.category()
Expected:
    Join of Category of finite posets
        and Category of finite enumerated sets
Got:
    Category of finite enumerated posets

These seem rather nice :-) On the other hand, 

sage -t src/sage/categories/division_rings.py
**********************************************************************
File "src/sage/categories/division_rings.py", line 81, in sage.categories.division_rings.DivisionRings.Finite_extra_super_categories
Failed example:
    DivisionRings().Finite()
Expected:
    Category of finite fields
Got:
    Category of finite enumerated fields

This is rather ugly. I guess that  this is caused partially by that the "finite" axiom does not imply "enumerated" axiom, which is legitimate. Do you think "enumerated" axiom should be in Sage or not?

Kwankyu Lee

unread,
Aug 31, 2016, 7:59:46 PM8/31/16
to sage-devel, Nicolas...@u-psud.fr
One more nice example.

sage -t src/sage/combinat/integer_vector_weighted.py
**********************************************************************
File "src/sage/combinat/integer_vector_weighted.py", line 125, in sage.combinat.integer_vector_weighted.WeightedIntegerVectors_all.__init__
Failed example:
    C.category()
Expected:
    Join of Category of sets with grading and Category of infinite enumerated sets
Got:
    Category of infinite enumerated sets with grading

Daniel Krenn

unread,
Sep 1, 2016, 10:53:00 AM9/1/16
to sage-...@googlegroups.com
On 2016-09-01 01:47, Kwankyu Lee wrote:
> I am playing with an experimental implementation of "enumerated" axiom.

From what I guess is, that this axiom implies an implementation of
__getitem__, correct?
Does it also imply something on the index set (e.g. natural numbers) of
this object? Or does it only mean an enumeration is possible by some
index set?

> Category of finite enumerated fields
>
> This is rather ugly. I guess that this is caused partially by that the
> "finite" axiom does not imply "enumerated" axiom

Side-question: Would it be SageMath-technically possible that one axiom
implies another?

> which is legitimate.

Why? (I understand the following: From a mathematical point of view,
there is no need to print the "enumerated" when already a "finite" is
there. From a more technical point of view, "finite" does not mean
SageMath provides a way to enumerate it, i.e., that __getitem__ is
implemented)


Kwankyu Lee

unread,
Sep 1, 2016, 5:15:52 PM9/1/16
to sage-devel
On Thursday, September 1, 2016 at 4:53:00 PM UTC+2, Daniel Krenn wrote:
On 2016-09-01 01:47, Kwankyu Lee wrote:
> I am playing with an experimental implementation of "enumerated" axiom.

From what I guess is, that this axiom implies an implementation of
__getitem__, correct?

If you see the code for the enumerated sets category, it means that the object in the category is iterable and has ".list()" method basically. 
 
Does it also imply something on the index set (e.g. natural numbers) of
this object? Or does it only mean an enumeration is possible by some
index set?

You know what it means mathematically (indexed by a countable set). Technically it means what I said above.
 
> This is rather ugly. I guess that  this is caused partially by that the
> "finite" axiom does not imply "enumerated" axiom

Side-question: Would it be SageMath-technically possible that one axiom
implies another?

I don't think so, but I am not sure about this. I just meant that in Sage, the finite sets category and the enumerated sets category are two distinct categories and that none of them is a subcategory of the other. I think that all this is reasonable.
 
> which is legitimate.

Why? (I understand the following: From a mathematical point of view,
there is no need to print the "enumerated" when already a "finite" is
there. From a more technical point of view, "finite" does not mean
SageMath provides a way to enumerate it, i.e., that __getitem__ is
implemented)

It is legitimate from the technical point of view as you said. In Sage, "finite" and "finite enumerated"  are distinct. If a category is of finite enumerated sets, then the objects in the category has ".list()" method while if it is only of finite sets, then not.

On the other hand, some may prefer that "finite enumerated" is just printed as "finite" from esthetic point of view. So for example, a finite field belongs to the "Category of finite fields" rather than "Category of finite enumerated fields". I am inclined to living with "finite enumerated fields" :-) 

I now think we should have "enumerated" axiom in Sage. But I want to hear opinions of Sage-category experts.

Simon King

unread,
Sep 2, 2016, 9:27:46 AM9/2/16
to sage-...@googlegroups.com
Hi!

On 2016-09-01, Kwankyu Lee <ekwa...@gmail.com> wrote:
>> Side-question: Would it be SageMath-technically possible that one axiom
>> implies another?

I think so. For example, if you combine the axioms of a division ring
with the "finite" axiom, it implies the "commutative"-axiom:

sage: DivisionRings().Commutative()
Category of fields

Cheers,
Simon

Reply all
Reply to author
Forward
0 new messages