WEBVTT

00:00.550 --> 00:07.790
Want to go over a very important concept in programming called boolean logic using Poulan logic to create

00:07.820 --> 00:15.530
our conditions which in turn will make our decisions we said before that conditions can either evaluate

00:15.530 --> 00:17.380
to TRUE or FALSE.

00:17.390 --> 00:26.840
So your own two values a boolean Bayrou variable can have is what and logic really boils down to getting

00:26.840 --> 00:32.200
things to evaluate to TRUE or FALSE.

00:32.450 --> 00:39.630
There are three main operations we'll go through and or and inverse.

00:39.760 --> 00:50.370
So for and logical and here say we have to in variables A and B.

00:50.810 --> 00:59.100
So the whole condition evaluates to true only if A and B are both true.

00:59.970 --> 01:04.860
So otherwise the combination is false.

01:05.540 --> 01:11.570
So this makes sense if you really think about it both have to be true in order for the entire thing

01:11.570 --> 01:12.390
to be true.

01:15.370 --> 01:25.510
So the next is Wanjiku or so again we say we have our boolean values a and b.

01:25.750 --> 01:31.750
So a or b is true if either is true.

01:31.750 --> 01:39.400
So either A is true or B is true or both a and b are true.

01:39.400 --> 01:48.280
So the only time a or b is false is if A is false and B is false.

01:48.280 --> 01:52.050
So the exact opposite of and

01:55.070 --> 01:56.450
so inverse.

01:56.460 --> 02:02.620
Let's say we have a is a in value and you sign it to be true.

02:02.990 --> 02:07.900
So the inverse of A then is false and vice versa.

02:07.910 --> 02:18.300
Say we add a is false the inverse a would be true it's just the opposite of what the value is.

02:18.300 --> 02:22.940
So there are a few laws that you can use and think about.

02:23.160 --> 02:31.010
And the first one is the associate of law also a or b is the same as B or A.

02:31.080 --> 02:39.330
And of course the same for and is a and b is the same as B and C you can write them in any order.

02:39.340 --> 02:41.850
It's really what this is saying.

02:44.880 --> 02:55.780
The distributive law so let's say we have a and in parentheses B or C is the same as saying a and b

02:55.930 --> 03:04.200
or a and c so it distributes to each part of the expression

03:08.470 --> 03:11.640
so and laso see me have a.

03:12.030 --> 03:13.590
And false.

03:13.590 --> 03:21.540
Well we said before both have to be true for the entire expression to be true so a and false is always

03:21.540 --> 03:22.480
false.

03:23.350 --> 03:26.110
So a and true.

03:26.170 --> 03:33.100
Well that really depends on what a is if a is true then the whole expression of it be true.

03:33.100 --> 03:47.840
But if a was false false and true is false A and A is again really just dependent on what A is and similarly

03:48.260 --> 03:54.800
A and B inverse of A is always false because a can't have the value.

03:54.890 --> 04:01.030
So if A has a value true and inverse of true is false.

04:01.040 --> 04:04.720
So a true and false is false.

04:04.720 --> 04:10.720
So it can't be both true.

04:10.910 --> 04:17.140
So the or law say we have a.

04:17.170 --> 04:18.110
Or false.

04:18.110 --> 04:21.580
Well again it depends on what A is.

04:21.610 --> 04:29.050
So if A was true then the entire expression true if A was false then the entire expression would be

04:29.050 --> 04:31.220
false.

04:31.300 --> 04:34.180
And similarly with the A or true.

04:34.180 --> 04:43.600
Well you said before that if either part of the expression is true then offering it together is always

04:43.600 --> 04:44.150
true.

04:46.070 --> 04:52.600
And then a or a is again always a depends and then a.

04:52.650 --> 04:56.910
Or should say the inverse of A is always true.

04:56.910 --> 05:08.100
So it's the opposite of what the analysts said because say was false A or the inverse of false is true.

05:08.130 --> 05:09.110
So for

05:12.020 --> 05:15.130
and lastly the in version on.

05:15.440 --> 05:21.490
Let's say we have the inverse of the inverse of a well the inverse is just kind of cancel out.

05:21.530 --> 05:26.960
And then you're left with Hey.

05:27.220 --> 05:33.120
There there are some other ways something can evaluate to TRUE and FALSE and we'll see that in the next

05:33.120 --> 05:33.920
lecture.

05:34.170 --> 05:40.740
We also see some examples of what I just outlined in the next lecture and what the syntax we need to

05:40.740 --> 05:43.180
make this to make this work.
