Welcome back everyone.

We're gonna finish up our suite on set theory by giving you a neat way to visualize sets,

something called the Venn diagram.

What I'll do is I'll start by going over what

Venn diagrams are and what they're used for.

One of the neat tricks we're gonna do is we're gonna prove

something called the inclusion-exclusion formula which

tells you how big the union of two sets is in terms of the sets and their intersections.

And then we'll revisit our medical testing example just to see how Venn diagrams work.

And again, Venn diagrams are just a way to look at sets and visualize what's going on.

There's no proof to it, but it's often a good visualization trick. Okay, let's get to it.

So, let's first write a set in our old notation.

So we have a set A is equal to curly braces 1, 5, 10, 2.

So let's remember this means that our cardinality of A is equal to what?

Cardinality of A is equal to four.

Okay. So here we've written the set by just listing out its elements explicitly.

Another way to write it is to write

a big circle and just put the elements kind of floating inside it anywhere-- 1,

5, 10, 2, so this is A.

We just think of A,

what we're making explicit here is A is a bag,

sort of a ball with some things in it: 1, 5, 2.

The ordering doesn't matter,

there's nothing there, it's just A has four things in it – there they are.

Okay. And by the way,

you can write this any way you want.

So this might be, for example,

the same as 1, 2, 10, 5.

It's just a visual notion. Okay. So what?

Well, this gives us a cool way to visualize things like intersections.

So for example let's write A again.

A equals 1, 10, 5, 2.

Let's take the set B is equal to 5, -7, 10, 3.

And say that C is equal to 8, 11.

And just a way to depict,

let's draw A as 1,

2, 10, and 5.

And now let's choose a different color – let's draw same color actually, let's draw B.

B has 5, -7, 10 3.

Notice that A intersect B is 10 and 5 – they share that in common.

We can show that by having the two sets overlap.

So here, what are the extra things in B?

-7 and 3.

And notice in some sense this is A,

this over here is B, but inside here is A intersect B,

which we know is equal to 10 and 5,

but we can visually see it.

What about poor little C here.

C is an 8 and 11, 8 and 11 share nothing in common with anything else.

So over here is C, and we're really making a visual point that C is disjoint from A.

A intersect C is the empty set,

B intersect C is the empty set.

Okay. So that's kind of neat.

And I want to use what I have over there to make one more point.

So here is a formula you will often see

called the inclusion-exclusion formula.

And this is one of the formulas that's always true in general.

We're gonna see visually that it's true here,

and we're gonna check it by example.

What this formula is concerned with is if you take A union B.

Let's remember what A union B is: it's a set of things which are in A or B.

In terms of this picture by the way,

A and B is everything you see, right?

That's something the point.

If A is a little ball and B is a little ball,

A union B is just the union of the two.

The inclusion-exclusion formula tells us that the cardinality of A union B,

understood in terms of A and B,

is equal to the cardinality of A plus the cardinality of

B minus the cardinality of A intersect B.

Okay. So first let's just check if that's true in this case.

So, working over here,

we know the cardinal of A union B,

first we can just count that.

What's in A union B? 1 and 2 and 10 and 5 and -7 and 3.

Therefore, this is equal to six.

Cardinality of A, 1 and 2 and 10 and 5,

is equal to four; cardinality of B,

10 and 5 and -7 and 3,

is equal to four; and the cardinality of A intersect B,

10 and 5, is two.

So, we're basically asking is 6 = 4+4-2 and yup, turns out that's true.

Let's erase this question mark;

let's put back in a check.

So that works. Of course it works in that example;

we also see visually why it works.

Right? Because if we take the cardinality of A,

we count it – there are all those elements.

Then we take the cardinality of B and we count it,

we take all those elements.

What's wrong with saying that the cardinality of

A union B equals the cardinality of A plus cardinality of B?

Well, we've double-counted, we've given ourselves

too much credit because we counted 10 and 5 twice.

So we've taken that into account by subtracting,

in essence, one of the copies of 10 and one of the copies of 5.

So, cardinality of A union B equals cardinality of A plus

the cardinality of B minus the cardinality of A intersect B.

Okay, fine. Now with Venn diagrams in hand,

let's revisit that medical testing example.

So let's remember that X was equal to all the people,

so these are all the people who took some exam.

Let's remember that X could be divided up into the healthy people – the people who did

not have I believe we called it VBS for

very bad syndrome – X union S, the people who did have it.

So let's draw that partition here.

We're gonna draw it like this.

There's a line.

Over here are the healthy people,

and over here are the sick people.

Notice we also have that H intersect S is empty.

And so somehow we use that line to divide the two. We had another partition.

We have that X was divided up into the people who tested negative – so

they took a test and made that happy because the test told them they did not have VBS.

Union P, where P was a set

of people who took the test and got very nervous because it told them they had VBS.

So this is another partition of the set, let's use red.

And then it looks sort of like this.

So on this side might be the people who tested negative,

and on this side might be the people who tested positive.

And notice the way I've drawn it: Venn diagrams are never a way to compute something,

they're way to encode visually assumptions.

Notice that H and N are not the same but share a lot of area,

and P and S are not the same but share a lot of area.

That sort of making the point, the following point.

Let's look at this guy right here.

What does that consist of?

That consist of people who are in S but are also in N,

so this is S intersect N which we remember are

the false negatives –

the people who do have the disease but the test tells them they don't.

That's very dangerous, that means they don't get the treatment they need.

Over here, what is this?

These are the set of people who are in H but also in P,

so that's H intersect P,

which are the false positives – those are also unfortunate people,

a little less unfortunate, they just get nervous for no reason.

Ideally, what you would like for

a perfect test is for S intersect N and H intersect P to not be there.

In a good-enough world,

you would like those little slivers to be really small compared to the rest.

Okay, that concludes our video on Venn diagrams.