Exemplo n.º 1
0
def test_cap_of_every_interval_pair_is_empty_or_an_interval_with_natural_bounds(
):
    counterexamples = set()
    for i, intervalLeftWrapped in enumerate(all3VecIntervals):
        intervalLeft = fv.hashableArrays_to_stack(intervalLeftWrapped)
        maxLeft, minLeft = fv.max_of(intervalLeft), fv.min_of(intervalLeft)
        for j, intervalRightWrapped in enumerate(all3VecIntervals):
            intervalRight = fv.hashableArrays_to_stack(intervalRightWrapped)
            maxRight, minRight = fv.max_of(intervalRight), fv.min_of(
                intervalRight)

            capSet = intervalLeftWrapped.intersection(intervalRightWrapped)
            capStack = fv.hashableArrays_to_stack(capSet)

            est_cap_max = fv.meet_specification(maxLeft, maxRight)
            est_cap_min = fv.join_specification(minLeft, minRight)
            if len(capSet) > 0:
                est_cap = fv.interval(est_cap_min, est_cap_max)
                est_capSet = fv.stack_to_set(est_cap)
                if not est_capSet == capSet:
                    counterexamples.add(
                        ((i, intervalLeftWrapped), (j, intervalRightWrapped),
                         (capSet, est_capSet)))
            else:
                assert est_cap_max is None or est_cap_min is None or not fv.lte_specification(
                    est_cap_min, est_cap_max), f"{est_cap_max}, {est_cap_min}"
    assert len(counterexamples) == 0, f"Counterexamples:\n{counterexamples}"
Exemplo n.º 2
0
def test_right_inverse_is_associative():
    counterexamples = set()
    for xWrapped, yWrapped, zWrapped in all3VecTriplesSet:
        x, y, z = xWrapped.unwrap(), yWrapped.unwrap(), zWrapped.unwrap()
        xy = fv.right_inv_priority_union(x, y)
        xyWrapped = None if xy is None else fv.stack_to_set(xy)
        if xy is None:
            xy_z = None
        else:
            xy_zWrapped = set()
            for xyPrimeWrapped in xyWrapped:
                xyPrime = xyPrimeWrapped.unwrap()
                if fv.right_inv_priority_union(xyPrime, z) is not None:
                    xy_zWrapped.union(
                        fv.stack_to_set(fv.right_inv_priority_union(
                            xyPrime, z)))
            xy_z = fv.hashableArrays_to_stack(
                xy_zWrapped) if len(xy_zWrapped) > 0 else None
            # xy_z  = np.unique(fv.hashableArrays_to_stack(
            #     grand_union([
            #         fv.stack_to_set(fv.right_inv_priority_union(xyPrime, z))
            #         for xyPrime in xyWrapped if fv.right_inv_priority_union(xyPrime, z) is not None])
            # ), axis=0)
        yz = fv.right_inv_priority_union(y, z)
        yzWrapped = None if yz is None else fv.stack_to_set(yz)
        if yz is None:
            x_yz = None
        else:
            x_yzWrapped = set()
            for yzPrimeWrapped in yzWrapped:
                yzPrime = yzPrimeWrapped.unwrap()
                if fv.right_inv_priority_union(x, yzPrime) is not None:
                    x_yzWrapped.union(
                        fv.stack_to_set(fv.right_inv_priority_union(
                            x, yzPrime)))
            x_yz = fv.hashableArrays_to_stack(
                x_yzWrapped) if len(x_yzWrapped) > 0 else None
            # x_yz  = np.unique(fv.hashableArrays_to_stack(
            #     grand_union([
            #         fv.stack_to_set(fv.right_inv_priority_union(x, yzPrime))
            #         for yzPrime in yzWrapped if fv.right_inv_priority_union(x, yzPrime) is not None])
            # ), axis=0)
        # x_yz = None if yz is None else fv.right_inv_priority_union(x, yz)
        if xy_z is None and not x_yz is None:
            counterexamples.add((xWrapped, yWrapped, zWrapped))
        elif xy_z is not None and x_yz is None:
            counterexamples.add((xWrapped, yWrapped, zWrapped))
        elif xy_z is not None and x_yz is not None:
            if not np.array_equal(xy_z, x_yz):
                counterexamples.add((xWrapped, yWrapped, zWrapped))
        else:
            pass
    assert len(counterexamples) == 0, f"{counterexamples}"
Exemplo n.º 3
0
def test_every_interval_is_a_bounded_lattice():
    counterexamples = set()
    for i, intervalWrapped in enumerate(all3VecIntervals):
        interval = fv.hashableArrays_to_stack(intervalWrapped)
        if not fv.is_bounded_lattice(interval):
            counterexamples.add(intervalWrapped)
    assert len(counterexamples) == 0, f"Counterexamples:\n{counterexamples}"
Exemplo n.º 4
0
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()
            cStack = fv.complement_search(x, lc)
            c = np.expand_dims(fv.complement_exact(x, lc), axis=0)
            if not np.array_equal(cStack, c):
                counterexamples.add(
                    (lc, x, cStack, c, f"{lc}, {x} | {cStack} ≠ {c}"))
    assert len(counterexamples) == 0, f"Counterexamples:\n{counterexamples}"
Exemplo n.º 5
0
def test_the_intersection_of_every_pair_of_intervals_is_empty_or_an_interval():
    counterexamples = set()
    for i, intervalLeftWrapped in enumerate(all3VecIntervals):
        # intervalLeft = fv.hashableArrays_to_stack(intervalLeftWrapped)
        for j, intervalRightWrapped in enumerate(all3VecIntervals):
            # intervalRight = fv.hashableArrays_to_stack(intervalRightWrapped)
            capSet = intervalLeftWrapped.intersection(intervalRightWrapped)
            capStack = fv.hashableArrays_to_stack(capSet)
            if len(capSet) > 0:
                # if not fv.is_bounded_lattice(capStack):
                if not capSet in all3VecIntervals:
                    counterexamples.add(
                        ((i, intervalLeftWrapped), (j, intervalRightWrapped)))
    assert len(counterexamples) == 0, f"Counterexamples:\n{counterexamples}"