#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,     |  8045aa4a4b7ada735b3eb6055382f9b341a39f1e
  #10193, #12895, #14516, #14722,    |     Stopgaps:
  #13589, #14471, #15069, #15094,    |
  #11688, #13394, #15150, #15506     |
-------------------------------------+-------------------------------------

Comment (by nbruin):

 Replying to [comment:396 vbraun]:
 >For example the following would make me much happier since it makes the
 dependence visible:
 > {{{
 > sage: class Cs(Category):
 > ....:     def super_categories(self):
 > ....:         return [Sets()]
 > ....:     class Finite_or_any_other_name(Sets.Finite):
 > ....:         class ParentMethods:
 > ....:             def foo(self):
 > ....:                 print "I am a method on finite C's"
 > sage: P = Parent(category=Cs().Finite_or_any_other_name())
 > sage: P.is_finite()     # obviously comes from Sets.Finite
 > }}}
 Ah, I see your issue. I get the feeling that if one would address that
 point
 fully, one would end up with a system so verbose that axioms don't really
 save
 coding any more, which is the motivation of the system in the first place.

 I also don't think the above suggestion expresses the link properly: P
 doesn't
 have the `is_finite` method because its category is `Cs.Finite`, but
 because its
 category is `Cs` together with the `Finite` axiom, `Cs` is a subcategory
 of
 `Sets`, and `Sets` can also have the `Finite` axiom applied to it. This
 kind of
 inheritance is fundamentally richer than what normal class inheritance
 allows
 for, so trying to express it is doomed to fail (otherwise we could have
 used the
 translation!). I am not convinced that we really ''need'' this in sage,
 but the
 author does.

 In fact, the syntax above is perhaps more misleading: By letting
 `Cs.Finite`
 inherit from `Sets.Finite`, you might think that attributes like
 `ParentMethods`
 follow the usual inheritance rules as well. But they shouldn't, because
 `Cs.Finite.ParentMethods` does not contain `is_finite`, so this fails to
 express
 how P gets its `is_finite` attribute completely. By not letting
 `Cs.Finite`
 inherit from `Sets.Finite`, at least we're not suggesting a kind of
 relation
 that doesn't apply.

 > Or, even better, with stand-alone axiom objects either using a
 `@require_axiom(Finite)` decorator or class syntax if you prefer:
 > {{{
 > sage: class Cs(Category):
 > ....:     class Finite_or_any_other_name(axioms.Finite):
 > ....:         class ParentMethods:
 > ....:             def foo(self):
 > ....:                 print "I am a method on finite C's"
 > }}}

 There might be something to that, but if the `or_any_other_name` option
 gets
 excercises, how would you tell efficiently whether `Cs` can have
 `axioms.Finite`
 applied to it? See if there are any attributes that are subtypes of
 axioms.Finite?

 There is precedency in Python for "magic" attribute names. For instance,
 an
 object gets a length by implementing a `__len__` method on it.

 I think the bigger issue is how the supercategories of a category are
 documented, rather than the relations between the axioms on each of them.

 > You could argue that the `ParentMethods` / `ElementMethods` are already
 > precedent for magic attribute names that violate the usual python mental
 model.

 I think the category framework itself violates the usual python mental
 model,
 but that's being advertised as feature, the argument being that the usual
 python
 model isn't expressive enough.

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