Subrings of the Symbolic Ring#

Subrings of the symbolic ring can be created via the subring() method of SR. This will call SymbolicSubring of this module.

The following kinds of subrings are supported:

  • A symbolic subring of expressions, whose variables are contained in a given set of symbolic variables (see SymbolicSubringAcceptingVars). E.g.

    sage: SR.subring(accepting_variables=('a', 'b'))
    Symbolic Subring accepting the variables a, b
    
  • A symbolic subring of expressions, whose variables are disjoint to a given set of symbolic variables (see SymbolicSubringRejectingVars). E.g.

    sage: SR.subring(rejecting_variables=('r', 's'))
    Symbolic Subring rejecting the variables r, s
    
  • The subring of symbolic constants (see SymbolicConstantsSubring). E.g.

    sage: SR.subring(no_variables=True)
    Symbolic Constants Subring
    

AUTHORS:

  • Daniel Krenn (2015)

Classes and Methods#

class sage.symbolic.subring.GenericSymbolicSubring(vars)#

Bases: SymbolicRing

An abstract base class for a symbolic subring.

INPUT:

  • vars – a tuple of symbolic variables.

has_valid_variable(variable)#

Return whether the given variable is valid in this subring.

INPUT:

  • variable – a symbolic variable.

OUTPUT:

A boolean.

EXAMPLES:

sage: from sage.symbolic.subring import GenericSymbolicSubring
sage: GenericSymbolicSubring(vars=tuple()).has_valid_variable(x)
Traceback (most recent call last):
...
NotImplementedError: Not implemented in this abstract base class
class sage.symbolic.subring.GenericSymbolicSubringFunctor(vars)#

Bases: ConstructionFunctor

A base class for the functors constructing symbolic subrings.

INPUT:

  • vars – a tuple, set, or other iterable of symbolic variables.

EXAMPLES:

sage: from sage.symbolic.subring import SymbolicSubring
sage: SymbolicSubring(no_variables=True).construction()[0]  # indirect doctest
Subring<accepting no variable>
coercion_reversed = True#
merge(other)#

Merge this functor with other if possible.

INPUT:

  • other – a functor.

OUTPUT:

A functor or None.

EXAMPLES:

sage: from sage.symbolic.subring import SymbolicSubring
sage: F = SymbolicSubring(accepting_variables=('a',)).construction()[0]
sage: F.merge(F) is F
True
rank = 11#
class sage.symbolic.subring.SymbolicConstantsSubring(vars)#

Bases: SymbolicSubringAcceptingVars

The symbolic subring consisting of symbolic constants.

has_valid_variable(variable)#

Return whether the given variable is valid in this subring.

INPUT:

  • variable – a symbolic variable.

OUTPUT:

A boolean.

EXAMPLES:

sage: from sage.symbolic.subring import SymbolicSubring
sage: S = SymbolicSubring(no_variables=True)
sage: S.has_valid_variable('a')
False
sage: S.has_valid_variable('r')
False
sage: S.has_valid_variable('x')
False
class sage.symbolic.subring.SymbolicSubringAcceptingVars(vars)#

Bases: GenericSymbolicSubring

The symbolic subring consisting of symbolic expressions in the given variables.

construction()#

Return the functorial construction of this symbolic subring.

OUTPUT:

A tuple whose first entry is a construction functor and its second is the symbolic ring.

EXAMPLES:

sage: from sage.symbolic.subring import SymbolicSubring
sage: SymbolicSubring(accepting_variables=('a',)).construction()
(Subring<accepting a>, Symbolic Ring)
has_valid_variable(variable)#

Return whether the given variable is valid in this subring.

INPUT:

  • variable – a symbolic variable.

OUTPUT:

A boolean.

EXAMPLES:

sage: from sage.symbolic.subring import SymbolicSubring
sage: S = SymbolicSubring(accepting_variables=('a',))
sage: S.has_valid_variable('a')
True
sage: S.has_valid_variable('r')
False
sage: S.has_valid_variable('x')
False
class sage.symbolic.subring.SymbolicSubringAcceptingVarsFunctor(vars)#

