Skip to the content.
3.6 Equivalent Boolean Expressions
- There are multiple ways to represent the same boolean expression. To show that the are the same expression, wither prove that they can be simplified to the same expression using boolean properties and identitied or prove that they can be the same in all cases.
- Using De Morgan’s Law to compare and contrast equivalent Boolean expressions
Logical operators reminder
&&
(AND):
- Returns
true
only if both conditions are true.
- Example:
(condition1 && condition2)
is true if both condition1
and condition2
are true.
||
(OR):
- Returns
true
if at least one of the conditions is true.
- Example:
(condition1 || condition2)
is true if either condition1
or condition2
(or both) are true.
!
(NOT):
- Negates the value of a condition; returns
true
if the condition is false, and vice versa.
- Example:
!(condition)
is true if condition
is false.
De Morgans Law
Distributing a “not” with a Boolean expression ‘flips’ the relationsal operator to the opposite relational operator
- ex: !(x > 0) is equivalent to (x<= 0)
Popcorn Hack
Challenge Questions
- What is
!(x == 0)
equivalent to?
- Apply De Morgan’s Law to find an equivalent expression.
- Answer: x!=0
- Negate the expression
(x < -5 || x > 10)
.
- Use De Morgan’s Law to rewrite this expression in a different form.
- Answer: !(x >= -5 && x <= 10)
Truth Tables
- evaluate and shoe equivalency in Boolean expressions
- see al the possible outcomes that we will have.