Formula Sheet: Based On Dave Tompkins's Awesome CPSC 121 Handout
Formula Sheet: Based On Dave Tompkins's Awesome CPSC 121 Handout
Prove P ≡ Q
p→q p is sufficient for q q is necessary for p P ≡ ... (LAW)
p↔q p is sufficient and necessary for q ≡ ... (LAW)
MUX s is a when c is false, b when c is true s ≡ (a ∧ ∼ c) ∨ (b ∧ c) ≡Q
1
based on Dave Tompkins’s Awesome CPSC 121 Handout
Powers of 2
20 21 22 23 24 25 26 27 28 29 210 211 212 213 214 215 216
1 2 4 8 16 32 64 128 256 512 1,024 2,048 4,096 8,192 16,384 32,768 65,536
Binary Representation
x3 x2 x1 x0 HEX unsigned signed x3 x 2 x1 x0 HEX unsigned signed
0 0 0 0 0 0 0 1 0 0 0 8 8 -8
0 0 0 1 1 1 1 1 0 0 1 9 9 -7
0 0 1 0 2 2 2 1 0 1 0 A 10 -6
0 0 1 1 3 3 3 1 0 1 1 B 11 -5
0 1 0 0 4 4 4 1 1 0 0 C 12 -4
0 1 0 1 5 5 5 1 1 0 1 D 13 -3
0 1 1 0 6 6 6 1 1 1 0 E 14 -2
0 1 1 1 7 7 7 1 1 1 1 F 15 -1
Rules of Inference
Modus Ponens: [M.PON] p→q Modus Tollens: [M.TOL] p→q
p ∼q
∴q ∴ ∼p
Generalization: [GEN] p Specialization: [SPEC] p∧q
∴p∧q ∴p
Conjunction: [CONJ] p Elimination: [ELIM] p∨q
q ∼q
∴p∧q ∴p
Transitivity: [TRANS] p→q Proof by cases: [CASE] p→r
q→r q→r
∴ p→r ∴ (p ∨ q) → r
Resolution: [RES] p∨q Contradiction: [CONT] p→F
∼p ∨ r ∴p
∴ (q ∨ r)
Argumets Validity
Premises: w
x (w ∧ x ∧ y) → z
y is a tautology
Conclusion: ∴z
Domains
Z Integers {· · · , −3, −2, −1, 0, 1, 2, 3, · · ·}
Z+ Positive Integers {x ∈ Z, x > 0}
Z∗ Non-zero Integers {x ∈ Z, x 6= 0}
Q Rational Numbers { ab | a ∈ Z, b ∈ Z∗ }
Q̄ Irrational Numbers {x ∈ R, x 6∈ Q}√
R Real Numbers {· · · , − 20
6
, 0, 1, 2, π, 100
3
, · · ·}
N0 Natural Numbers {0, 1, 2, 3, · · ·}
N1 {1, 2, 3, · · ·}
Quantifiers
∀x ∈ U, P (x) ⇒ P(x) is true for all (every) x in U
∃x ∈ U, P (x) ⇒ P(x) is true for at least one x in U
∼ ∀x ∈ D, P (x) ≡ ∃x ∈ D, ∼ P (x)
∼ ∃x ∈ D, P (x) ≡ ∀x ∈ D, ∼ P (x)
∀x ∈ D, Q(x) ≡ ∀x ∈ U, P (x) → Q(x)
∃x ∈ D, Q(x) ≡ ∃x ∈ U, P (x) ∧ Q(x)
Handy Predicates
Even(x) ⇔ ∃k ∈ Z, x = 2k
Odd(x) ⇔ ∃k ∈ Z, x = 2k + 1
P rime(x) ⇔ ∀k, m ∈ Z, (x = km) →((m = x) ∨ (m = 1))
Sets
A ⊆ B ⇔ ∀x ∈ U, (x ∈ A) →(x ∈ B) A = B ⇔ (A ⊆ B) ∧ (B ⊆ A)
A ∪ B = {x ∈ U | (x ∈ A) ∨ (x ∈ B)} A ∩ B = {x ∈ U | (x ∈ A) ∧ (x ∈ B)}
A − B = {x ∈ U | (x ∈ A) ∧ (x 6∈ B)} AC = {x ∈ U | (x 6∈ A)}
P(A) = {X ∈ U | X ⊆ A} A × B = {(a, b)|(a ∈ A) ∧ (b ∈ B)}
Function f : X → Y
X is the domain of f
Y is the co-domain of f
range or image of f = {y ∈ Y |∃x ∈ X, f (x) = y}
f is one-to-one (injective) ⇔ ∀x1 , x2 ∈ X, (f (x1 ) = f (x2 )) →(x1 = x2 )
f is onto (surjective) ⇔ ∀y ∈ Y, ∃x ∈ X, f (x) = y
f is a one-to-one correspondence (bijection) ⇔ (f is one-to-one) ∧ (f is onto)
Regular Expressions
. Matches any character
[xy] Matches one character from those listed
[x − z] Matches one character from the range of characters listed
[ˆxy] Matches one character from those not listed
| Matches one element from those separated by pipes
∗ Matches the previous element 0 or more times
+ Matches the previous element 1 or more times
? Matches the previous element 0 or 1 time
{m, n} Matches the preceding element from m to n times
\s Matches a whitespace character
\d Matches a digit, same as [0-9]
\w Matches an alphanumeric character, including “ ”