Ticket #8800: some_ideas.patch

File some_ideas.patch, 32.0 KB (added by lftabera, 10 years ago)

Ideas to consider merging

  • doc/en/reference/categories.rst

    # HG changeset patch
    # Parent 74c911071a9a7ea5e77000bc00f3de2a9f0fdb07
    
    diff -r 74c911071a9a doc/en/reference/categories.rst
    a b  
    1313   sage/categories/homset
    1414   sage/categories/morphism
    1515   sage/categories/functor
     16   sage/categories/pushout
    1617
    1718Functorial constructions
    1819========================
  • sage/categories/functor.pyx

    diff -r 74c911071a9a sage/categories/functor.pyx
    a b  
    118118    result is a homomorphism that is defined on the base ring::
    119119
    120120        sage: F = QQ['t'].construction()[0]
     121        sage: F
     122        Poly[t]
    121123        sage: F(f)
    122124        Ring morphism:
    123125          From: Univariate Polynomial Ring in t over Univariate Polynomial Ring in x over Integer Ring
     
    155157       
    156158    def _apply_functor(self, x):
    157159        """
    158         Apply the functor to an object of ``self``'s domain
     160        Apply the functor to an object of ``self``'s domain.
    159161
    160162        NOTE:
    161163
     
    175177
    176178    def _apply_functor_to_morphism(self, f):
    177179        """
    178         Apply the functor to a morphism between two objects of ``self``'s domain
     180        Apply the functor to a morphism between two objects of ``self``'s domain.
    179181
    180182        NOTE:
    181183
     
    210212
    211213    def _coerce_into_domain(self, x):
    212214        """
    213         Interprete the argument as an object of self's domain
     215        Interprete the argument as an object of self's domain.
    214216
    215217        NOTE:
    216218
     
    232234            ...
    233235            TypeError: x (=Integer Ring) is not in Category of fields
    234236
    235        
    236237        """
    237238        if not (x in  self.__domain):
    238239            raise TypeError, "x (=%s) is not in %s"%(x, self.__domain)
     
    474475        ...
    475476        TypeError: x (=Integer Ring) is not in Category of fields
    476477
     478    TESTS::
     479
     480        sage: R = IdentityFunctor(Rings())
     481        sage: P, _ = QQ['t'].construction()
     482        sage: R == P
     483        False
     484        sage: P == R
     485        False
     486        sage: R == QQ
     487        False
    477488    """
    478489    def __init__(self, C):
    479490        """
     
    514525   
    515526    def _apply_functor(self, x):
    516527        """
     528        Apply the functor to an object of ``self``'s domain.
     529       
    517530        TESTS::
    518531
    519532            sage: fields = Fields()
  • sage/categories/pushout.py

    diff -r 74c911071a9a sage/categories/pushout.py
    a b  
    77
    88class ConstructionFunctor(Functor):
    99    """
    10     Base class for construction functors
     10    Base class for construction functors.
    1111
    1212    A construction functor is a functorial algebraic construction,
    1313    such as the construction of a matrix ring over a given ring
     
    3030
    3131    ::
    3232
    33         sage: F1,R = QQ.construction()
     33        sage: F1, R = QQ.construction()
    3434        sage: F1
    3535        FractionField
    3636        sage: R
    3737        Integer Ring
    38         sage: F2,R = (ZZ['x']).construction()
     38        sage: F2, R = (ZZ['x']).construction()
    3939        sage: F2
    4040        Poly[x]
    4141        sage: R
     
    5353        Univariate Polynomial Ring in x over Rational Field
    5454
    5555    When composing two construction functors, they are sometimes
    56     merged into one, as is the case in the Quotient construction.
    57 
    58     ::
    59 
    60         sage: Q15,R = (ZZ.quo(15*ZZ)).construction()
     56    merged into one, as is the case in the Quotient construction::
     57
     58        sage: Q15, R = (ZZ.quo(15*ZZ)).construction()
    6159        sage: Q15
    6260        QuotientFunctor
    63         sage: Q35,R = (ZZ.quo(35*ZZ)).construction()
     61        sage: Q35, R = (ZZ.quo(35*ZZ)).construction()
    6462        sage: Q35
    6563        QuotientFunctor
    6664        sage: Q15.merge(Q35)
     
    125123       
    126124    def pushout(self, other):
    127125        """
    128         Return the composition of two construction functors, in an order given by their ranks
     126        Return the composition of two construction functors, in an order given by their ranks.
    129127
    130128        NOTE:
    131129       
    132         - This method seems not to be used in the coercion model
    133         - By default, the functor with smaller rank is applied first
     130        - This method seems not to be used in the coercion model.
     131        - By default, the functor with smaller rank is applied first.
    134132
    135133        TESTS::
    136134
     
    173171        NOTE:
    174172
    175173        By default, it returns the name of the construction functor's class.
    176         Usually, this method will be overloaded
     174        Usually, this method will be overloaded.
    177175
    178176        TEST::
    179177
     
    194192        NOTE:
    195193
    196194        By default, it returns the name of the construction functor's class.
    197         Usually, this method will be overloaded
     195        Usually, this method will be overloaded.
    198196
    199197        TEST::
    200198
     
    210208       
    211209    def merge(self, other):
    212210        """
    213         Merge ``self`` with another construction functor, or return None
     211        Merge ``self`` with another construction functor, or return None.
    214212
    215213        NOTE:
    216214
     
    236234           
    237235    def commutes(self, other):
    238236        """
    239         Determine whether ``self`` commutes with another construction functor
     237        Determine whether ``self`` commutes with another construction functor.
    240238
    241239        NOTE:
    242240
     
    262260
    263261    def expand(self):
    264262        """
    265         Decompose ``self`` into a list of construction functors
     263        Decompose ``self`` into a list of construction functors.
    266264
    267265        NOTE:
    268266
     
    276274            sage: Q = ZZ.quo(2).construction()[0]
    277275            sage: Q.expand()
    278276            [QuotientFunctor]
     277            sage: P = ZZ['t'].construction()[0]
     278            sage: FP = F*P
     279            sage: FP.expand()
     280            [FractionField, Poly[t]]
    279281
    280282        """
    281283        return [self]
     
    283285       
    284286class CompositeConstructionFunctor(ConstructionFunctor):
    285287    """
    286     A Construction Functor composed by other Construction Functors
     288    A Construction Functor composed by other Construction Functors.
    287289
    288290    INPUT:
    289291
    290     ``F1,F2,...``: A list of Construction Functors. The result is the
     292    ``F1, F2,...``: A list of Construction Functors. The result is the
    291293    composition ``F1`` followed by ``F2`` followed by ...
    292294
    293295    EXAMPLES::
     
    329331
    330332    def _apply_functor_to_morphism(self, f):
    331333        """
     334        Apply the functor to an object of ``self``'s domain.
     335       
    332336        TESTS::
    333337
    334338            sage: from sage.categories.pushout import CompositeConstructionFunctor
     
    353357
    354358    def _apply_functor(self, R):
    355359        """
     360        Apply the functor to an object of ``self``'s domain.
     361       
    356362        TESTS::
    357363       
    358364            sage: from sage.categories.pushout import CompositeConstructionFunctor
     
    383389           
    384390    def __mul__(self, other):
    385391        """
    386         Convention: ``(F1*F2)(X) == F1(F2(X))``.
     392        Compose construction functors to a composit construction functor, unless one of them is the identity.
     393
     394        NOTE:
     395
     396        The product is in functorial notation, i.e., when applying the product to an object
     397        then the second factor is applied first.
    387398
    388399        EXAMPLES::
    389400
     
    441452       
    442453class IdentityConstructionFunctor(ConstructionFunctor):
    443454    """
    444     A construction functor that is the identity functor
     455    A construction functor that is the identity functor.
    445456
    446457    TESTS::
    447458
     
    471482
    472483    def _apply_functor(self, x):
    473484        """
    474         Return the argument unaltered
     485        Return the argument unaltered.
    475486       
    476487        TESTS::
    477488
     
    484495
    485496    def _apply_functor_to_morphism(self, f):
    486497        """
    487         Return the argument unaltered
     498        Return the argument unaltered.
    488499       
    489500        TESTS::
    490501
     
    517528
    518529    def __mul__(self, other):
    519530        """
     531        Compose construction functors to a composit construction functor, unless one of them is the identity.
     532
     533        NOTE:
     534
     535        The product is in functorial notation, i.e., when applying the product to an object
     536        then the second factor is applied first.
     537
    520538        TESTS::
    521539
    522540            sage: from sage.categories.pushout import IdentityConstructionFunctor
     
    541559
    542560class PolynomialFunctor(ConstructionFunctor):
    543561    """
    544     Construction functor for univariate polynomial rings
     562    Construction functor for univariate polynomial rings.
    545563
    546564    EXAMPLE:
    547565
     
    584602
    585603    def _apply_functor(self, R):
    586604        """
     605        Apply the functor to an object of ``self``'s domain.
     606       
    587607        TEST::
    588608
    589609            sage: P = ZZ['x'].construction()[0]
     
    622642
    623643    def merge(self, other):
    624644        """
     645        Merge ``self`` with another construction functor, or return None.
     646       
    625647        NOTE:
    626648
    627649        Internally, the merging is delegated to the merging of
     
    700722
    701723    def _apply_functor(self, R):
    702724        """
     725        Apply the functor to an object of ``self``'s domain.
     726       
    703727        EXAMPLES::
    704728       
    705729            sage: R.<x,y,z> = QQ[]
     
    764788
    765789    def merge(self, other):
    766790        """
     791        Merge ``self`` with another construction functor, or return None.
     792       
    767793        EXAMPLES::
    768794       
    769795            sage: F = sage.categories.pushout.MultiPolynomialFunctor(['x','y'], None)
     
    780806
    781807    def expand(self):
    782808        """
     809        Decompose ``self`` into a list of construction functors.
     810       
    783811        EXAMPLES::
    784812       
    785813            sage: F = QQ['x,y,z,t'].construction()[0]; F
     
    823851
    824852class InfinitePolynomialFunctor(ConstructionFunctor):
    825853    """
    826     A Construction Functor for Infinite Polynomial Rings (see :mod:`~sage.rings.polynomial.infinite_polynomial_ring`)
     854    A Construction Functor for Infinite Polynomial Rings (see :mod:`~sage.rings.polynomial.infinite_polynomial_ring`).
    827855   
    828856    AUTHOR:
    829857
     
    881909        CoercionException: Overlapping variables (('a', 'b'),['a_3', 'a_1']) are incompatible
    882910
    883911    Since the construction functors are actually used to construct infinite polynomial rings, the following
    884     result is no surprise:
     912    result is no surprise::
    885913
    886914        sage: C.<a,b> = InfinitePolynomialRing(B); C
    887915        Infinite polynomial ring in a, b over Multivariate Polynomial Ring in x, y over Rational Field
     
    893921
    894922    `X` and `Y` have an overlapping generators `x_\\ast, y_\\ast`. Since the default lexicographic order is
    895923    used in both rings, it gives rise to isomorphic sub-monoids in both `X` and `Y`. They are merged in the
    896     pushout, which also yields a common parent for doing arithmetic.
     924    pushout, which also yields a common parent for doing arithmetic::
    897925
    898926        sage: P = sage.categories.pushout.pushout(Y,X); P
    899927        Infinite polynomial ring in w, x, y, z over Rational Field
     
    946974
    947975    def _apply_functor(self, R):
    948976        """
     977        Apply the functor to an object of ``self``'s domain.
     978       
    949979        TEST::
    950980
    951981            sage: F = sage.categories.pushout.InfinitePolynomialFunctor(['a','b','x'],'degrevlex','sparse'); F
     
    9861016
    9871017    def __mul__(self, other):
    9881018        """
     1019        Compose construction functors to a composit construction functor, unless one of them is the identity.
     1020
     1021        NOTE:
     1022
     1023        The product is in functorial notation, i.e., when applying the product to an object
     1024        then the second factor is applied first.
     1025
    9891026        TESTS::
    9901027
    9911028            sage: F1 = QQ['a','x_2','x_1','y_3','y_2'].construction()[0]; F1
     
    11421179
    11431180    def expand(self):
    11441181        """
    1145         Decompose the functor `F` into sub-functors, whose product returns `F`
     1182        Decompose the functor `F` into sub-functors, whose product returns `F`.
    11461183
    11471184        EXAMPLES::
    11481185
     
    11681205
    11691206class MatrixFunctor(ConstructionFunctor):
    11701207    """
    1171     A construction functor for matrices over rings
     1208    A construction functor for matrices over rings.
    11721209
    11731210    EXAMPLES::
    11741211
    1175         sage: MS = MatrixSpace(ZZ,2)
     1212        sage: MS = MatrixSpace(ZZ,2, 3)
    11761213        sage: F = MS.construction()[0]; F
    11771214        MatrixFunctor
    11781215        sage: MS = MatrixSpace(ZZ,2)
     
    12051242            True
    12061243            sage: F.codomain()
    12071244            Category of commutative additive groups
    1208             sage: MatrixSpace(ZZ,2,2).construction()[0].codomain()
     1245            sage: R = MatrixSpace(ZZ,2,2).construction()[0]
     1246            sage: R.codomain()
    12091247            Category of rings
    1210 
     1248            sage: F(ZZ)
     1249            Full MatrixSpace of 2 by 3 dense matrices over Integer Ring
     1250            sage: F(ZZ) in F.codomain()
     1251            True
     1252            sage: R(GF(2))
     1253            Full MatrixSpace of 2 by 2 dense matrices over Finite Field of size 2
     1254            sage: R(GF(2)) in R.codomain()
     1255            True
    12111256        """
    12121257        if nrows == ncols:
    12131258            Functor.__init__(self, Rings(), Rings()) # Algebras() takes a base ring
     
    12171262        self.nrows = nrows
    12181263        self.ncols = ncols
    12191264        self.is_sparse = is_sparse
     1265
    12201266    def _apply_functor(self, R):
    12211267        """
     1268        Apply the functor to an object of ``self``'s domain.
     1269       
    12221270        TEST:
    12231271
    12241272        The following is a test against a bug discussed at ticket #8800
     
    12321280        """
    12331281        from sage.matrix.matrix_space import MatrixSpace
    12341282        return MatrixSpace(R, self.nrows, self.ncols, sparse=self.is_sparse)
     1283
    12351284    def __cmp__(self, other):
    12361285        """
    12371286        TEST::
     
    12471296        if c == 0:
    12481297            c = cmp((self.nrows, self.ncols), (other.nrows, other.ncols))
    12491298        return c
     1299
    12501300    def merge(self, other):
    12511301        """
    12521302        Merging is only happening if both functors are matrix functors of the same dimension.
     
    12781328
    12791329class LaurentPolynomialFunctor(ConstructionFunctor):
    12801330    """
    1281     Construction functor for Laurent polynomial rings
     1331    Construction functor for Laurent polynomial rings.
    12821332
    12831333    EXAMPLES::
    12841334
     
    13321382        if not isinstance(var, (basestring,tuple,list)):
    13331383            raise TypeError, "variable name or list of variable names expected"
    13341384        self.var = var
    1335         self.multi_variate = multi_variate or not isinstance(var,basestring)
     1385        self.multi_variate = multi_variate or not isinstance(var, basestring)
     1386
    13361387    def _apply_functor(self, R):
    13371388        """
     1389        Apply the functor to an object of ``self``'s domain.
     1390       
    13381391        TESTS::
    13391392
    13401393            sage: from sage.categories.pushout import LaurentPolynomialFunctor
     
    13551408        else:
    13561409            from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
    13571410            return LaurentPolynomialRing(R, self.var)
     1411
    13581412    def __cmp__(self, other):
    13591413        """
    13601414        TESTS::
     
    13771431        if c == 0:
    13781432            c = cmp(self.var, other.var)
    13791433        return c
     1434
    13801435    def merge(self, other):
    13811436        """
    13821437        Two Laurent polynomial construction functors merge if the variable names coincide.
     
    14031458       
    14041459class VectorFunctor(ConstructionFunctor):
    14051460    """
    1406     A construction functor for free modules over commutative rings
     1461    A construction functor for free modules over commutative rings.
    14071462
    14081463    EXAMPLE::
    14091464
     
    14221477        """
    14231478        INPUT:
    14241479
    1425         - ``n``, the rank of the to-be-created modules (non-neg. integer)
     1480        - ``n``, the rank of the to-be-created modules (non-negative integer)
    14261481        - ``is_sparse`` (optional bool, default ``False``), create sparse implementation of modules
    14271482        - ``inner_product_matrix``: ``n`` by ``n`` matrix, used to compute inner products in the
    14281483          to-be-created modules
     
    14311486
    14321487            sage: from sage.categories.pushout import VectorFunctor
    14331488            sage: F1 = VectorFunctor(3, inner_product_matrix = Matrix(3,3,range(9)))
     1489            sage: F1.domain()
     1490            Category of commutative rings
     1491            sage: F1.codomain()
     1492            Category of commutative additive groups
    14341493            sage: M1 = F1(ZZ)
    14351494            sage: M1.is_sparse()
    14361495            False
     
    14521511        self.n = n
    14531512        self.is_sparse = is_sparse
    14541513        self.inner_product_matrix = inner_product_matrix
     1514
    14551515    def _apply_functor(self, R):
    14561516        """
     1517        Apply the functor to an object of ``self``'s domain.
     1518       
    14571519        TESTS::
    14581520
    14591521            sage: from sage.categories.pushout import VectorFunctor
     
    14771539        """
    14781540        from sage.modules.free_module import FreeModule
    14791541        return FreeModule(R, self.n, sparse=self.is_sparse, inner_product_matrix=self.inner_product_matrix)
     1542
    14801543    def _apply_functor_to_morphism(self, f):
    14811544        """
    14821545        This is not implemented yet.
     
    14931556        """
    14941557        ## TODO: Implement this!
    14951558        raise NotImplementedError, "Can not create induced morphisms of free modules yet"
     1559
    14961560    def __cmp__(self, other):
    14971561        """
    1498         Only the rank of the to-be-created modules is compared, *not* the inner product matrix
     1562        Only the rank of the to-be-created modules is compared, *not* the inner product matrix.
    14991563
    15001564        TESTS::
    15011565
     
    15151579        if c == 0:
    15161580            c = cmp(self.n, other.n)
    15171581        return c
     1582
    15181583    def merge(self, other):
    15191584        """
    15201585        Two constructors of free modules merge, if the module ranks coincide. If both
    1521         have explicitly given inner product matrices, they must coincide as well
     1586        have explicitly given inner product matrices, they must coincide as well.
    15221587
    15231588        EXAMPLE:
    15241589
     
    15791644        else:
    15801645            return VectorFunctor(self.n, self.is_sparse and other.is_sparse, self.inner_product_matrix)
    15811646
    1582 
    15831647class SubspaceFunctor(ConstructionFunctor):
    15841648    """
    15851649    Constructing a subspace of an ambient free module, given by a basis.
     
    16061670
    16071671    """
    16081672    rank = 11 # ranking of functor, not rank of module
     1673
    16091674    def __init__(self, basis):
    16101675        """
    16111676        INPUT:
    16121677
    1613         ``basis``: a list of elements of a free module
     1678        ``basis``: a list of elements of a free module.
    16141679
    16151680        TEST::
    16161681
     
    16301695        ## contains in- and output
    16311696        Functor.__init__(self, CommutativeAdditiveGroups(), CommutativeAdditiveGroups())
    16321697        self.basis = basis
     1698
    16331699    def _apply_functor(self, ambient):
    16341700        """
     1701        Apply the functor to an object of ``self``'s domain.
     1702       
    16351703        TESTS::
    16361704
    16371705            sage: M = ZZ^3
     
    16481716            [0 1 0]
    16491717        """
    16501718        return ambient.span_of_basis(self.basis)
     1719
    16511720    def _apply_functor_to_morphism(self, f):
    16521721        """
    16531722        This is not implemented yet.
     
    16631732            NotImplementedError: Can not create morphisms of free sub-modules yet
    16641733        """
    16651734        raise NotImplementedError, "Can not create morphisms of free sub-modules yet"
     1735
    16661736    def __cmp__(self, other):
    16671737        """
    16681738        TEST::
     
    17211791        if c == 0:
    17221792            c = cmp(self.basis, other.basis)
    17231793        return c
     1794
    17241795    def merge(self, other):
    17251796        """
    1726         Two Subspace Functors are merged into a construction functor of the sum of two subspaces
     1797        Two Subspace Functors are merged into a construction functor of the sum of two subspaces.
    17271798
    17281799        EXAMPLE::
    17291800
     
    17751846        else:
    17761847            return None
    17771848
    1778        
    17791849class FractionField(ConstructionFunctor):
    17801850    """
    1781     Construction functor for fraction fields
     1851    Construction functor for fraction fields.
    17821852
    17831853    EXAMPLE::
    17841854
     
    18131883            Fraction Field of Univariate Polynomial Ring in t over Integer Ring
    18141884        """
    18151885        Functor.__init__(self, Rings(), Fields())
     1886
    18161887    def _apply_functor(self, R):
    18171888        """
     1889        Apply the functor to an object of ``self``'s domain.
     1890       
    18181891        TEST::
    18191892
    18201893            sage: F = QQ.construction()[0]
     
    18411914#            c = cmp(self.t, other.t)
    18421915#        return c
    18431916   
    1844    
    18451917class CompletionFunctor(ConstructionFunctor):
    18461918    """
    1847     Completion of a ring with respect to a given prime (including infinity)
     1919    Completion of a ring with respect to a given prime (including infinity).
    18481920
    18491921    EXAMPLES::
    18501922
     
    18821954
    18831955    """
    18841956    rank = 4
    1885    
     1957
    18861958    def __init__(self, p, prec, extras=None):
    18871959        """
    18881960        INPUT:
     
    19121984        self.p = p
    19131985        self.prec = prec
    19141986        self.extras = extras
     1987
    19151988    def __str__(self):
    19161989        """
    19171990        TEST::
     
    19201993            (Completion[7], Integer Ring)
    19211994        """
    19221995        return 'Completion[%s]'%repr(self.p)
     1996
    19231997    def _apply_functor(self, R):
    19241998        """
     1999        Apply the functor to an object of ``self``'s domain.
     2000       
    19252001        TEST::
    19262002
    19272003            sage: R = Zp(5)
     
    19792055        if c == 0:
    19802056            c = cmp(self.p, other.p)
    19812057        return c
     2058
    19822059    def merge(self, other):
    19832060        """
    19842061        Two Completion functors are merged, if they are equal. If the precisions of
     
    20212098##   both commute. This is used in the call method,
    20222099##   since some fraction fields have no completion method
    20232100##   implemented.
     2101
    20242102    def commutes(self,other):
    20252103        """
    2026         Completion commutes with fraction fields
     2104        Completion commutes with fraction fields.
    20272105
    20282106        EXAMPLE::
    20292107
     
    20462124            False
    20472125            sage: C(R) is Frac(C(P))
    20482126            True
     2127            sage: F = R.construction()[0]
     2128            sage: (C*F)(ZZ['x']) is (F*C)(ZZ['x'])
     2129            True
    20492130
    20502131        """
    20512132        return isinstance(other,(FractionField,CompletionFunctor))
    20522133   
    20532134class QuotientFunctor(ConstructionFunctor):
    20542135    """
    2055     Construction functor for quotient rings
     2136    Construction functor for quotient rings.
    20562137
    20572138    NOTE:
    20582139
     
    21122193        self.I = I
    21132194        if names is None:
    21142195            self.names = None
    2115         elif isinstance(names,basestring):
     2196        elif isinstance(names, basestring):
    21162197            self.names = (names,)
    21172198        else:
    21182199            self.names = tuple(names)
    21192200        self.as_field = as_field
     2201
    21202202    def _apply_functor(self, R):
    21212203        """
     2204        Apply the functor to an object of ``self``'s domain.
     2205       
    21222206        TESTS::
    21232207
    21242208            sage: P.<x,y> = ZZ[]
     
    21592243        if self.as_field and hasattr(Q, 'field'):
    21602244            Q = Q.field()
    21612245        return Q
     2246
    21622247    def __cmp__(self, other):
    21632248        """
    21642249        The types, the names and the moduli are compared.
     
    21822267        if c == 0:
    21832268            c = cmp(self.I, other.I)
    21842269        return c
     2270
    21852271    def merge(self, other):
    21862272        """
    2187         Two quotient functors with coinciding names are merged by taking the gcd of their moduli
     2273        Two quotient functors with coinciding names are merged by taking the gcd of their moduli.
    21882274
    21892275        EXAMPLE::
    21902276
     
    22022288
    22032289        """
    22042290        if type(self)!=type(other):
    2205             return
     2291            return None
    22062292        if self.names != other.names:
    2207             return
     2293            return None
    22082294        if self == other:
    22092295            if self.as_field == other.as_field:
    22102296                return self
    2211             return QuotientFunctor(self.I,names=self.names, as_field=True) # one of them yields a field!
     2297            return QuotientFunctor(self.I, names=self.names, as_field=True) # one of them yields a field!
    22122298        try:
    22132299            gcd = self.I + other.I
    22142300        except (TypeError, NotImplementedError):
     
    22232309            raise TypeError, "Trivial quotient intersection."
    22242310        # GF(p) has a coercion from Integers(p). Hence, merging should
    22252311        # yield a field if either self or other yields a field.
    2226         return QuotientFunctor(gcd,names=self.names, as_field=self.as_field or other.as_field)
     2312        return QuotientFunctor(gcd, names=self.names, as_field=self.as_field or other.as_field)
    22272313
    22282314class AlgebraicExtensionFunctor(ConstructionFunctor):
    22292315    """
    2230     Algebraic extension (univariate polynomial ring modulo principal ideal)
     2316    Algebraic extension (univariate polynomial ring modulo principal ideal).
    22312317
    22322318    EXAMPLE::
    22332319
     
    22402326    extension will be constructed as the quotient of a univariate
    22412327    polynomial ring::
    22422328
     2329        sage: F(CC)
     2330        Univariate Quotient Polynomial Ring in a over Complex Field with 53 bits of precision with modulus a^3 + a^2 + 1.00000000000000
    22432331        sage: F(RR)
    22442332        Univariate Quotient Polynomial Ring in a over Real Field with 53 bits of precision with modulus a^3 + a^2 + 1.00000000000000
    22452333
     
    23222410            Order in Number Field in a with defining polynomial x^3 - x^2 + 1
    23232411
    23242412        The cyclotomic fields form a special case of number fields
    2325         with prescribed embeddings.
    2326         ::
     2413        with prescribed embeddings::
    23272414
    23282415            sage: C = CyclotomicField(8)
    23292416            sage: F,R = C.construction()
     
    23492436
    23502437    def _apply_functor(self, R):
    23512438        """
     2439        Apply the functor to an object of ``self``'s domain.
     2440       
    23522441        TESTS::
    23532442
    23542443            sage: K.<a>=NumberField(x^3+x^2+1)
     
    23882477
    23892478    def merge(self,other):
    23902479        """
    2391         Merging two :class:`AlgebraicExtensionFunctor`s
     2480        Merging two :class:`AlgebraicExtensionFunctor`s.
    23922481
    23932482        INPUT:
    23942483
    2395         ``other`` -- Construction Functor
     2484        ``other`` -- Construction Functor.
    23962485
    23972486        OUTPUT:
    23982487
     
    24472536
    24482537        """
    24492538        if not isinstance(other,AlgebraicExtensionFunctor):
    2450             return
     2539            return None
    24512540        if self == other:
    24522541            return self
    24532542        # This method is supposed to be used in pushout(),
     
    24552544        # assume that both functors have a single variable.
    24562545        # But for being on the safe side...:
    24572546        if len(self.names)!=1 or len(other.names)!=1:
    2458             return
     2547            return None
    24592548##       We don't accept a forgetful coercion, since, together
    24602549##       with bidirectional coercions between two embedded
    24612550##       number fields, it would yield to contradictions in
     
    24862575
    24872576    def __mul__(self, other):
    24882577        """
    2489         Functor composition.
    2490 
    2491         The last factor is applied first.
     2578        Compose construction functors to a composit construction functor, unless one of them is the identity.
     2579
     2580        NOTE:
     2581
     2582        The product is in functorial notation, i.e., when applying the product to an object
     2583        then the second factor is applied first.
    24922584
    24932585        TESTS::
    24942586
     
    25142606
    25152607    def expand(self):
    25162608        """
    2517         Decompose the functor `F` into sub-functors, whose product returns `F`
     2609        Decompose the functor `F` into sub-functors, whose product returns `F`.
    25182610
    25192611        EXAMPLES::
    25202612
     
    25242616            sage: F,R = L.construction()
    25252617            sage: prod(F.expand())(R) == L
    25262618            True
    2527 
     2619            sage: K = NumberField([x^2-2, x^2-3],'a')
     2620            sage: F, R = K.construction()
     2621            sage: F
     2622            AlgebraicExtensionFunctor
     2623            sage: L = F.expand(); L
     2624            [AlgebraicExtensionFunctor, AlgebraicExtensionFunctor]
     2625            sage: L[-1](QQ)
     2626            Number Field in a1 with defining polynomial x^2 - 3
    25282627        """
    25292628        if len(self.polys)==1:
    25302629            return [self]
     
    25322631
    25332632class AlgebraicClosureFunctor(ConstructionFunctor):
    25342633    """
    2535     Algebraic Closure
     2634    Algebraic Closure.
    25362635
    25372636    EXAMPLE::
    25382637
     
    25622661
    25632662        """
    25642663        Functor.__init__(self, Rings(), Rings())
     2664
    25652665    def _apply_functor(self, R):
    25662666        """
     2667        Apply the functor to an object of ``self``'s domain.
     2668       
    25672669        TEST::
    25682670
    25692671            sage: F = CDF.construction()[0]
     
    25752677            if c is not None and c[0]==self:
    25762678                return R
    25772679        return R.algebraic_closure()
     2680
    25782681    def merge(self, other):
    25792682        """
    25802683        Mathematically, Algebraic Closure subsumes Algebraic Extension.
     
    25922695        """
    25932696        if self==other:
    25942697            return self
     2698        return None
    25952699        # Mathematically, Algebraic Closure subsumes Algebraic Extension.
    25962700        # However, it seems that people do want to work with
    25972701        # algebraic extensions of RR (namely RR/poly*RR). So, we don't do:
     
    26492753
    26502754    def merge(self, other):
    26512755        """
     2756        Merge ``self`` with another construction functor, or return None.
     2757       
    26522758        EXAMPLES::
    26532759
    26542760            sage: P1 = PermutationGroup([[(1,2)]])
     
    26642770
    26652771class BlackBoxConstructionFunctor(ConstructionFunctor):
    26662772    """
    2667     Construction functor obtained from any callable object
     2773    Construction functor obtained from any callable object.
    26682774
    26692775    EXAMPLES::
    26702776
     
    27052811        if not callable(box):
    27062812            raise TypeError, "input must be callable"
    27072813        self.box = box
     2814
    27082815    def _apply_functor(self, R):
    27092816        """
     2817        Apply the functor to an object of ``self``'s domain.
     2818       
    27102819        TESTS::
    27112820
    27122821            sage: from sage.categories.pushout import BlackBoxConstructionFunctor
     
    27172826
    27182827        """
    27192828        return self.box(R)
     2829
    27202830    def __cmp__(self, other):
    27212831        """
    27222832        TESTS::
     
    27332843            c = cmp(self.box, other.box)
    27342844        #return self.box == other.box
    27352845        return c
    2736        
    2737        
     2846
    27382847def pushout(R, S):
    27392848    """
    27402849    Given a pair of Objects R and S, try and construct a
  • sage/groups/perm_gps/permgroup.py

    diff -r 74c911071a9a sage/groups/perm_gps/permgroup.py
    a b  
    366366        if gens is None:
    367367            self._gap_string = gap_group if isinstance(gap_group, str) else str(gap_group)
    368368            self._gens = self._gens_from_gap()
    369             return
     369            return None
    370370
    371371        gens = [self._element_class()(x, check=False).list() for x in gens]
    372372        self._deg = max([0]+[max(g) for g in gens])
  • sage/rings/number_field/number_field.py

    diff -r 74c911071a9a sage/rings/number_field/number_field.py
    a b  
    430430        sage: P.<x> = QQ[]
    431431        sage: K.<a> = NumberField(x^3-5,embedding=0)
    432432        sage: L.<b> = K.extension(x^2+a)
    433         sage: F,R = L.construction()
     433        sage: F, R = L.construction()
    434434        sage: F(R) == L    # indirect doctest
    435435        True
    436436
     
    50865086            sage: S.coerce(y) is y
    50875087            True
    50885088
    5089         Fields with embeddings into an ambient field coerce naturally by the given embedding.
    5090         ::
     5089        Fields with embeddings into an ambient field coerce naturally by the given embedding::
    50915090
    50925091            sage: CyclotomicField(15).coerce(CyclotomicField(5).0 - 17/3)
    50935092            zeta15^3 - 17/3
     
    51765175                    # R is embedded, self isn't. So, we could only have
    51775176                    # the forgetful coercion. But this yields to non-commuting
    51785177                    # coercions, as was pointed out at ticket #8800
    5179                     return
     5178                    return None
    51805179
    51815180    def _magma_init_(self, magma):
    51825181        """
  • sage/rings/number_field/number_field_ideal.py

    diff -r 74c911071a9a sage/rings/number_field/number_field_ideal.py
    a b  
    281281            sage: L.<b> = NumberField(x^8-x^4+1)
    282282            sage: F_2 = L.fractional_ideal(b^2-1)
    283283            sage: F_4 = L.fractional_ideal(b^4-1)
    284             sage: F_2==F_4
     284            sage: F_2 == F_4
    285285            True
    286286
    287287        """
  • sage/rings/polynomial/polynomial_quotient_ring.py

    diff -r 74c911071a9a sage/rings/polynomial/polynomial_quotient_ring.py
    a b  
    419419
    420420            sage: P.<t>=ZZ[]
    421421            sage: Q = P.quo(5+t^2)
    422             sage: F,R = Q.construction()
     422            sage: F, R = Q.construction()
    423423            sage: F(R) == Q
    424424            True
    425425            sage: P.<t> = GF(3)[]
    426426            sage: Q = P.quo([2+t^2])
    427             sage: F,R = Q.construction()
     427            sage: F, R = Q.construction()
    428428            sage: F(R) == Q
    429429            True
    430430