def is_transitive(mo: _mo.MathObject, _checked: bool = True) -> bool: r"""Return whether ``mo`` is :term:`transitive` or `Undef()` if not applicable. Is implemented for :term:`relation`\s, :term:`clan`\s, :term:`multiclan`\s and :term:`set`\s of (sets of ...) clans. Is also defined (but not yet implemented) for any combination of sets or :term:`multiset`\s of relations. """ # pylint: disable=too-many-return-statements if _checked: if not isinstance(mo, _mo.MathObject): return _undef.make_or_raise_undef() # Check cache status. if mo.cached_transitive == _mo.CacheStatus.IS: return True if mo.cached_transitive == _mo.CacheStatus.IS_NOT: return False if mo.cached_transitive == _mo.CacheStatus.N_A: return _undef.make_or_raise_undef(2) # Check type (transitive is only defined on Sets and Multisets) and algebra memberships. if not mo.is_set and not mo.is_multiset: mo.cache_transitive(_mo.CacheStatus.N_A) return _undef.make_or_raise_undef(2) if _relations.is_member(mo): return _relations.is_transitive(mo, _checked=False) if _clans.is_member(mo): return _clans.is_transitive(mo, _checked=False) if _multiclans.is_member(mo): return _multiclans.is_transitive(mo, _checked=False) # Check higher (not yet defined) algebras. transitive = _is_powerset_property(mo, _relations.get_ground_set(), is_transitive) if transitive is not _undef.Undef(): mo.cache_transitive(_mo.CacheStatus.from_bool(transitive)) return transitive # Nothing applied: 'transitive' is not defined. mo.cache_transitive(_mo.CacheStatus.N_A) return _undef.make_or_raise_undef(2)
def is_transitive(mo: _mo.MathObject, _checked: bool=True) -> bool: r"""Return whether ``mo`` is :term:`transitive` or `Undef()` if not applicable. Is implemented for :term:`relation`\s, :term:`clan`\s, :term:`multiclan`\s and :term:`set`\s of (sets of ...) clans. Is also defined (but not yet implemented) for any combination of sets or :term:`multiset`\s of relations. """ # pylint: disable=too-many-return-statements if _checked: if not isinstance(mo, _mo.MathObject): return _undef.make_or_raise_undef() # Check cache status. if mo.cached_transitive == _mo.CacheStatus.IS: return True if mo.cached_transitive == _mo.CacheStatus.IS_NOT: return False if mo.cached_transitive == _mo.CacheStatus.N_A: return _undef.make_or_raise_undef(2) # Check type (transitive is only defined on Sets and Multisets) and algebra memberships. if not mo.is_set and not mo.is_multiset: mo.cache_transitive(_mo.CacheStatus.N_A) return _undef.make_or_raise_undef(2) if _relations.is_member(mo): return _relations.is_transitive(mo, _checked=False) if _clans.is_member(mo): return _clans.is_transitive(mo, _checked=False) if _multiclans.is_member(mo): return _multiclans.is_transitive(mo, _checked=False) # Check higher (not yet defined) algebras. transitive = _is_powerset_property(mo, _relations.get_ground_set(), is_transitive) if transitive is not _undef.Undef(): mo.cache_transitive(_mo.CacheStatus.from_bool(transitive)) return transitive # Nothing applied: 'transitive' is not defined. mo.cache_transitive(_mo.CacheStatus.N_A) return _undef.make_or_raise_undef(2)
def get_ground_set() -> _structure.Structure: """Return the :term:`ground set` of this :term:`algebra`.""" return _structure.PowerSet( _structure.CartesianProduct(_relations.get_ground_set(), _structure.GenesisSetN()))
def get_ground_set() -> _structure.Structure: """Return the :term:`ground set` of this :term:`algebra`.""" return _structure.PowerSet(_relations.get_ground_set())