Boolean Logic Boolean Operators TF x NOT x

Boolean Logic

Boolean Operators (T/F) x NOT x F T T F x y x OR y F F T T T F T T x y x AND y F F T T T

Boolean Operators (1/0) x NOT x 0 1 1 0 x y x OR y 0 0 1 1 1 0 1 1 x y x AND y 0 0 1 1 1

More Boolean Operators (1/0) NAND = NOT(x AND y) NOR = NOT(x OR y) XOR = EXCLUSIVE OR x y x NAND y 0 0 1 1 1 0 x y x NOR y x XOR y 0 0 1 1 1 0 0 1 1 1 0

Boolean Expressions n Follows a logical order of operations 1. 2. 3. 4. n NOT operators Parentheses AND OR Examples: x OR y AND z x OR (y AND z) Do it this way just in case

Truth Tables n n n Write out table of all possible combinations of truth values Evaluate the boolean expression for all combinations Example x OR y AND z x y z x OR (y AND z) F F F T T F F T T T T F T T T

Example n What is the truth table for: NOT x OR y? x y F F F T T NOT x OR y

Another Example n What is the truth table for: x AND NOT y? x y F F F T T x AND NOT y

Your Turn n What is the truth table for the Boolean expression: x OR NOT y OR z?

Your Turn n What is the truth table for the Boolean expression: x NAND y OR NOT z

Your turn n What is the truth table for the Boolean expression: a AND (b XOR c)

Partner Practice 1. 2. 3. Write a Boolean expression with no more than 3 variables (you can have multiple Boolean operators) Swap boards with somebody else in the room Write the truth table for the expression

Problem Scenarios 1. 2. 3. 4. You will be given a scenario Identify the input variables Write the Boolean expression Construct the truth table

Scenario #1 n 1. 2. 3. Either the sun is shining or rain is falling Identify the input variables Write the Boolean expression Construct the truth table

Scenario #2 n 1. 2. 3. Maria won’t go to school if it is cold and raining or she has not done her homework. Identify the input variables Write the Boolean expression Construct the truth table

Scenario #3 Your car has 4 wheel drive, which turns on when the temperature is freezing or when you hit the manual override, but you cannot turn on the override when you are going over 60 mph. 1. Identify the input variables 2. Write the Boolean expression 3. Construct the truth table n

Scenario #4 n You are ordering dinner, and your options are a burger, fries, and vegetables. You cannot get a burger and a side of fries together. The healthy option of steamed vegetables is allowed with your burger.
- Slides: 17