Bases: GenericSymbolicSubringFunctor

merge(other)#

Merge this functor with other if possible.

INPUT:

  • other – a functor.

OUTPUT:

A functor or None.

EXAMPLES:

sage: from sage.symbolic.subring import SymbolicSubring
sage: F = SymbolicSubring(accepting_variables=('a',)).construction()[0]
sage: G = SymbolicSubring(rejecting_variables=('r',)).construction()[0]
sage: F.merge(F) is F
True
sage: F.merge(G) is G
True
class sage.symbolic.subring.SymbolicSubringFactory#

Bases: UniqueFactory

A factory creating a symbolic subring.

INPUT:

Specify one of the following keywords to create a subring.

  • accepting_variables (default: None) – a tuple or other iterable of variables. If specified, then a symbolic subring of expressions in only these variables is created.

  • rejecting_variables (default: None) – a tuple or other iterable of variables. If specified, then a symbolic subring of expressions in variables distinct to these variables is created.

  • no_variables (default: False) – a boolean. If set, then a symbolic subring of constant expressions (i.e., expressions without a variable) is created.

EXAMPLES:

sage: from sage.symbolic.subring import SymbolicSubring
sage: V = var('a, b, c, r, s, t, x, y, z')
sage: A = SymbolicSubring(accepting_variables=(a, b, c)); A
Symbolic Subring accepting the variables a, b, c
sage: tuple((v, v in A) for v in V)
((a, True), (b, True), (c, True),
 (r, False), (s, False), (t, False),
 (x, False), (y, False), (z, False))
sage: R = SymbolicSubring(rejecting_variables=(r, s, t)); R
Symbolic Subring rejecting the variables r, s, t
sage: tuple((v, v in R) for v in V)
((a, True), (b, True), (c, True),
 (r, False), (s, False), (t, False),
 (x, True), (y, True), (z, True))
sage: C = SymbolicSubring(no_variables=True); C
Symbolic Constants Subring
sage: tuple((v, v in C) for v in V)
((a, False), (b, False), (c, False),
 (r, False), (s, False), (t, False),
 (x, False), (y, False), (z, False))
create_key_and_extra_args(accepting_variables=None, rejecting_variables=None, no_variables=False, **kwds)#

Given the arguments and keyword, create a key that uniquely determines this object.

See SymbolicSubringFactory for details.

create_object(version, key, **kwds)#

Create an object from the given arguments.

See SymbolicSubringFactory for details.

class sage.symbolic.subring.SymbolicSubringRejectingVars(vars)#

Bases: GenericSymbolicSubring

The symbolic subring consisting of symbolic expressions whose variables are none of the given variables.

construction()#

Return the functorial construction of this symbolic subring.

OUTPUT:

A tuple whose first entry is a construction functor and its second is the symbolic ring.

EXAMPLES:

sage: from sage.symbolic.subring import SymbolicSubring
sage: SymbolicSubring(rejecting_variables=('r',)).construction()
(Subring<rejecting r>, Symbolic Ring)
has_valid_variable(variable)#

Return whether the given variable is valid in this subring.

INPUT:

  • variable – a symbolic variable.

OUTPUT:

A boolean.

EXAMPLES:

sage: from sage.symbolic.subring import SymbolicSubring
sage: S = SymbolicSubring(rejecting_variables=('r',))
sage: S.has_valid_variable('a')
True
sage: S.has_valid_variable('r')
False
sage: S.has_valid_variable('x')
True
class sage.symbolic.subring.SymbolicSubringRejectingVarsFunctor(vars)#

Bases: GenericSymbolicSubringFunctor

merge(other)#

Merge this functor with other if possible.

INPUT:

  • other – a functor.

OUTPUT:

A functor or None.

EXAMPLES:

sage: from sage.symbolic.subring import SymbolicSubring
sage: F = SymbolicSubring(accepting_variables=('a',)).construction()[0]
sage: G = SymbolicSubring(rejecting_variables=('r',)).construction()[0]
sage: G.merge(G) is G
True
sage: G.merge(F) is G
True