#10963: More functorial constructions
-------------------------------------+-------------------------------------
       Reporter:  nthiery            |        Owner:  stumpc5
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.1
      Component:  categories         |   Resolution:
       Keywords:  days54             |    Merged in:
        Authors:  Nicolas M. Thiéry  |    Reviewers:  Simon King, Frédéric
Report Upstream:  N/A                |  Chapoton
         Branch:                     |  Work issues:
  public/ticket/10963                |       Commit:
   Dependencies:  #11224, #8327,     |  eb7b486c6fecac296052f980788e15e2ad1b59e4
  #10193, #12895, #14516, #14722,    |     Stopgaps:
  #13589, #14471, #15069, #15094,    |
  #11688, #13394, #15150, #15506     |
-------------------------------------+-------------------------------------

Comment (by SimonKing):

 Replying to [comment:456 vbraun]:
 > I agree with Simon's explanations. And it illustrates the point that I'm
 trying to make,

 Hence, you agree with my explanations, but not with my conclusions (namely
 that the example demonstrates that only the theorem needs to be
 implemented, but not its implications, and that implementing the theorem
 is fairly straightforward after learning the rules).

 > if you show the code to a Python programmer then he'll be quite
 astonished that it does what it does since it seemingly consists only of
 all a pile of apparently unrelated inner classes.

 What would the same programmer say about the abc module?

 > The question about unnecessary breaking of symmetry already arises at
 > {{{
 > class As(Category_singleton):
 >     class B(CategoryWithAxiom):
 >         class C(CategoryWithAxiom):
 >             pass
 > }}}
 > why As.B.C and not As.C.B?

 I said that it only seemed unnecessary to me ''at first''! And after all,
 the necessity to choose a spanning tree makes it fairly obvious that one
 has to make choices at some point.

 And a more symmetric solution is possible, too:
 {{{
 #!python
 from sage.misc.lazy_attribute import lazy_class_attribute

 class CBAs(CategoryWithAxiom):
     @lazy_class_attribute
     def _base_category_class_and_axiom(cls):
         return(As.B, "C")

 class As(Category_singleton):
     def super_categories(self):
         return [Bases()]

     class B(CategoryWithAxiom):
         C = CBAs

     class C(CategoryWithAxiom):
         pass

     class E(CategoryWithAxiom):
         pass

     class F(CategoryWithAxiom):
         pass

     class D(CategoryWithAxiom):
         pass
 }}}

 The only asymmetry is the choice of a spanning tree, as defined by
 `_base_category_class_and_axiom` and the corresponding thing to do at the
 starting point of the arrow that belongs to the spanning tree.

 And it still works:
 {{{
 sage: As().B().C() is As().C().B()
 True
 sage: As().B().C()
 Category of c b as
 sage: type(_)
 <class '__main__.CBAs_with_category'>
 }}}

 So, there is an asymmetry, but it is necessary.

 > The only "error message" if you get the asymmetry wrong will be an
 infinite recursion.

 Yes, and this is unfortunate.

--
Ticket URL: <http://trac.sagemath.org/ticket/10963#comment:457>
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/groups/opt_out.

Reply via email to