def reldom_compatible(
    a: tuple[cl.Relation, Domain],
    b: tuple[cl.Relation, Domain],
):
    """If relation a is satisfied, can relation b be satisfied?"""

    assert isinstance(a[1], Domain)
    assert isinstance(b[1], Domain)

    a_neg = isinstance(a[0], cl.NegatedRelation)
    b_neg = isinstance(b[0], cl.NegatedRelation)
    match (a_neg, b_neg):
        case True, False:
            if b[0].implies(a[0].rel) and b[1].intersects(a[1]):
                lazydebug(
                    logger,
                    lambda: f"reldom_compatible found contradicting negated {a[0]} {b[0]}",
                )
                return False
        case False, True:
            if a[0].implies(b[0].rel) and a[1].intersects(b[1]):
                lazydebug(
                    logger,
                    lambda: f"reldom_compatible found contradicting negated {a[0]} {b[0]}",
                )
                return False

    return True
If relation a is satisfied, can relation b be satisfied?
infinigen/core/constraints/reasoning/domain.py