Vous êtes sur la page 1sur 35

Warm-up

A Little Boolean Review


DeMorgans Laws:
!(P&&Q) = ___________________
!(P || Q) = ____________________

Warm-up
A Little Boolean Review
DeMorgans Laws:
!(P&&Q) = !P || !Q
!(P || Q) = !P && !Q

Warm-up
A Little Boolean Review
! (x > = y ) = _______________

! (x>y)

= _______________

Warm-up
A Little Boolean Review
Use DeMorgans Law to change these:

! (x > = y && a < b ) = ____________

! ( x >= y || a >= b ) = _____________

Warm-up
A Little Boolean Review
Use DeMorgans Law to change these:

! (x > = y && a < b ) = x<y || a>=b

! ( x >= y || a >= b ) = x<y || a<b

More Boolean!
(y>10000) || ( x>1000 && x<1500 )

a. (y>10000 || x>1000) && (y>10000 || x<1500)


b. (y>10000 || x>1000) || (y>10000 || x<1500)
c. (y>10000) && (x>1000 || x<1500 )
d. (y>10000 && x>1000) || (y>10000 && x<1500)

e. (y > 10000 && x>1000) && (y>10000 && x<1500)

Use the old distributive property:


(y>10000) || ( x>1000 && x<1500 )
A * (B + C) = A * B + A * C

a. (y>10000 || x>1000) && (y>10000 || x<1500)


b. (y>10000 || x>1000) || (y>10000 || x<1500)
c. (y>10000) && (x>1000 || x<1500 )
d. (y>10000 && x>1000) || (y>10000 && x<1500)
e. (y > 10000 && x>1000) && (y>10000 && x<1500)

Use the old distributive property:


(y>10000) || ( x>1000 && x<1500 )
A * (B + C) = A * B + A * C
(y>10000 || x>1000)
a. (y>10000 || x>1000) && (y>10000 || x<1500)
b. (y>10000 || x>1000) || (y>10000 || x<1500)
c. (y>10000) && (x>1000 || x<1500 )
d. (y>10000 && x>1000) || (y>10000 && x<1500)
e. (y > 10000 && x>1000) && (y>10000 && x<1500)

Use the old distributive property:


(y>10000) || ( x>1000 && x<1500 )
A * (B + C) = A * B + A * C
(y>10000 || x>1000) &&
a. (y>10000 || x>1000) && (y>10000 || x<1500)
b. (y>10000 || x>1000) || (y>10000 || x<1500)
c. (y>10000) && (x>1000 || x<1500 )
d. (y>10000 && x>1000) || (y>10000 && x<1500)
e. (y > 10000 && x>1000) && (y>10000 && x<1500)

Use the old distributive property:


(y>10000) || ( x>1000 && x<1500 )
A * (B + C) = A * B + A * C
(y>10000 || x>1000) && (y>10000 || x<1500)
a. (y>10000 || x>1000) && (y>10000 || x<1500)
b. (y>10000 || x>1000) || (y>10000 || x<1500)
c. (y>10000) && (x>1000 || x<1500 )
d. (y>10000 && x>1000) || (y>10000 && x<1500)
e. (y > 10000 && x>1000) && (y>10000 && x<1500)

Use the old distributive property:


(y>10000) || ( x>1000 && x<1500 )
A * (B + C) = A * B + A * C
(y>10000 || x>1000) && (y>10000 || x<1500)
a. (y>10000 || x>1000) && (y>10000 || x<1500)
b. (y>10000 || x>1000) || (y>10000 || x<1500)
c. (y>10000) && (x>1000 || x<1500 )
d. (y>10000 && x>1000) || (y>10000 && x<1500)
e. (y > 10000 && x>1000) && (y>10000 && x<1500)

(x==y && x!=z) || (x!=y && x==z)

(x==y || x==z) && (x!=y || x!= z)


Lets see what happens if the last statement is true.

(x==y) != (x==z)

(x==y && x!=z) || (x!=y && x==z)

(x==y || x==z) && (x!=y || x!= z)


Lets see what happens if the last statement is true.

(x==y) != (x==z)
The value of the left side and the right side cant be
the same. They must be Not Equal. One side must
be true and the other side must be false.

(x==y && x!=z) || (x!=y && x==z)

(x==y || x==z) && (x!=y || x!= z)

(x==y) != (x==z)
Since x = y or x = z, but x doesnt equal y and z. If
all three are equal, then both the left and right would
be true, and would not meet the != condition

(x==y && x!=z) || (x!=y && x==z)

(x==y || x==z) && (x!=y || x!= z)


In other words, they cant all be the same.

(x==y) != (x==z)
Furthermore, if all three are different, then both the
left and right side would be false, which means they
dont meet the != condition.

