deMorganUnion<T> static method

bool deMorganUnion<T>(
  1. CustomSet<T> a,
  2. CustomSet<T> b,
  3. CustomSet<T> universal
)

Verifies De Morgan's Law for Union.

Law: (A ∪ B)' = A' ∩ B'

The complement of a union equals the intersection of the complements.

Implementation

static bool deMorganUnion<T>(
  CustomSet<T> a,
  CustomSet<T> b,
  CustomSet<T> universal,
) {
  final union = SetOperations.union(a, b);
  final complementUnion = SetOperations.complement(union, universal);
  final complementA = SetOperations.complement(a, universal);
  final complementB = SetOperations.complement(b, universal);
  final intersectionComplements = SetOperations.intersection(
    complementA,
    complementB,
  );
  return complementUnion.equals(intersectionComplements);
}