# 4.1.C Operations on sets

Now that we have a way to express a wide variety of sets, we turn to operations that can be performed on sets. The most basic operations on sets are union and intersection. IfA and are sets, then we define the union of and to be the set that contains all the elements of together with all the elements of B. The union of and is denoted byA ∪ B. The union can be defined formally as

$$A \cup B=\{x | x \in A \vee x \in B\}$$

The intersection of and is defined to be the set that contains every entity that is both a member of and a member of B. The intersection of and is denoted by AB. Formally,

$$A \cap B=\{x | x \in A \wedge x \in B\}$$

An entity gets into ∪ if it is in either or B. It gets into ∩ if it is in both and B. Note that the symbol for the logical ‘or’ operator, ∨, is similar to the symbol for the union operator, ∪, while the logical ‘and’ operator, ∧, is similar to the intersection operator, ∩.

The set difference of two sets, and B, is defined to be the set of all entities that are members of but are not members of B. The set difference of and is denoted ∖ or alternatively as − B. The idea is that ∖ is formed by starting with and then removing any element that is also found in B. Formally,

$$A>B=\{x | x \in A \wedge x \notin B\}$$

Union and intersection are clearly commutative operations. That is, ∪ ∪ andA ∩ ∩ for any sets and B. However, set difference is not commutative. In general, AB $$\neq$$ BA.

Suppose that $$A=\{a, b, c\}$$, that $$B=\{b, d\},$$ and that $$C=\{d, e, f\} .$$ Then we can apply the definitions of union, intersection, and set difference to compute, for example, that:

A= {a,b,c,d}     A= {b}     A= {a,c}

A= {a,b,c,d,ef}     A= ∅     A= {a,b,c}

In this example, the sets and have no elements in common, so that ∩ = ∅. There is a term for this: Two sets are said to be disjoint if they have no elements in common. That is, for any sets and Band are said to be disjoint if and only if A ∩ = ∅.

Of course, the set operations can also be applied to sets that are defined by predicates. The next example illustrates this.

let L(x) be the predicate ‘is lucky’, and let W(x) be the predicate ‘is wise’, where the domain of discourse for each predicate is the set of people. LetX = {L(x)}, and let = {W(x)}. Then

∪ = {L(x) ∨ W(x)} = {people who are lucky or wise}

∩ = {L(x) ∧ W(x)} = {people who are lucky and wise}

∖ = {L(x) ∧ ¬W(x)} = {people who are lucky but not wise}

∖ = {W(x) ∧ ¬L(x)} = {people who are wise but not lucky}

Figure 4.2: Some of the notations that are defined in this section. and are sets, anda is an entity.

You have to be a little careful with the English word ‘and’. We might say that the set ∪ contains people who are lucky and people who are wise. But what this means is that a person gets into the set ∪ either by being lucky or by being wise, so ∪ is defined using the logical ‘or’ operator, ∨.