UPI Study › Courses › Discrete Mathematics › Free lessons › Lesson 2.3 Free with a free account
Set Complement and Set Difference
Discrete Mathematics · Chapter 2: Set Theory and FunctionsSection 2.3 · lesson 11 of 878 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Discrete Mathematics.
Lesson complete
Earn the 4 college credits for Discrete Mathematics
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Cardinality and Types of Subsets →← The Universal Set and SubsetsNext lesson: Cardinality and Types of Subsets →
In this lesson
Combining 2 sets into a third - and shading the region each describes.
- Compute unions and intersections
- Compute complements, differences, and symmetric differences
- Read each operation as a shaded Venn region
- Prove De Morgan's laws for sets
Transcript
Everything said in the video, section by section (1,157 words). Read along, or search it.
Set Theory and Functions
Set Operations: Complement and Difference
Chapter two has defined what a set is, and how one set sits inside a universal set. This section adds the operations that combine two sets into a third. We'll compute unions, intersections, complements, differences, and symmetric differences. We'll shade the region each one describes on a Venn diagram. And we'll prove De Morgan's laws for sets.
The Opening Problem
One Training Record, Many Lists
A company's learning-management system tracks which employees have completed each required security-training module. A compliance officer needs several lists from the same two tables of employee IDs. Everyone who still needs at least one module. Everyone who's fully compliant. Everyone who finished the phishing module, but not the password module. Each of those lists is, with no extra machinery, a set operation. And in a real database, each is a single query. Union, intersect, and except compute exactly the operations in this section, applied to two tables of IDs.
Definitions 2.3.1 and 2.3.2
Union and Intersection
The union of A and B is the set of all x such that x is in A, or x is in B. Everything in either set. The intersection of A and B is the set of all x such that x is in A, and x is in B. Everything in both. Here's the running example. The universal set is twelve employee IDs, one through twelve. A is the IDs who completed the phishing module, one through seven. B is those who completed the password module, four through ten. For the union, an ID belongs if it appears in at least one list. Every ID from one to ten does, while eleven and twelve appear in neither. That's everyone who completed at least one module. For the intersection, an ID belongs only if it's in both lists. Exactly four, five, six, and seven are. That's everyone who's fully compliant.
Definitions 2.3.3-2.3.5
Complement, Difference, Symmetric Difference
Three more operations round out the toolkit. The complement of A, written A prime, is the set of elements of the universal set that are not in A. It's U minus A, so it depends on U. The set difference, A minus B, is the set of elements in A but not in B. Equivalently, it's A intersect B prime, since not in B is exactly what B prime collects. And the symmetric difference of A and B is the set of elements in exactly one of them. It's A minus B, together with B minus A.
Worked Example, Continued
Who Still Needs What
Using the same sets, here are the results. A prime removes one through seven from one through twelve, leaving eight through twelve. Those employees still need the phishing module. A minus B keeps the IDs in A that aren't in B. That's one, two, and three. They completed phishing only, and still need the password module. B minus A, by the same check in the other direction, is eight, nine, and ten. They completed the password module only. And the symmetric difference is those two sets together. One, two, three, eight, nine, and ten. Everyone who completed exactly one module, and isn't yet fully compliant.
Figure 2.3.1 (1)
The Regions, Shaded
This figure shows the regions on a Venn diagram, with the universal set as the rectangle. The reference diagram shows how many IDs are in each region. Three in A only, four in both, three in B only, and two outside both. The union shades everything inside either circle. And the intersection shades only the overlap, where the two circles share their elements.
Figure 2.3.1 (2)
Complement, Difference, Symmetric Difference
Here are the other three operations, on the same layout. The complement of A shades everything in the rectangle outside circle A. That's why the complement depends on the universal set. A minus B shades the part of circle A that doesn't overlap B. And the symmetric difference shades both circles, except the overlap. It's the union, with the intersection removed.
Laws for Sets
Mirroring the Laws of Logic
These operations obey algebraic laws that mirror the logical laws from section one point six, term for term. Union behaves like or. Intersection behaves like and. And complement behaves like not. The distributive laws for sets say A intersect the quantity B union C equals A intersect B, union A intersect C. And the same holds with union and intersection swapped. De Morgan's laws for sets say the complement of A union B is A prime intersect B prime. And the complement of A intersect B is A prime union B prime.
Worked Proof
De Morgan's Law for Sets
Here's a general proof of the first De Morgan's law for sets, in the arbitrary-element style from section one point seven. Let x be an arbitrary element of the universal set. x is in the complement of A union B, if and only if x is not in A union B, by the definition of complement. By the definition of union, that holds if and only if it's not the case, that x is in A or x is in B. Next comes De Morgan's law for logic, cited from section one point six rather than re-derived. It says that holds if and only if x is not in A, and x is not in B. That's x in A prime and x in B prime. And that's exactly x in the intersection of A prime and B prime. Since x was arbitrary, the two sets are equal.
Checking a Distributive Law
One Case, Both Sides
A distributive law can also be checked for a specific case. Add a set C, the IDs who completed an optional data privacy workshop. Two, four, six, eight, ten, and twelve. On the left, B union C is two, four, five, six, seven, eight, nine, ten, and twelve. Intersect that with A, and you get two, four, five, six, and seven. On the right, A intersect B is four through seven, and A intersect C is two, four, and six. Their union is two, four, five, six, and seven. Both sides match, confirming the law for this case. The general proof is what covers every case.
Table 2.3.1
The Same Operations in SQL
This table pairs each operation with its direct SQL analogue, over two tables of IDs. Union is select from A, union, select from B. Intersection uses intersect. The complement selects the IDs from the universal table that are not in A. Difference uses except. And the symmetric difference is A except B, union, B except A. Set theory and query languages are describing the identical structure.
Takeaways
Every Operation Is a Region
To summarize. Union keeps elements in at least one set, and intersection keeps only elements in both. The complement depends on the universal set. The difference A minus B equals A intersect B prime. And the symmetric difference keeps elements in exactly one set. Every operation corresponds to a shaded region of a Venn diagram, and, for finite sets, to a concrete list you can check. And De Morgan's laws for sets mirror the logical laws from section one point six. Here's something to think about. Two sets split the universal set into four regions. Only A, only B, both, and neither. How many regions can three sets create? And must every region actually contain an element, or can some legitimately be empty?
About Discrete Mathematics at UPI Study
Discrete Mathematics (Math 230) is a self-paced online course of 87 video lessons in 13 chapters, from logic and proof to counting, probability, graph theory and trees. It carries a NCCRS credit recommendation for 4 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus Every course with PRO →
Why take it here
Why students take Discrete Mathematics with UPI Study
Where the credit goes
Universities that work with NCCRS
Discrete Mathematics carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About Set Complement and Set Difference
What is the difference between set complement and set difference?
How do you find A minus B, B minus A, and the symmetric difference of two sets?
How do you shade set complement, difference, and symmetric difference on a Venn diagram?
How do you prove De Morgan's law (A\cup B)' = A'\cap B' for sets?
About the Discrete Mathematics course
How many college credits is Discrete Mathematics?
How much does Discrete Mathematics cost and what is included?
Which universities accept UPI Study credits?
How long does Discrete Mathematics take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 4 credits in Discrete Mathematics.
87 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
4 credits · NCCRSEnroll →