(x==y && x!=z) || (x!=y && x==z)

(x==y || x==z) && (x!=y || x!= z)

(x==y) != (x==z)
Conclusion: x is equal to either y or z. Does this
condition make the two statements above true?

Knowing this, lets look at this statement.

(x==y && x!=z) || (x!=y && x==z)


Do the same conditions make it true?

(x==y || x==z) && (x!=y || x!= z)

(x==y) != (x==z)

If x equals y and does not equal z, the left side is true

(x==y && x!=z) || (x!=y && x==z)


Since the operator is OR, the statement is true no
matter what is on the right side.

(x==y || x==z) && (x!=y || x!= z)

(x==y) != (x==z)

If x equals z and does not equal y, the right side is true

(x==y && x!=z) || (x!=y && x==z)


Since the operator is OR, the statement is true no
matter what is on the left side.

(x==y || x==z) && (x!=y || x!= z)

(x==y) != (x==z)

So, the third and first meet the same conditions

(x==y && x!=z) || (x!=y && x==z)


when evaluating to true. How about the middle?

(x==y || x==z) && (x!=y || x!= z)

(x==y) != (x==z)

(x==y && x!=z) || (x!=y && x==z)


If x equals either y or z, the left is true. If the x

(x==y || x==z) && (x!=y || x!= z)


is different than either y or z, the right is true.

(x==y) != (x==z)

(x==y && x!=z) || (x!=y && x==z)


So given the exact conditions again, that x equals

(x==y || x==z) && (x!=y || x!= z)


either y or z, but not both, the middle statement is true.

(x==y) != (x==z)

(x==y && x!=z) || (x!=y && x==z)

(x==y || x==z) && (x!=y || x!= z)

(x==y) != (x==z)
You may figure out the condition that make the last
statement false and follow the same steps to compare
those conditions to the other two statements

(x==y && x!=z) || (x!=y && x==z)

(x==y || x==z) && (x!=y || x!= z)

(x==y) != (x==z)
Hint: This statement is false only if
* all three are the same,
* all three are different,
* or y = z but not x.

De Morgans Laws
!(a&&b) = !a || !b
!(a || b) = !a && !b

Using DeMorgans Laws


The expression !((x<=y) && (y>5)) is
equivilant to which of the following?

A.
B.
C.
D.
E.

(x<=y) && (y>5)


(x<=y) || (y>5)
(x>=y) || (y<5)
(x>y) || (y<=5)
(x>y) && (y<=5)

Using DeMorgans Laws


The expression !((x<=y) && (y>5)) is
equivilant to which of the following?

A.
B.
C.
D.
E.

(x<=y) && (y>5)


(x<=y) || (y>5)
(x>=y) || (y<5)
(x>y) || (y<=5)
(x>y) && (y<=5)

Using DeMorgans Laws


The expression !(x>y && y<=0) is equivilant
to which of the following?

A.
B.
C.
D.
E.

!(x<=y) || (y>0)
x>y && y<=0
x<=y || y>0
x>y || y<0
x<=y && y<=0

Using DeMorgans Laws


The expression !(x>y && y<=0) is equivilant
to which of the following?

A.
B.
C.
D.
E.

!(x<=y) || (y>0)
x>y && y<=0
x<=y || y>0
x>y || y<0
x<=y && y<=0

Given that x is true, y is true, and z is


false, which of the following
expressions will evaluate to false?
A.
B.
C.
D.
E.

(x&&y) || z
(x || y) && z
y || (x&&z)
x || (y && z)
x && (y || z)

Given that x is true, y is true, and z is


false, which of the following
expressions will evaluate to false?
A.
B.
C.
D.
E.

(x&&y) || z
(x || y) && z
y || (x&&z)
x || (y && z)
x && (y || z)

Assuming that c and d are boolean variables,


the expression !c || d is equivalent to
which of the following?

A.
B.
C.
D.
E.

!(c && d)
!(c && !d)
c && !d
!(c || !d)
!(!c && d)

Assuming that c and d are boolean variables,


the expression !c || d is equivalent to
which of the following?

A.
B.
C.
D.
E.

!(c && d)
!(c && !d)
c && !d
!(c || !d)
!(!c && d)

Assuming that a and b are boolean when is the


following expression true:
!(!a || b) || (!a && b)

A.
B.
C.
D.
E.

If and only if a and b have different values


If and only if a and b have the same value
If and only if both a and b are true
If and only if both a and b are false
None

Assuming that a and b are boolean when is the


following expression true:
!(!a || b) || (!a && b)

A.
B.
C.
D.
E.

If and only if a and b have different values


If and only if a and b have the same value
If and only if both a and b are true
If and only if both a and b are false
None

Vous aimerez peut-être aussi