Truth Table Tool: http://web.stanford.edu/class/archive/cs/cs103/cs103.1232/tools/truth-table-tool/
Today’s topic: reasoning with boolean variables
Propositional Variables
- Each propositional variable stands for a proposition, something that is either true or false.
- convention is lower-case letters, such as $p,q,r,s$
- each variable is like a
bool
variable
Propositional Connectives
- Propositional connectives link propositions into larger propositions (e.g. $\lor$, $\land$, $\to$, etc.)
- Seven propositional connectives, five of which will be familiar from programming
- Notes: $\lor$ is inclusive or
- true and false are considered connectives that connect 0 things
- Exclusive or: can be written as $(p \lor q) \land \lnot (p \land q)$, or $(\lnot p \land q) \lor (p \land \lnot q)$
- The convention for proofs is NOT to use propositional logic notation, and to instead use words. Exception: if proof about the actual logic notation or computational logic.
Written |
Read |
Fancy name |
C++ |
$\lnot p$ |
not p |
negation |
!p |
$p \land q$ |
p and q |
conjunction |
p && q |
$p \lor q$ |
p or q |
disjunction |
`p |
$\top$ |
true |
truth |
true |
$\bot$ |
false |
falsity |
false |
$p \to q$ |
p implies q |
material conditional |
??? |
$p \leftrightarrow q$ |
p if and only if q |
biconditional |
??? |
Truth Table
Negating a proposition: de Morgan’s Laws
- $\lnot (p \land q) = \lnot p \lor \lnot q$
- $\lnot(p \lor q) = \lnot p \land \lnot q$
- pro tip in code: use de Morgan’s laws to do short-circuit evaluation. Prefer right side over left side in above equations for code.
Revisiting Proof Methods
- Contrapositive in a new light: $p \to q = \lnot q \to \lnot p$
- Another thing: you can assume $p$ is true to prove an implication, since if $p$ is false, then $p \to q$ is trivially true.
- Proof by contradiction: $(\lnot p \to \bot) \to p$