Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functorial constructions in categories #8881

Closed
hivert opened this issue May 5, 2010 · 17 comments
Closed

Functorial constructions in categories #8881

hivert opened this issue May 5, 2010 · 17 comments

Comments

@hivert
Copy link

hivert commented May 5, 2010

This patch refactors completely the framework for (covariant)
functorial constructions, improves the existing ones, and adds new ones.

Improved constructions:

  • Cartesian products: generalization to non modules_with_basis,
    monoid operations, ...

New constructions:

  • Subquotients, Quotients, Subobjects, IsomorphicObjects
  • DualObjects, Algebras

Miscellaneous category fixes and improvements:

  • is_subcategory now handles properly join categories
    (courtesy of Florent Hivert)
  • For a field K, Modules(K) returns VectorSpaces(K)
  • As a temporary workaround, Parent.an_element calls the
    _an_element_ method provided by the categories, if available
  • Adds a method Category.or_subcategory
  • Cleans up _repr_ by extracting a _repr_object_names method
  • Cleans up _latex_ by extracting a _short_name method

Depend on #9104

CC: @sagetrac-sage-combinat

Component: categories

Keywords: Functorial constructions

Author: Nicolas M. Thiéry

Reviewer: Florent Hivert

Merged: sage-4.4.4.alpha0

Issue created by migration from https://trac.sagemath.org/ticket/8881

@hivert hivert added this to the sage-4.4.4 milestone May 5, 2010
@hivert
Copy link
Author

hivert commented Jun 1, 2010

comment:1

The patch is on review on sage-combinat-queue and should be ready soon. Please Nicolas, can you fold my last review patch if you are ok with it and upload the bunch here. I'll probably put a positive review after a last re-reading (and at least 5 folded review patches) :-)

Florent

@hivert
Copy link
Author

hivert commented Jun 1, 2010

Reviewer: Florent Hivert

@hivert
Copy link
Author

hivert commented Jun 1, 2010

Author: Nicolas M. Thiéry

@nthiery
Copy link
Contributor

nthiery commented Jun 1, 2010

Changed keywords from Functorial construction to Functorial constructions

@nthiery

This comment has been minimized.

@hivert
Copy link
Author

hivert commented Jun 1, 2010

comment:3

Replying to @nthiery:

One last remark, otherwise I'm ready to give positive review: there is a slight naming inconsistency:

  • CartesianProductFunctor, CartesianProducts, CartesianProductsCategory, cartesian_product
  • TensorFunctor, TensorProducts, TensorProductsCategory, tensor

I'm just not 100% sure that we don't want TensorProductFunctor and tensor_product...

Any arguments ?

By the way I put Priority=critical because they are at least a dozen of patch on sage-combinat which depend on this one...

@nthiery
Copy link
Contributor

nthiery commented Jun 2, 2010

Renames TensorFunctor to TensorProductFunctor

@nthiery
Copy link
Contributor

nthiery commented Jun 2, 2010

Attachment: trac_8881-functorial_constructions-nt.patch.gz

Attachment: diff.gz

Diff to previous version of the patch

@nthiery
Copy link
Contributor

nthiery commented Jun 2, 2010

comment:4

Replying to @hivert:

One last remark, otherwise I'm ready to give positive review: there is a slight naming inconsistency:

  • CartesianProductFunctor, CartesianProducts, CartesianProductsCategory, cartesian_product
  • TensorFunctor, TensorProducts, TensorProductsCategory, tensor

I'm just not 100% sure that we don't want TensorProductFunctor and tensor_product...

Any arguments ?

Yup, we had discussed this with David Roe during the review of the
category patches. And we had agreed that tensor([A,B,C]) was
shorter and more practical than tensor_product([A,B,C]), yet
clear and unambiguous. On the other hand cartesian([A,B,C])
wasn't that clear. So we decided to favor here practicality over
consistency.

On the other hand, I fixed TensorFunctor to TensorProductFunctor in
the updated patch.

@hivert
Copy link
Author

hivert commented Jun 2, 2010

comment:5

Excellent ! Positive review unless Massena find a new bug (which is VeryUnlikely(TM)).

@nthiery
Copy link
Contributor

nthiery commented Jun 2, 2010

comment:6

Replying to @hivert:

Excellent ! Positive review unless Massena find a new bug (which is VeryUnlikely(TM)).

Thanks for all your work on this!

@williamstein
Copy link
Contributor

comment:7

This causes doctest failures, including the following.


sage -t  sage/categories/sets_cat.py
**********************************************************************
File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/devel/sage-main/sage/categories/sets_cat.py", line 624:
    sage: A = Monoids().example().algebra(QQ); A
