How to build a set using the rule “exclude A or B” in set theory

elementary-set-theory

I've just started learning set theory today and have been trying to understand how the notion of "inclusion" and "exclusion" fits within it, to build a subset from a set based on a set of rules – see the related question

My XY problem is that I am trying to create a program that will filter a list of items based on various "rules", where a rule can be something like "include/exclude items with condition A", or "include/exclude items with condition B". To muddy the waters, it is possible to say something like "include items with condition A AND B" or "include items with condition A OR B", and conversely "exclude A AND B" or "exclude A OR B"

To give a few practical examples, let's say we have a "universal set" $U = \{1, 2, 3, 4, 5, 6, 7, 8, 9, 10\}$.

I can apply "rules" like the following to produce a new subset.

  1. "Include numbers that are even" –> $\{2, 4, 6, 8, 10\}$
  2. "Include numbers that are even AND greater than 5" –> $\{6, 8, 10\}$
  3. "Include numbers that are even OR greater than 5" –> $\{2, 4, 6, 7, 8, 9, 10\}$
  4. "Exclude numbers that are even" –> $\{1, 3, 5, 7, 9\}$
  5. "Exclude numbers that are even AND greater than 5" –> $\{1, 2, 3, 4, 5, 7, 9\}$
  6. "Exclude numbers that are even OR greater than 5" –> ???

I arrive at a problem at rule 6. I have no idea how to compute this set.

I understand that I can use some set operations to apply these "rules". E.g. for rule 1, I'm coming up with a set of even numbers (call it $E$) and performing an intersection with the universal set, such that $U \cap E = \{2, 4, 6, 8, 10\}$. With rule 2, I'm calculating a set of the even numbers (the aforementioned $E$) and the set of numbers greater than 5 (call it $G = \{6, 7, 8, 9, 10\}$), and then I'm again performing an intersection on these two sets: $E \cap G = \{2, 4, 6, 8, 10\} \cap \{6, 7, 8, 9, 10\} = \{6, 8, 10\}$

But I don't understand logically what the rule 6 I've laid out even means. Rule 5 is clear enough, that we take $E \cap G$, which again is $\{6, 8, 10\}$, and then subtract that from the universal set $U – \{6, 8, 10\} = \{1, 2, 3, 4, 5, 7, 9\}$. What would it mean to exclude numbers that are either even or greater than 5?

I'm sure this is obvious once you've got a grounding in set theory, but I'm not seeing the solution and would appreciate a pointer.

Best Answer

Excluding numbers that are either even or greater than $5$ is the precise opposite of including numbers that are even or greater than $5$, so assuming you know how to do the latter, the former follows fairly simply.

We can include numbers that are even or greater than $5$ with a union. Set $E=\{2,4,6,8,10\}$ and $G=\{6,7,8,9,10\}$, and take the union $E\cup G=\{2,4,6,7,8,9,10\}$. If we instead want to exclude these numbers, we simply subtract from the universal set to get $U-(E\cup G)=\{1,3,5\}$.