#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 tscrim):
It really sounds like what you're after Volker is something like Java's
`enum` type: labels belonging to some collection (which in this case we
can use as flags [ints]). Perhaps we should mimic that with a container
class called `Axioms` which has methods (ideal world would be immutable
attributes which show up in the documentation) for the various axioms
(which we could encode as strings or flgs). I'd almost advocate going a
step further with this in that this also stores what axioms are used. So
it would work something like this:
{{{
sage: F = Fields().with_axiom(Axioms.finite()); F
Finite fields
sage: F.axioms()
Axioms: Finite
}}}
and internally:
{{{#!python
# In Category
def with_axiom(axioms):
self._axioms.add_axioms(axioms)
# The container class
class Axioms(object):
def __init__(self, axioms=[]):
self._axioms = axioms
def __repr__(self):
return "Axioms: {}".format(repr(self._axioms)[1:-1])
def __iadd__(self, axiom):
return self.add_axioms([axiom])
def __isub__(self, axiom):
return self.without_axioms([axiom])
def add_axioms(self, axioms):
# After making sure each axiom is valid
self._axioms += axioms
def without_axioms(self, axioms):
for ax in axioms:
self._axioms.remove(ax)
@staticmethod
def finite():
"""
With this we can document what each axiom means and
it shows up on tab completion.
"""
return "Finite"
@staticmethod
def commutative():
return "Commutative"
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/10963#comment:392>
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.