#18223: cartesian products with orders
-------------------------------------+-------------------------------------
       Reporter:  dkrenn             |        Owner:
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-6.7
      Component:  categories         |   Resolution:
       Keywords:  sd67               |    Merged in:
        Authors:  Daniel Krenn       |    Reviewers:  Benjamin Hackl
Report Upstream:  N/A                |  Work issues:
         Branch:  u/behackl/cat      |       Commit:
  /cartesian-product-posets          |  0a74ff134169bd9e1fa9d50eb061f69c19fe351e
   Dependencies:  #18586             |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by behackl):

 Thanks for having a look at the code Vincent! I'd like to add some more
 comments as well.

 Replying to [comment:18 vdelecroix]:
 > 1. I think that the class `CartesianProductPosets` would better be
 somewhere in `combinat/posets` rather in `sets/cartesian_product`. It is
 always better to split files.

 Currently, I like the idea that both "types" of cartesian products can be
 found in the same file; I'm not quite sure if it would really be more
 clean to move this code to some other file. In any case, I don't really
 have any arguments for or against moving the code, I'll leave this
 decision to those with more experience.

 > 2. Why is the following not a poset
 > {{{
 > sage: P = Poset((srange(3), lambda left, right: left <= right))
 > sage: cartesian_product([P,P]).category()
 > Category of Cartesian products of finite enumerated sets
 > }}}

 This is the same behavior as we had before; this ticket did not change
 that. However, it probably should.

 My suggestion would be to add the line

 {{{
 CartesianProduct = CartesianProductPosets
 }}}

 to the `ParentMethods`-class in `categories/posets.py`, together with an
 appropriate (lazy) import. If I understood correctly, this would make all
 parents with a subcategory of `Posets()` use the
 `CartesianProductPosets`-class for constructing the cartesian product.

 This change would also suggest using a default argument for the order
 (otherwise, this change is potentially backwards-incompatible)---and as
 Vincent has pointed out in 4., this would be somehow natural.

 > 3. The argument `order` in the class `CartesianProductPosets` is
 mandatory. While the following just works
 > {{{
 > sage: C = cartesian_product([ZZ, ZZ], extra_category=Posets())
 > }}}
 >    actually not
 > {{{
 > sage: TestSuite(C).run()
 > Failure in _test_not_implemented_methods:
 > Traceback (most recent call last):
 > ...
 > AssertionError: Not implemented method: le
 > ------------------------------------------------------------
 > The following tests failed: _test_not_implemented_methods
 > }}}
 >

 As far as I can see, this comes from
 {{{
 return parents[0].CartesianProduct(...)
 }}}
 in the last line of `cartesian_product` in `categories/sets_cat.py`. If
 the category of `parents[0]` isn't a subcategory of `Posets()`, the non-
 poset cartesian product is constructed. In any case, I think it is easy to
 take care of that case.

 I agree completely with 4, 5, 7; and I know too little about
 `_refine_category_` to comment on 6. It seems like a good idea to follow
 #18305 and implement `_richcmp_` in the `Element`-class.

 Finally, I pushed another small commit with some documentation-related
 changes.

 I'd suggest taking care of setting `Parent.CartesianProduct` automatically
 for subcategories of `Posets()`, as well as adapting `cartesian_product`
 such that in case `extra_category` is a subcategory of `Posets()`, the
 class `CartesianProductPosets` is used for the construction of the
 cartesian product.

 Other than that, this would be `positive_review` from my side.

 Benjamin

--
Ticket URL: <http://trac.sagemath.org/ticket/18223#comment:21>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to