How are SetAlgebra.isDIsjoint, .isSubset, and .isSuperset supposed to work with two empty sets as operands?

The question is for a general set operation function:

func confirmMerger(
  of first: some Sequence<String>,
  and second: some Sequence<String>,
  hasExclusivesToFirst: ConfirmMergerSearchState = .doNotCare,
  hasExclusivesToSecond: ConfirmMergerSearchState = .doNotCare,
  hasSharedValues: ConfirmMergerSearchState = .doNotCare
) -> Bool {
  //...
}

enum ConfirmMergerSearchState: Int {
  case mustBeAbsent = -1
  case doNotCare
  case mustBePresent
}

Mathematically, the intersection of two empty sets, is the empty set. When the intersection is empty, the operands are considered disjoint.
Therefore, two empty sets are disjoint.

Also, the empty set is a subset of every set.
So the empty set is a subset of an empty set.

Finally, a set A is a superset of B, if B is a subset of A.
Therefore, the empty set is a superset of an empty set.

They are all true:

let a: Set<Int> = []
let b: Set<Int> = []

a.isDisjoint(with: b)   // true
a.isSubset(of: b)       // true
a.isSuperset(of: b)     // true
6 Likes