Relative complement

The rel­a­tive com­ple­ment of two sets \(A\) and \(B\), de­noted \(A \setminus B\), is the set of el­e­ments that are in \(A\) while not in \(B\).

illustration of the output of a relative complement

For­mally stated, where \(C = A \setminus B\)

$$x \in C \leftrightarrow (x \in A \land x \notin B)$$

That is, Iff \(x\) is in the rel­a­tive com­ple­ment \(C\), then \(x\) is in \(A\) and x is not in \(B\).

For ex­am­ple,

  • \(\{1,2,3\} \setminus \{2\} = \{1,3\}\)

  • \(\{1,2,3\} \setminus \{9\} = \{1,2,3\}\)

  • \(\{1,2\} \setminus \{1,2,3,4\} = \{\}\)

If we name the set \(U\) as the set of all things, then we can define the Ab­solute com­ple­ment of the set \(A\), \(A^\complement\), as \(U \setminus A\)