Propositions
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.
Each proposition gets a truth value: T for true or F for false. Python spells them True and False. Say it is raining but I forgot my umbrella: p is T and q is F. A lit lamp (the binary digit 1) means T.
Connectives
Connectives build new propositions from old ones. The simplest is negation, written ¬p and read "not p". It flips the value: p is T, so ¬p is F. In Python you write not p.
Conjunction, written p ∧ q and read "p and q", is true only when both parts are true. Here p is T but q is F, so p ∧ q is F. In Python you write p and q.
Disjunction, written p ∨ q and read "p or q", is true when at least one part is true, and also when both are. p is T, so p ∨ q is T. This inclusive or is Python's or.
Truth tables
A truth table lists every combination of values. Each proposition is T or F, so two propositions give 2 × 2 = 4 rows, and n propositions give 2ⁿ rows. Fill in p and q: TT, TF, FT, FF.
Now work out each connective row by row. p ∧ q is T only in row 1, where both are T. p ∨ q is F only in row 4, where both are F. These two columns define AND and OR completely.
Implication
Implication, p → q, reads "if p then q". Treat it as a promise: if it rains, I take an umbrella. The promise is broken only when p is T and q is F, so row 2 is its only F.
When it is not raining, the promise is never tested, so p → q counts as true whatever q is. That is why rows 3 and 4 are T. Mathematicians call this vacuously true.
Python has no → operator, so write (not p) or q. Its column, T F T T, matches p → q in every row. Formulas with identical columns are logically equivalent: p → q ≡ ¬p ∨ q.
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.