Exception raised:
    Traceback (most recent call last):
      File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_16[4]>", line 1, in <module>
        A = Monoids().example().algebra(QQ); A###line 624:
    sage: A = Monoids().example().algebra(QQ); A
      File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/local/lib/python/site-packages/sage/categories/sets_cat.py", line 637, in algebra
        return CombinatorialFreeModule(base_ring, self, category = category.Algebras(base_ring))
      File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/local/lib/python/site-packages/sage/misc/classcall_metaclass.py", line 256, in __call__
        return cls.__classcall_private__(cls, *args, **options)
      File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/local/lib/python/site-packages/sage/combinat/free_module.py", line 850, in __classcall_private__
        return super(CombinatorialFreeModule, cls).__classcall__(cls, *args, **keywords)
      File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/local/lib/python/site-packages/sage/misc/cachefunc.py", line 115, in __call__
        w = self.f(*args, **kwds)
      File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/local/lib/python/site-packages/sage/structure/unique_representation.py", line 447, in __classcall__
        instance = type.__call__(cls, *args, **options)
      File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/local/lib/python/site-packages/sage/combinat/free_module.py", line 892, in __init__
        element_constructor = self._element_constructor_)
      File "parent.pyx", line 457, in sage.structure.parent.Parent.__init__ (sage/structure/parent.c:3851)
      File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/local/lib/python/site-packages/sage/categories/magmas.py", line 115, in __init_extra__
        if (self.product != self.product_from_element_class_mul) and hasattr(self, "element_class") and hasattr(self.element_class, "_mul_parent"):
      File "element.pyx", line 860, in sage.structure.element.Element.__richcmp__ (sage/structure/element.c:7061)
      File "element.pyx", line 801, in sage.structure.element.Element._richcmp (sage/structure/element.c:6441)
      File "coerce.pyx", line 907, in sage.structure.coerce.CoercionModel_cache_maps.canonical_coercion (sage/structure/coerce.c:8537)
      File "sage_object.pyx", line 101, in sage.structure.sage_object.SageObject.__repr__ (sage/structure/sage_object.c:1370)
      File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/local/lib/python/site-packages/sage/categories/homset.py", line 302, in _repr_
        self._domain, self._codomain, self.__category)
      File "sage_object.pyx", line 101, in sage.structure.sage_object.SageObject.__repr__ (sage/structure/sage_object.c:1370)
      File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/local/lib/python/site-packages/sage/combinat/free_module.py", line 1163, in _repr_
        return self._name + " over %s"%self.base_ring()
      File "parent.pyx", line 676, in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:5239)
      File "parent.pyx", line 263, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:2753)
      File "parent.pyx", line 171, in sage.structure.parent.raise_attribute_error (sage/structure/parent.c:2625)
    AttributeError: 'CombinatorialFreeModule_with_category' object has no attribute '_name'
**********************************************************************
File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/devel/sage-main/sage/categories/sets_cat.py", line 626:
    sage: A.category()
Expected:
    Category of monoid algebras over Rational Field
Got:
    Category of set algebras over Rational Field
**********************************************************************
1 items had failures:
   2 of   8 in __main__.example_16
***Test Failed*** 2 failures.
For whitespace errors, see the file /scratch/wstein/sage//tmp/.doctest_sets_cat.py

@hivert
Copy link
Author

hivert commented Jun 3, 2010

comment:8

Replying to @williamstein:

This causes doctest failures, including the following.

> 
> sage -t  sage/categories/sets_cat.py
> **********************************************************************
> File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/devel/sage-main/sage/categories/sets_cat.py", line 624:
>     sage: A = Monoids().example().algebra(QQ); A
> Exception raised:
. [...]
>     AttributeError: 'CombinatorialFreeModule_with_category' object has no attribute '_name'
> **********************************************************************
> File "/mnt/usb1/scratch/wstein/build/release/4.4.3/sage-4.4.3.alpha2/devel/sage-main/sage/categories/sets_cat.py", line 626:
>     sage: A.category()
> Expected:
>     Category of monoid algebras over Rational Field
> Got:
>     Category of set algebras over Rational Field
> **********************************************************************

This bug is fixed in #9104 but it does appear on 4.4.2 so I didn't think about a dependency. Sorry for this.

@hivert

This comment has been minimized.

@hivert
Copy link
Author

hivert commented Jun 3, 2010

comment:9

Note: I put back positive review though I had no chance to test on sage-4.4.3.alpha2...

@hivert
Copy link
Author

hivert commented Jun 3, 2010

comment:10

Replying to @hivert:

This bug is fixed in #9104 but it does appear on 4.4.2 so I didn't think about a dependency. Sorry for this.

Actually it did (see the note there), but I completely forgot about it. My mistake.

@mwhansen
Copy link
Contributor

mwhansen commented Jun 5, 2010

Merged: sage-4.4.4.alpha0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants