algebraixlib.mathobjects.set module

A math object that represents a set.

class algebraixlib.mathobjects.set.Set(*args, direct_load=False)[source]

Bases: algebraixlib.mathobjects.mathobject.MathObject

A set consisting of zero or more different MathObject instances.

Construct a Set from a single MathObject or value or an iterable collection of
such.
Parameters:
  • args – Zero or more unnamed arguments that are placed into the created set.
  • direct_load – Flag they allows bypassing the normal auto-converting of elements. The elements must all be instances of MathObject.

If no argument is given or the given iterable is empty, an empty set is created.

Note

A string is an iterable, so an explicit conversion to an Atom (or wrapping it into brackets or braces) is required for multi-character strings.

data

Read-only; return the elements of this instance as a frozenset of MathObject instances.

cardinality

Read-only; return the number of elements in the set.

is_empty

Return True if this set is empty.

has_element(elem: algebraixlib.mathobjects.mathobject.MathObject) → bool[source]

Return True if elem is an element of this set. elem must be a MathObject.

For a more relaxed version (that auto-converts non-MathObject arguments into instances of Atom) see __contains__ and the construct elem in Set.

get_ground_set() → algebraixlib.structure.Structure[source]

Return the ground set of the lowest-level algebra of this Set.

get_left_set() → 'P( A )'[source]

Get the left set for this Set. Return Undef if not applicable.

get_right_set() → 'P( A )'[source]

Get the right set for this Set. Return Undef if not applicable.

is_left_regular() → bool[source]

Return True if this Set is left-regular. Return Undef if not applicable.

is_left_functional() → bool[source]

Return True if this Set is left-functional. Return Undef if not applicable.

is_right_functional() → bool[source]

Return True if this Set is right-functional. Return Undef if not applicable.

is_bijection() → bool[source]

Return True if this Set is both left and right-functional. Return Undef if not applicable.

is_reflexive() → bool[source]

Return True if this Set is reflexive. Return Undef if not applicable.

is_symmetric() → bool[source]

Return True if this Set is symmetric. Return Undef if not applicable.

is_transitive() → bool[source]

Return True if this Set is transitive. Return Undef if not applicable.

is_equivalence_relation() → bool[source]

Return True if this Set is reflexive, symmetric, and transitive. Return Undef if not applicable.

get_repr() → str[source]

Return the instance’s code representation.

get_str() → str[source]

Return the instance’s string representation.

__eq__(other)[source]

Implement value-based equality. Return True if type and set elements match.

__ne__(other)[source]

Implement value-based inequality. Return True if type or set elements don’t match.

__contains__(item)[source]

Return True if item is a member of this set. If item is not a MathObject, it is converted into an Atom.

This allows Boolean expressions of the form element in set.

__hash__()[source]

Return a hash based on the value that is calculated on demand and cached.

__repr__()[source]

Return the instance’s code representation.

__str__()[source]

Return the instance’s string representation.

cache_is_relation(value: bool)[source]
cache_is_clan(value: bool)[source]
cache_is_left_functional(value: bool)[source]
cache_is_right_functional(value: bool)[source]
cache_is_left_regular(value: bool)[source]
cache_is_reflexive(value: bool)[source]
cache_is_symmetric(value: bool)[source]
cache_is_transitive(value: bool)[source]