1p, q = True, False2not p3p and q4p or q5(not p) or q01p = ?01q = ??pqp∧qp∨qp→q¬p∨qpqp∧qp∨qp→q¬p∨qpqp∧qp∨qp→q¬p∨qpqp∧qp∨qp→q¬p∨q
Input lamps: a lit lamp is true (T, 1), a dark lamp false (F, 0)Evaluator: one expression and its truth valueTruth table: one row per combination, one column per formulaPython card: not, and, or on the same exampleTwo propositions, p (it is raining) and q (I take an umbrella), each true or false. A lit lamp is T. The evaluator works out one connective at a time for p = T and q = F: ¬p is F, p ∧ q is F, p ∨ q is T. The truth table at the front lists all 2 × 2 = 4 combinations and fills in column by column. Implication p → q is F only in row 2 (p true, q false), and its column matches ¬p ∨ q in every row, so the two formulas are logically equivalent. p → q is not the same as its converse q → p. Row 3 shows the difference: p is F and q is T, so p → q is T but q → p is F.

Propositions

  1. A proposition is a statement that is either true or false, never both. Let p be "it is raining" and q be "I take an umbrella". A question such as "Is it raining?" is not a proposition: it has no truth value.

Connectives

Truth tables

Implication

Try it in the Python prompt

;; step 1/10 · What a proposition is
>>> 2 + 2 == 4            # a true proposition
True
>>> 2 + 2 == 5            # a false one
False
>>> type(2 + 2 == 5)
<class 'bool'>

not binds tighter than and, and and binds tighter than or, so not p or q means (not p) or q. Brackets make the meaning clear to the reader anyway. Python stops early. In p and q, if p is false, q is never evaluated; in p or q, if p is true, q is skipped. This is called short-circuit evaluation.