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.
- Negate the expression
(x < -5 || x > 10)
.- Use De Morgan’s Law to rewrite this expression in a different form.
- Equivalent Expression for !(x == 0)
Using De Morgan’s Law, the expression !(x == 0) can be rewritten as:
Original Expression: !(x == 0)
Equivalent Expression: x != 0
-
Negation of the Expression (x < -5 x > 10) To negate the expression (x < -5 x > 10), we apply De Morgan’s Law:
Original Expression: !(x < -5 || x > 10)
Negation: !(x < -5) && !(x > 10)
Now, applying the negation to each part:
!(x < -5) becomes x >= -5
!(x > 10) becomes x <= 10
Truth Tables
- evaluate and shoe equivalency in Boolean expressions
- see al the possible outcomes that we will have.