algebraixlib.algebras.sets module¶
This module contains the algebra of sets and related functionality.
-
class
algebraixlib.algebras.sets.Algebra[source]¶ Bases:
objectProvide the operations and relations that are members of the algebra of sets.
This class contains only static member functions. Its main purpose is to provide a namespace for and highlight the operations and relations that belong to the algebra of sets. All member functions are also available at the enclosing module level.
-
static
union()[source]¶ Return the union of
set1withset2.Returns: The binary union of set1andset2orUndef()ifset1orset2are not sets (that is, instances ofSet).
-
static
intersect()[source]¶ Return the intersection of
set1withset2.Returns: The binary intersection of set1andset2orUndef()ifset1orset2are not sets (that is, instances ofSet).
-
static
minus()[source]¶ Return the set difference of
set1andset2.Returns: The difference of set1andset2orUndef()ifset1orset2are not sets (that is, instances ofSet).
-
static
substrict()[source]¶ Return
set1if it is a subset ofset2, otherwise returnUndef().Returns: Return the substriction of set1andset1; that is, returnset1if it is a subset ofset2orUndef()if not. Also returnUndef()ifset1orset2are not sets (that is, instances ofSet).
-
static
superstrict()[source]¶ Return
set1if it is a superset ofset2, otherwise returnUndef().Returns: Return the superstriction of set1andset1; that is, returnset1if it is a superset ofset2orUndef()if not. Also returnUndef()ifset1orset2are not sets (that is, instances ofSet).
-
static
-
algebraixlib.algebras.sets.union()¶ Convenience redirection to
Algebra.union.
-
algebraixlib.algebras.sets.intersect()¶ Convenience redirection to
Algebra.intersect.
-
algebraixlib.algebras.sets.minus()¶ Convenience redirection to
Algebra.minus.
-
algebraixlib.algebras.sets.substrict()¶ Convenience redirection to
Algebra.substrict.
-
algebraixlib.algebras.sets.superstrict()¶ Convenience redirection to
Algebra.superstrict.
-
algebraixlib.algebras.sets.is_subset_of()¶ Convenience redirection to
Algebra.is_subset_of.
-
algebraixlib.algebras.sets.is_superset_of()¶ Convenience redirection to
Algebra.is_superset_of.
-
algebraixlib.algebras.sets.get_name() → str[source]¶ Return the name and ground set of this algebra in string form.
-
algebraixlib.algebras.sets.get_ground_set() → algebraixlib.structure.Structure[source]¶ Return the ground set of this algebra.
-
algebraixlib.algebras.sets.get_absolute_ground_set() → algebraixlib.structure.Structure[source]¶ Return the absolute ground set of this algebra.
-
algebraixlib.algebras.sets.is_member(obj: algebraixlib.mathobjects.mathobject.MathObject) → bool[source]¶ Return whether
objis a member of the ground set of this algebra.Returns: Trueifobjis a set (an instance ofSet),Falseif not.
-
algebraixlib.algebras.sets.is_member_or_undef(obj: algebraixlib.mathobjects.mathobject.MathObject) → bool[source]¶ - Return whether
objis either a member of the ground set of this algebra - or
Undef.
Returns: Trueifobjis either a relation orUndef,Falseif not.- Return whether
-
algebraixlib.algebras.sets.is_absolute_member(obj: algebraixlib.mathobjects.mathobject.MathObject) → bool[source]¶ Return whether
objis a member of the absolute ground set of this algebra.Returns: Trueifobjis an absolute set,Falseif not.
-
algebraixlib.algebras.sets.multify()[source]¶ Return a multiset based on
set_where all multiples are set to 1.
-
algebraixlib.algebras.sets.big_union()[source]¶ Return the union of all members of
set_.Returns: The union of all members of set_orUndef()ifset_or any of its members are not instances ofSet.Example code:
from algebraixlib.mathobjects import Set from algebraixlib.algebras.sets import big_union big_union(Set(Set('a', 'b'), Set('b', 'c'))) # Output: Set(Atom('a'), Atom('b'), Atom('c')) big_union(Set(Set('a', 'b'), 'a')) # Output: <algebraixlib.undef.Undef at 0x4004978>
-
algebraixlib.algebras.sets.big_intersect()[source]¶ Return the intersection of all members of
set_.Returns: The intersection of all members of set_orUndef()ifset_or any of its members are not instances ofSet.Example code:
from algebraixlib.mathobjects import Set from algebraixlib.algebras.sets import big_intersect big_intersect(Set(Set('a', 'b'), Set('b', 'c'))) # Output: Set(Atom('b')) big_intersect(Set(Set('a', 'b'), 'a')) # Output: <algebraixlib.undef.Undef at 0x4004978>
-
algebraixlib.algebras.sets.single(set_: algebraixlib.mathobjects.set.Set)[source]¶ Return the single element of
set_.Returns: Return the single element of set_, orUndef()ifset_has not exactly one element or is not a set (that is, an instance ofSet).
-
algebraixlib.algebras.sets.some(set_: algebraixlib.mathobjects.set.Set)[source]¶ Return ‘some’ element of
set_. Use with caution - may be non-deterministic.Returns: Some element of set_, orUndef()ifset_is empty or is not a set (that is, an instance ofSet).Note
This function should only be used in contexts where the way the return value will be utilized by the calling function is invariant of the particular element returned; the element of
set_that is returned is non-deterministic.This function is only intended to be used in (mostly implementation) scenarios where it does not matter which element of
set_is retrieved, because the expressions that consume that value will be invariant with respect to the exact element ofset_that is returned.
-
algebraixlib.algebras.sets.power_set(set_: algebraixlib.mathobjects.set.Set)[source]¶ Return the power set of
set_.
-
algebraixlib.algebras.sets.power_up(set_: algebraixlib.mathobjects.set.Set)[source]¶ ‘Add a set of braces’ around the elements of
set_.Returns: A Setwhere every element is aSetthat contains exactly one element ofset_and where there is exactly one element-Setfor every element ofset_.
-
algebraixlib.algebras.sets.restrict()[source]¶ Return a set with all the elements from
set_for which the predicateselectorreturnsTrue.Parameters: - set – The source data. Must be a set.
- selector – A
Callablethat accepts as single argument aMathObjectand returns aboolthat indicates whether the element is in the result set (True) or not (False).
-
algebraixlib.algebras.sets.chain_binary_operation(set_, binary_op, is_algebra_member)[source]¶ Chain all elements of
set_with the binary operationbinary_opand return the result.Parameters: Returns: A member of
algebrathat is the result of chaining all elements ofset_with the binary operationbinary_op.