Esempio n. 1
0
def is_absolute_member(obj: _mo.MathObject) -> bool:
    """Return whether ``obj`` is a member of the :term:`absolute ground set` of this algebra.

     :return: ``True`` if ``obj`` is an :term:`absolute clan`, ``False`` if not.

    .. note:: This function may call :meth:`~.MathObject.get_ground_set` on ``obj``. The result
        of this operation is cached.
    """
    if obj.cached_is_not_multiclan:
        # If known to not be a multiclan, it's also not an absolute multiclan. No further caching.
        return False
    # The `or` clause in this `if` statement is a safety thing. It should never hit.
    if obj.cached_absolute == _mo.CacheStatus.UNKNOWN \
            or obj.cached_multiclan == _mo.CacheStatus.UNKNOWN:
        # The 'absolute' state has not yet been cached. Determine whether obj is an absolute
        # multiclan.
        is_absolute_mclan = obj.get_ground_set().is_subset(get_absolute_ground_set())
        if obj.cached_multiclan == _mo.CacheStatus.UNKNOWN:
            if is_absolute_mclan:
                # If it is an absolute multiclan, it is also a multiclan.
                obj.cache_multiclan(_mo.CacheStatus.IS)
            else:
                # If it is not an absolute multiclan, it may still be a multiclan.
                is_mclan = is_member(obj)
                if not is_mclan:
                    # If it is neither an absolute multiclan nor a multiclan, exit. (That it is
                    # not a multiclan has already been cached in is_member().)
                    return False
        # At this point, cached_multiclan == IS. Cache whether this is an absolute multiclan.
        assert obj.cached_is_multiclan
        obj.cache_absolute(_mo.CacheStatus.from_bool(is_absolute_mclan))
    # At this point, cached_multiclan == IS. Return whether it is an absolute multiclan.
    return obj.cached_is_absolute
Esempio n. 2
0
def is_absolute_member(obj: _mo.MathObject) -> bool:
    """Return whether ``obj`` is a member of the :term:`absolute ground set` of this algebra.

     :return: ``True`` if ``obj`` is an :term:`absolute set`, ``False`` if not.
    """
    if not obj.is_set:
        # If known to not be a set, it's also not an absolute set. No further checking or caching.
        return False
    # From this point on, `obj` is known to be a set.
    if obj.cached_absolute == _mo.CacheStatus.UNKNOWN:
        import algebraixlib.algebras.clans as _clans
        import algebraixlib.algebras.relations as _relations

        # In order to find out whether this is an absolute set, we need to know whether `obj` is a
        # relation or a clan (both sets). If it is one of these, it is not an absolute set -- but
        # we also don't know whether it is an absolute relation or clan. So we return `False` but
        # don't cache anything. (But we have now cached that it is a relation or a clan.)
        if _relations.is_member(obj) or _clans.is_member(obj):
            return False
        is_absolute_set = all(elem.is_atom for elem in obj)
        obj.cache_absolute(_mo.CacheStatus.from_bool(is_absolute_set))
    # In order to determine whether this is an absolute set, we need to also examine whether this
    # is a relation or a clan (both are sets). Absolute relations and absolute clans are not
    # absolute sets.
    return obj.cached_is_absolute and not obj.cached_is_relation and not obj.cached_is_clan
Esempio n. 3
0
def is_absolute_member(obj: _mo.MathObject) -> bool:
    """Return whether ``obj`` is a member of the :term:`absolute ground set` of this algebra.

     :return: ``True`` if ``obj`` is an :term:`absolute clan`, ``False`` if not.

    .. note:: This function may call :meth:`~.MathObject.get_ground_set` on ``obj``. The result
        of this operation is cached.
    """
    if obj.cached_is_not_multiclan:
        # If known to not be a multiclan, it's also not an absolute multiclan. No further caching.
        return False
    # The `or` clause in this `if` statement is a safety thing. It should never hit.
    if obj.cached_absolute == _mo.CacheStatus.UNKNOWN \
            or obj.cached_multiclan == _mo.CacheStatus.UNKNOWN:
        # The 'absolute' state has not yet been cached. Determine whether obj is an absolute
        # multiclan.
        is_absolute_mclan = obj.get_ground_set().is_subset(
            get_absolute_ground_set())
        if obj.cached_multiclan == _mo.CacheStatus.UNKNOWN:
            if is_absolute_mclan:
                # If it is an absolute multiclan, it is also a multiclan.
                obj.cache_multiclan(_mo.CacheStatus.IS)
            else:
                # If it is not an absolute multiclan, it may still be a multiclan.
                is_mclan = is_member(obj)
                if not is_mclan:
                    # If it is neither an absolute multiclan nor a multiclan, exit. (That it is
                    # not a multiclan has already been cached in is_member().)
                    return False
        # At this point, cached_multiclan == IS. Cache whether this is an absolute multiclan.
        assert obj.cached_is_multiclan
        obj.cache_absolute(_mo.CacheStatus.from_bool(is_absolute_mclan))
    # At this point, cached_multiclan == IS. Return whether it is an absolute multiclan.
    return obj.cached_is_absolute
