Esempio n. 1
0
def test_intersection_of_every_pair_of_LCs_is_the_LC_of_the_meet():
    for i, (a, b) in enumerate([(a, b) for a in all3Vecs for b in all3Vecs]):
        lcA, lcB = fv.lower_closure(a), fv.lower_closure(b)
        lcAs, lcBs = fv.stack_to_set(lcA), fv.stack_to_set(lcB)
        cap = lcAs.intersection(lcBs)
        meet = fv.meet_specification(a, b)
        lcMeet = fv.lower_closure(meet)
        lcMeets = fv.stack_to_set(lcMeet)
        assert cap == lcMeets, f"{i}:{a},{b}\n{cap}\n{lcMeets}"
Esempio n. 2
0
def test_priority_union_left_is_a_lattice_HM_over_LCs():
    prunion_lhm_LCs_cxs_lefts = []
    for xWrapped in all3VecsSet:
        x = xWrapped.unwrap()
        xLC = fv.lower_closure(x)
        rightArg = lambda right: fv.priority_union(x, right)
        current_prunion_lhm_LCs_cxs_left = fv.is_lattice_homomorphism(
            xLC, rightArg, returnCounterexamples=True)
        prunion_lhm_LCs_cxs_lefts.append(current_prunion_lhm_LCs_cxs_left)
    prunion_lhm_LCs_cxs_left = grand_union(prunion_lhm_LCs_cxs_lefts)
    assert len(prunion_lhm_LCs_cxs_left) == 0, f"{prunion_lhm_LCs_cxs_left}"
Esempio n. 3
0
def test_every_lc_defines_a_complemented_lattice():
    for i, v in enumerate(all3Vecs):
        lc = fv.lower_closure(v)
        assert fv.is_complemented_lattice(lc), f"{i}:{v}\n{lc}"
Esempio n. 4
0
def test_every_lc_defines_a_modular_lattice():
    for i, v in enumerate(all3Vecs):
        lc = fv.lower_closure(v)
        assert fv.is_lattice_modular(lc), f"{i}:{v}\n{lc}"
Esempio n. 5
0
def test_every_lc_defines_a_distributive_lattice():
    for i, v in enumerate(all3Vecs):
        lc = fv.lower_closure(v)
        assert fv.is_lattice_distributive(lc), f"{i}:{v}\n{lc}"
Esempio n. 6
0

def test_priority_union_right_inverse_implementations_are_eq():
    for i, (a, b, c) in enumerate(all3VecIO):
        oldAnswer = fv.stack_to_set(fv.right_inv_priority_union(c=c, b=b))
        newAnswer = fv.stack_to_set(fv.right_inv_priority_union_old(c=c, b=b))
        missingFromNew = oldAnswer - newAnswer
        extraInNew = newAnswer - oldAnswer
        assert oldAnswer == newAnswer, f"{i}:{a},{b},{c}\n{missingFromNew}\n{extraInNew}"


# allLC3sNaive = set(lmap(fv.HashableArray,
#                               [fv.lower_closure(v) for v in all3Vecs]))
allLC3sCompressed = set(
    lmap(lambda M: frozenset(fv.stack_to_set(M)),
         [fv.lower_closure(v) for v in all3Vecs]))
allUC3sCompressed = set(
    lmap(lambda M: frozenset(fv.stack_to_set(M)),
         [fv.upper_closure(v) for v in all3Vecs]))

#####################################
# complement implementation testing #
#####################################


def test_complement_implementations_eq_on_LCs():
    counterexamples = set()
    for lcS in allLC3sCompressed:
        lc = fv.hashableArrays_to_stack(lcS)
        for xWrapped in lcS:
            x = xWrapped.unwrap()