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 bothcondition1
andcondition2
are true.
- Returns
||
(OR):- Returns
true
if at least one of the conditions is true. - Example:
(condition1 || condition2)
is true if eithercondition1
orcondition2
(or both) are true.
- Returns
!
(NOT):- Negates the value of a condition; returns
true
if the condition is false, and vice versa. - Example:
!(condition)
is true ifcondition
is false.
- Negates the value of a condition; returns
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.
!(x == 0)
= (x != 0)
- Negate the expression
(x < -5 || x > 10)
.- Use De Morgan’s Law to rewrite this expression in a different form.
(x < -5 || x > 10)
=(x >= -5 && x <= 10)
- Use De Morgan’s Law to rewrite this expression in a different form.
Truth Tables
- evaluate and shoe equivalency in Boolean expressions
- see al the possible outcomes that we will have.