Preparation: Logical Statements and Truth Tables

Starting today, we are going to start introducing new course content through videos, readings, and warmup problems. Today’s prep is shorter than usual and should take a little more than an hour.

Videos (~20 mins)

Reading (~20 mins)

Optional Reading:

This reading covers the same material but has more examples from theoretical mathematics.

Warmup Problems (~30 mins)

Please complete these problems “by hand,” without typing. Pencil/pen and paper is best practice for the quiz, but using a stylus with a tablet is also fine. Then, scan/photograph or otherwise produce an image of your solutions and upload them to Canvas.

Problem 1

Part A

Create truth tables for each of the three logical expressions:

  1. \((r \lor p) \land q\)
  2. \((r \lor p) \land (r \lor q)\)
  3. \(r \lor (p \land q)\)

Part B

Two of these expressions are logically equivalent: no matter the truth values of \(r\), \(p\), and \(q\), the two expressions always evaluate to the same final truth value. Which are the two equivalent expressions?

Problem 2

Your friend tells you about a cool function they wrote in Python. Their function accepts 3 boolean arguments and returns a boolean return value.


def f(p, q, r):
    """
    p, q, and r are assumed to be booleans. 
    returns: boolean
    """
    
    a = p and q
    b = not (q or r)
    c = a and b
    
    return c

Part A

Write a logical expression in terms of \(p\), \(q\), and \(r\) (using symbols like \(\lnot, \lor, \land\)) which has the same value as the return value of your friend’s function f.

Part B

Make a truth table for your expression. Please show the values of a, b, and c in each line of your truth table.

Do you notice anything strange about your truth table?

Optionally, you might be interested to check the final column of your truth table in Python. Here’s some code you can run in Thonny or any other Python environment. You’ll need to also include the definition of the function f above.

import itertools
tf = [True, False]
for p, q, r in itertools.product(tf, tf, tf): 
    print(p, q, r, f(p, q, r))



© Phil Chodrow, 2023