Esempio n. 4
0
def is_absolute_member(obj: _mo.MathObject) -> bool:
    """Return whether ``obj`` is a member of the :term:`absolute ground set` of this algebra.

    :type obj: _mo.MathObject|_mo.Multiset
    :return: ``True`` if ``obj`` is an :term:`absolute multiset`, ``False`` if not.
    """
    import algebraixlib.algebras.multiclans as _multiclans

    if not obj.is_multiset:
        # If known to not be a multiset, it's also not an absolute multiset. No further checking or
        # caching.
        return False
    # From this point on, `obj` is known to be a multiset.
    if obj.cached_absolute == _mo.CacheStatus.UNKNOWN:
        # In order to find out whether this is an absolute multiset, we need to know whether `obj`
        # is a multiclan (also a multiset). If it is one, it is not an absolute multiset -- but
        # we also don't know whether it is an absolute multiclan. So we return `False` but don't
        # cache anything. (But we have now cached that it is a multiclan.)
        if _multiclans.is_member(obj):
            return False
        is_absolute_multiset = all(elem.is_atom for elem in obj.data)
        obj.cache_absolute(_mo.CacheStatus.from_bool(is_absolute_multiset))
    # In order to determine whether this is an absolute multiset, we need to also examine whether
    # this is a multiclan (also a multisets). Absolute multiclans are not absolute multisets.
    return obj.cached_is_absolute and not obj.cached_is_multiclan
Esempio n. 5
0
def is_absolute_member(obj: _mo.MathObject) -> bool:
    """Return whether ``obj`` is a member of the :term:`absolute ground set` of this algebra.

     :return: ``True`` if ``obj`` is an :term:`absolute set`, ``False`` if not.
    """
    if not obj.is_set:
        # If known to not be a set, it's also not an absolute set. No further checking or caching.
        return False
    # From this point on, `obj` is known to be a set.
    if obj.cached_absolute == _mo.CacheStatus.UNKNOWN:
        import algebraixlib.algebras.clans as _clans
        import algebraixlib.algebras.relations as _relations

        # In order to find out whether this is an absolute set, we need to know whether `obj` is a
        # relation or a clan (both sets). If it is one of these, it is not an absolute set -- but
        # we also don't know whether it is an absolute relation or clan. So we return `False` but
        # don't cache anything. (But we have now cached that it is a relation or a clan.)
        if _relations.is_member(obj) or _clans.is_member(obj):
            return False
        is_absolute_set = all(elem.is_atom for elem in obj)
        obj.cache_absolute(_mo.CacheStatus.from_bool(is_absolute_set))
    # In order to determine whether this is an absolute set, we need to also examine whether this
    # is a relation or a clan (both are sets). Absolute relations and absolute clans are not
    # absolute sets.
    return obj.cached_is_absolute and not obj.cached_is_relation and not obj.cached_is_clan
Esempio n. 6
0
def is_absolute_member(obj: _mo.MathObject) -> bool:
    """Return whether ``obj`` is a member of the :term:`absolute ground set` of this algebra.

    :type obj: _mo.MathObject|_mo.Multiset
    :return: ``True`` if ``obj`` is an :term:`absolute multiset`, ``False`` if not.
    """
    import algebraixlib.algebras.multiclans as _multiclans

    if not obj.is_multiset:
        # If known to not be a multiset, it's also not an absolute multiset. No further checking or
        # caching.
        return False
    # From this point on, `obj` is known to be a multiset.
    if obj.cached_absolute == CacheStatus.UNKNOWN:
        # In order to find out whether this is an absolute multiset, we need to know whether `obj`
        # is a multiclan (also a multiset). If it is one, it is not an absolute multiset -- but
        # we also don't know whether it is an absolute multiclan. So we return `False` but don't
        # cache anything. (But we have now cached that it is a multiclan.)
        if _multiclans.is_member(obj):
            return False
        is_absolute_multiset = all(elem.is_atom for elem in obj.data)
        obj.cache_absolute(CacheStatus.from_bool(is_absolute_multiset))
    # In order to determine whether this is an absolute multiset, we need to also examine whether
    # this is a multiclan (also a multisets). Absolute multiclans are not absolute multisets.
    return obj.cached_is_absolute and not obj.cached_is_multiclan
Esempio n. 7
0
def is_absolute_member(obj: _mo.MathObject) -> bool:
    """Return whether ``obj`` is a member of the :term:`absolute ground set` of this algebra.

    :type obj: _mo.MathObject|_mo.Couplet
    :return: ``True`` if ``obj`` is an :term:`absolute couplet`, ``False`` if not.
    """
    if not obj.is_couplet:
        # If known to not be a couplet, it's also not an absolute couplet. No further caching.
        return False
    # From this point on, `obj` is known to be a couplet.
    if obj.cached_absolute == _mo.CacheStatus.UNKNOWN:
        is_absolute_couplet = obj.left.is_atom and obj.right.is_atom
        obj.cache_absolute(_mo.CacheStatus.from_bool(is_absolute_couplet))
    return obj.cached_is_absolute
Esempio n. 8
0
def is_absolute_member(obj: _mo.MathObject) -> bool:
    """Return whether ``obj`` is a member of the :term:`absolute ground set` of this algebra.

    :type obj: _mo.MathObject|_mo.Couplet
    :return: ``True`` if ``obj`` is an :term:`absolute couplet`, ``False`` if not.
    """
    if not obj.is_couplet:
        # If known to not be a couplet, it's also not an absolute couplet. No further caching.
        return False
    # From this point on, `obj` is known to be a couplet.
    if obj.cached_absolute == CacheStatus.UNKNOWN:
        is_absolute_couplet = obj.left.is_atom and obj.right.is_atom
        obj.cache_absolute(CacheStatus.from_bool(is_absolute_couplet))
    return obj.cached_is_absolute