0% found this document useful (0 votes)
430 views

cs1231 Reference Cheat Sheet PDF

This document contains summaries of key concepts in logic, proofs, number theory, and predicate logic. It defines De Morgan's laws, rules of inference for conjunction, disjunction, contradiction, and conditional statements. It also covers predicates and quantified statements, including universal and existential statements. Valid arguments and fallacies are discussed. For number theory, it defines even and odd numbers and states the existence and uniqueness of the greatest common divisor, as well as Bézout's identity.

Uploaded by

Robert Fisher
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
430 views

cs1231 Reference Cheat Sheet PDF

This document contains summaries of key concepts in logic, proofs, number theory, and predicate logic. It defines De Morgan's laws, rules of inference for conjunction, disjunction, contradiction, and conditional statements. It also covers predicates and quantified statements, including universal and existential statements. Valid arguments and fallacies are discussed. For number theory, it defines even and odd numbers and states the existence and uniqueness of the greatest common divisor, as well as Bézout's identity.

Uploaded by

Robert Fisher
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

created by Syed Abdullah

CS1231: Reference • De Morgan’s laws: Rules of Inference (Wei Quan) – Stmt is false iff Q(x) false for at least
¬(p ∧ q) ≡ ¬p ∨ ¬q one x ∈ D
Proof Language ¬(p ∨ q) ≡ ¬p ∧ ¬q • Conjunction Intro – A, B, ∴ A ∧ B
• Existential Stmt (3.1.4):
• ∃!: Exists a unique... • Conjunction Elim – A ∧ B, ∴ A, B ∃x ∈ D, such that Q(x)
Conditional Statements
• ≡: Logical Equivalence: identical truth • Disjunction Intro – A, ∴ A ∨ B, B ∨ A – Equivlent to Q(x1 )∨Q(x2 )∨...∨Q(xn )
table (Definition 2.1.6) • p → q ≡ ¬p ∨ q – Stmt is true iff Q(x) true for at least
• Disjunction Elim :
• Contrapositive (Def 2.2.2): A ∨ B, A → C, B → C, ∴ C one x ∈ D
Order of Operations
p → q ≡ ¬q → ¬p – Stmt is false iff Q(x) false ∀x ∈ D
• ¬, followed by ∧∨, followed by →↔ • Contradiction Intro – A, ¬A, ∴ Cont.
• Converse (2.2.3): q → p • Implicit Quantification: =⇒ ⇐⇒
• Contradiction Elim:
Proving Methods • Inverse (2.2.4): ¬p → ¬q – P (x) =⇒ Q(x):
A → Contradiction, ∴ ¬A
truth set P (x) ⊂ truth set Q(x)
• Construction: just sub in all x ∈ D • p → q 6≡ (q → p ≡ ¬p → ¬q) • Double Negation Elim – ¬¬A, ∴ A – P (x) ⇐⇒ Q(x):
• Counterexample: show one condition • Only If (2.2.5): p only if q ≡ p → q truth set P (x) ≡ truth set Q(x)
that leads to contradiction
• Biconditional (2.2.6):
Fallacies
p ↔ q ≡ (p → q) ∧ (q → p)
Negation of Quantified Stmt
• Contraposition: • Converse Error: p → q, q, ∴ p
To prove P → Q, prove ¬Q → ¬P • Negation of Universal Stmt
• Necessary & Sufficient Cond (2.2.7): • Inverse Error: p → q, ¬p, ∴ ¬q
(Thm 3.2.1)
• Contradiction: To prove A, prove ¬A r necessary s ≡ r → s
is not true (Clearly this is absurd) r sufficient s ≡ ¬r → ¬s • Sound & Unsound Argument: Sound iff ∼ (∀x ∈ D, P (x)) ≡ ∃x ∈ D, s.t. ∼ P (x)
valid and premises are true
• Negation of Existential Stmt
Thm 2.1.1 Logical Equivalences Valid Arguments (Thm 3.2.1)
Predicates & Quantified Stmt
(Aaron, pp 21 - 22) • Argument (2.3.1): If all premise true, ∼ (∃x ∈ D, s.t. P (x)) ≡ ∀x ∈ D, ∼ P (x)
conclusion must be true • Predicate (3.1.1): A predicate sen-
• Commutative Law: p ∧ q ≡ q ∧ p tence contains a finite number of vari- Universal Conditional Stmt
• Syllogism: Two premises and one con- ables and becomes a stmt when specific
• Associative Law: clusion ∀x ∈ D, P (x) =⇒ Q(x)
values are subst in the vars. The do-
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r) (same with ∨)
• Modus Ponens: p → q, p, ∴ q main of a predicate var is the set of all • Vacuously True: iff P (x) false ∀x ∈ D
• Distributive Law: values that may be subst in place of the
• Modus Tollens: p → q, ¬q, ∴ ¬p var. • Contrapositive:
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
∀x ∈ D, ∼ Q(x) =⇒ ∼ P (x)
(swap ∨ & ∧)
• Truth Set (3.1.2): If P(x) is a predicate
Rules of Inference • Converse: ∀x ∈ D, Q(x) =⇒ P (x)
• Identity Law: p ∧ t ≡ p or p ∨ c ≡ p and Dx ≡ D, the truth set is the set of
• Generalization: p, ∴ p ∨ q all elements of D that make P (x) true • Inverse: ∀x ∈ D, ∼ P (x) =⇒ ∼ Q(x)
• Negation Law: p∨¬p ≡ t or p∧¬p ≡ c when they are subst for x. The truth set
• Specialization: p ∧ q, ∴ p • Refer to 2.2.5 and 2.2.7 for only if, nec-
• Double Negation Law: ¬(¬p) ≡ p of P (x) is {x ∈ D|P (x)}.
essary & sufficient conditions
• Elimination: p ∨ q, ¬p, ∴ q • Universal Stmt (3.1.3): ∀x ∈ D, Q(x)
• Idempotent Law: p ∧ p ≡ p (same for • Universal Modus Ponens & Tollens:
∨) • Transitivity: p → q, q → r, ∴ p → r ∀x ∈ D, P (x) =⇒ Q(x), P (a) for a ∈ D
– Equivalent to Q(x1 ) ∧ Q(x2 ) ∧ ... ∧
• Proof by Division into Cases: Q(x ) ∴ Q(a)
• Universal Bound Law: n
p ∨ q, p → r, q → r, ∴ r (∼ Q(a), ∴∼ P (a) for tollens)
p ∨ t ≡ t or p ∧ c ≡ c – Stmt is true iff Q(x) true ∀x ∈ D

Created using LATEX 2ε 1 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

CS1231: Number Theory • Existence of gcd (Prop 4.5.2): Appendix A (Epp)


For any a, b ∈ Z, not both zero, their gcd exists and
Def/Thm in Lecture Slides unique • T1 (Cancellation Law for Add): a+b = a+c =⇒ b = c

• Even & Odd (Def 1.6.1, Proofs Handout, TS): • Bézout’s Identity (Thm 4.5.3): • T2 (Possibility of Subtraction): Given a, b, ∃!x such that
Let a, b ∈ Z, not both zero, & d = gcd(a, b). a + x = b. This x is denoted by b − a.
n is even ⇐⇒ ∃k ∈ Z such that n = 2k Then, ∃x, y ∈ Z s.t.: • T3: b − a = b + (−a) T4: −(−a) = a
n is odd ⇐⇒ ∃k ∈ Z such that n = 2k + 1
ax + by = d • T5: a(b − c) = ab − ac T6: 0 · a = a · 0 = 0
• Divisibility (Def 1.3.1, PH):
• Relatively Prime/Coprime (Def 4.5.4): • T7 (Cancellation Law for Multiplication):
d | n ⇐⇒ ∃k ∈ Z, s.t. n = dk
a, b ∈ Z are coprime ⇐⇒ gcd(a, b) = 1 ab = ac, a 6= 0 =⇒ b = c
• Thm 4.1.1 (pg 4, Number Theory Week 4, TS) :
• Prop 4.5.5: • T8 (Possibility of Division):
∀a, b, c ∈ Z, if a | b & a | c, then ∀x, y ∈ Z, a | (bx + cy)
a, b ∈ Z, not both zero, if c is common divisor of a & b, Given a, b with a 6= 0, ∃!x such that ax = b. This x is
• Prop 4.2.2 (p9, NTW4, TS): then c | gcd(a, b) denoted b/a and is called the quotient of b and a
For any two primes p and p0 , if p | p0 then p = p0 • T9: a 6= 0 =⇒ b/a = b · a−1
• NTP2, p38: ∀a, b ∈ Z+ , a | b ⇐⇒ gcd(a, b) = a
• Thm 4.2.3 (pg 16, NTW4): • T10: a 6= 0 =⇒ (a−1 )−1 = a
• L.C.M. (Def 4.6.1, NTP2, p41):
If p is prime and x1 , x2 , ..., xn are any integers s.t.:
a, b ∈ Z \ {0}, their l.c.m, denoted lcm(a, b), is m ∈ Z+
• T11 (Zero Product Property): ab = 0 =⇒ a ∨ b = 0
p | x1 x2 ...xn , s.t.
• T12 (Rule for Multiplication with Negative Signs):
then p | xi for some xi (1 ≤ i ≤ n) a|m&b|m (3)
(−a)b = a(−b) = −(ab), (−a)(−b) = ab
∀c ∈ Z+ , if a | c & b | c, then m ≤ c (4) a −a a
• Lower Bound (Def 4.3.1, NTP2, p3): &− = =
b b −b
b ∈ Z is lower bound for set X ⊆ Z if b ≤ x, ∀x ∈ X • NTP2, p43: ∀a, b ∈ Z+ , gcd(a, b) | lcm(a, b) a ac
• T13 (Equivalent Fractions Property): = ; b, c 6= 0
• Well Ordering Principle (Thm 4.3.2, NTP2, p5): b bc
If non-empty set S ⊆ Z has lower/upper bound, then S Theorems By Epp a c
has a least/greatest element • T14 (Rule for Addition of Fractions): + =
b d
• Thm 4.3.1: ∀a, b ∈ Z+ , if a | b then a ≤ b ad + bc
• Uniqueness of least element (Prop 4.3.3, NTP2, p8): ; b, d 6= 0
bd
If set S ⊆ Z has least/greatest element, then • Thm 4.3.3: ∀a, b, c ∈ Z, if a | b and b | c then a | c
least/greatest elem is unique • T15 (Rule for Multiplication of Fractions):
• Thm 4.3.5: Given any integer n > 1, ∃k ∈ Z+ , distinct a c ac
primes p1 , p2 , ..., pk & positive integers e1 , e2 , ..., ek , s.t. · = , b 6= 0, d 6= 0
• Quotient-Remainder Thm (Thm 4.4.1): b d bd
Given any a ∈ Z & any b ∈ Z+ , ∃!q, r ∈ Z s.t.: • T16 (Rule for Division of Fractions):
n = pe11 pe22 pe33 ...pekk
a
a = bq + r & 0 ≤ r < b and any other exp for n as a product of prime numbers b ad
c = bc , b 6= 0, c 6= 0, d 6= 0
is identical to this (except ordering)
• G.C.D. (Def 4.5.1, NTP2, p21): √ d
Let a, b ∈ Z, not both zero, g.c.d. of a, b, gcd(a, b), is • Thm 4.7.1: 2 is irrational • T17 (Trichotomy Law): a < b, b < a or a = b, ∀a, b ∈ R
d ∈ Z satisfying:
• Prop 4.7.3: • T18 (Transitive Law): a < b, b < c =⇒ a < c
d|a&d|b (1) For any a ∈ Z and any prime p, if p | a then p - (a + 1)
• T19: a < b =⇒ a + c < b + c
∀c ∈ Z, if c | a & c | b then c ≤ d (2) • Thm 4.7.4: The set of primes is infinite

Created using LATEX 2ε 2 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

CS1231: Number Theories • Proposition 4.2.2 (NTW4) GCD/LCM


For any two primes p & p0 , if p | p0 then p = p0
Basics • Greatest Common Divisor (Def 4.5.1, NTP2):
• Proposition 4.7.3 (Epp) Let a, b be integers, not both zero. The greatest com-
• Even & Odd (Def 1.6.1, Proofs Handout, TS): For any a ∈ Z and any prime p, if p | a then p - (a + 1) mon divisor of a and b, denoted gcd(a, b), is the integer
d satisfying:
n is even ⇐⇒ ∃k ∈ Z such that n = 2k • The set of primes is infinite (Thm 4.7.4, Epp)
n is odd ⇐⇒ ∃k ∈ Z such that n = 2k + 1 (i) d | a and d | b
• Theorem 4.2.3 (pg 16, NTW4):
• The sum of two even Z is even (Thm 4.1.1, Epp) If p is prime and x1 , x2 , ..., xn are any integers s.t.: (ii) ∀c ∈ Z, if c | a and c | b, then c ≤ d

• Rational Number p | x1 x2 ...xn , • Existence of gcd (Prop 4.5.2, NTP2):


a
r ∈ Q ⇐⇒ ∃a, b ∈ Z, r = b & b 6= 0 For any integers a, b, not both zero, their gcd exists and
then p | xi for some xi (1 ≤ i ≤ n) is unique
• Every Z is a rational number (Thm 4.2.1, Epp)
• Unique Prime Factorization (Thm 4.3.5, Epp): • Bézout’s Identity (Thm 4.5.3, NTP2):
• The sum of any two rational numbers is rational Given any integer n > 1, ∃k ∈ Z+ , distinct primes
(Thm 4.2.2, Epp) Let a, b ∈ Z, not both zero, and let d = gcd(a, b). Then,
p1 , p2 , ..., pk & positive integers e1 , e2 , ..., ek , s.t. there exists x, y ∈ Z such that: ax + by = d
• The double of a rational number is rational
(Col 4.2.3, Epp) n = pe11 pe22 pe33 ...pekk • Relatively Prime/Coprime (Def 4.5.4, NTP2):
Integers a, b are (relatively prime)/coprime iff
and any other exp for n as a product of prime numbers
Divisibility gcd(a, b) = 1
is identical to this (except ordering)
• Divisibility (Def 1.3.1, PH): • Proposition 4.5.5 (NTP2):
d | n ⇐⇒ ∃k ∈ Z, s.t. n = dk Well Ordering Principle For any a, b ∈ Z, not both zero, if c is a common divisor
of a and b then c | gcd(a, b)
• Thm 4.1.1 (pg 4, Number Theory Week 4, TS) : • Lower Bound (Def 4.3.1, NTP2):
∀a, b, c ∈ Z, if a | b & a | c, then ∀x, y ∈ Z, a | (bx + cy) An integer b is said to be a lower bound for a set • Some Theorem (NTP2):
X ⊆ Z if b ≤ x for all x ∈ X ∀a, b ∈ Z+ , a | b ⇐⇒ gcd(a, b) = a
• Thm 4.3.1 (Epp): ∀a, b ∈ Z+ , if a | b then a ≤ b
• Thm 4.3.2 (Epp): d | 1, d is only 1, −1 • Well Ordering Principle (Thm 4.3.2, NTP2):
• Theorem in Assignment 1:
If a non-empty set S ⊆ Z has a lower/upper bound,
∀a, b ∈ Z, not both zero & d = gcd(a, b), then ad , db ∈
• Thm 4.3.3 (Epp): ∀a, b, c ∈ Z, if a | b & b | c then a | c then S has a least/greatest element
Z with no common divisor that is greater than 1
• Thm 4.3.4 (Epp): Any integer n > 1 is divisible by a • Uniqueness of least element (Prop 4.3.3, NTP2):
prime number If a set S of integers has a least/greatest element, then • Least Common Multiple (Def 4.6.1, NTP2):
the least/greatest element is unique For any non-zero integers a, b, their least common
multiple, denoted lcm(a, b), is the positive integer m
Prime Numbers such that:
• Definition of Prime Quotient-Remainder Theorem
n ∈ Z & n > 1 then, (i) a | m and b | m
• Quotient-Remainder Theorem (Thm 4.4.1, NTP2):
n is prime ↔ ∀r, s ∈ Z+ , n = rs → Given any a ∈ Z and any b ∈ Z+ , there exist unique in- (ii) ∀c ∈ Z+ , if a | c and b | c, then m ≤ c
((r = 1 ∧ s = n) ∨ (r = n ∧ s = 1)) tegers q, r such that:
+
n is composite ↔ ∃r, s ∈ Z s.t.
• Some other Theorem (NTP2, last page):
(n = rs) ∧ (1 < r < n ∧ 1 < s < n) a = bq + r and 0 ≤ r < b ∀a, b ∈ Z+ , gcd(a, b) | lcm(a, b)

Created using LATEX 2ε 3 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

Modulo Arithmetic • Existence of multiplicative inverse (4.7.3, NTP3):


For any a ∈ Z, its multiplicative inverse mod n (where
• Congruence Modulo (4.7.1, NTP3):
n > 1),a−1 , exists iff, a, n are coprime
Let m, n ∈ Z & d ∈ Z+ . m is congurent to n modulo d:
• Corollary 4.7.4 (n is prime):
m≡n (mod d) ⇐⇒ d | (m − n) If n = p is prime, then all a ∈ Z, 0 < a < p have multi-
plicative inverses mod p
• Modular Equivalences (8.4.1, Epp):
For a, b, n ∈ Z, n > 1. Then the following are equivalent: • Cancellation Law (8.4.9, Epp):
∀a, b, c, n ∈ Z, n > 1 and a, n coprime, if ab ≡ ac
1. n | (a − b) (mod n), then b ≡ c (mod n)
2. a ≡ b (mod n)
3. a = b + kn, k ∈ Z
4. a, b have same (non-negative) remainder when di-
vided by n
5. a mod n = b mod n

• Modulo Arithmetic (8.4.3, Epp):


Let a, b, c, d, n ∈ Z, n > 1 and suppose:

a ≡ c (mod n) & b ≡ d (mod n)

Then

1. (a ± b) ≡ (c ± d) (mod n)
2. ab ≡ cd (mod n)
3. am ≡ cm (mod n), ∀m ∈ Z+

• Corollary 8.4.4 (Epp):


For a, b, c ∈ Z, n > 1. Then,

ab ≡ [(a mod n)(b mod n)] (mod n)

If m ∈ Z+ , then,

am ≡ [(a mod n)m ] (mod n)

• Multiplicative inverse modulo n (4.7.2, NTP3):


For a, n ∈ Z, n > 1, if s ∈ Z, as ≡ 1 (mod n), then s
is the multiplicative inverse of a modulo n. We
write inverse as a−1 .
Since commutative law applies in modulo, a−1 a ≡ 1
(mod n).

Created using LATEX 2ε 4 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

CS1231: Sequences & Recursion


Definitions Common Sequences Solving Recurrences
• Sequences • Arithmetic Sequence (an = an−1 + d) • Second-order Linear Homogeneous Recurrence
Denote a seq. of numbers by: a0 , a1 , a2 , . . .. an = f (n), Relation with Constant Coefficients (Def 5.4.1,
for some fn f and n ∈ N. The indexing variable is n.  Slides)
a, if n = 0,
∀n ∈ N, an = This is a recurrence relation in the form:
an−1 + d, otherwise.
• Recursion Relations
Seq. relating an to its predecessors: an−1 , an−2 , . . . Explicit Formula: ak = Aak−1 + Bak−2 , ∀k ∈ Z≥k0
an = a + nd, ∀n ∈ N & a, r ∈ R where A, B ∈ R constants, B 6= and k0 ∈ Z constant
Summation & Product Closed Form: • Distinct-Roots Theorem (Thm 5.8.3, Epp):
n Suppose a sequence a0 , a1 , a2 , . . . satisfies a recurrence
• Summation: Sn = [2a + (n − 1)d], ∀n ∈ N & a, r ∈ R
2 relation
n
X
• Geometric Sequence (an = ran−1 ) ak = Aak−1 + Bak−2
ai = am + am+1 + . . . + an−1 + an = Sn , ∀n ∈ N
i=m for A, B ∈ R constants, with B 6= 0 and k ∈ Z≥2 . If

a, if n = 0, characteristic equation
n  ∀n ∈ N, an =
X 0, n<m ran−1 , otherwise.
ai = Pn−1 t2 − At − B = 0
( i=m ai ) + an otherwise Explicit Formula:
i=m
has two distinct roots r & s then a0 , a1 , a2 , . . . is given
an = arn , ∀n ∈ N & a, r ∈ R
• Product: by explicit formula
n
Closed Form:
Y an = Crn + Dsn , ∀n ∈ N
ai = am × am+1 × . . . × an−1 × an = Pn , ∀n ∈ N a(rn − 1)
Sn = , ∀n ∈ N, a, r ∈ R
i=m r−1 where C, D ∈ R as determined by initial conditions
a0 , a1
n  • Square Numbers (sum of first n odd numbers)
Y 1, n<m
ai = Qn−1 • Single-Roots Theorem (Thm 5.8.5, Epp):
( i=m ai ) · an otherwise Explicit Formula: ∀n ∈ N, n = n2
i=m Suppose a sequence a0 , a1 , a2 , . . . satisfies a recurrence
• Triangle Numbers (sum of first n + 1 integers) relation
• Theorem 5.1.1 (Epp): n(n + 1) ak = Aak−1 + Bak−2
If am , am+1 , . . . and bm , bm+1 , . . . are sequences of real Explicit Formula: ∀n ∈ N, 4n =
2
numbers and for any c ∈ R, then the following equations Interesting: for A, B ∈ R constants, with B 6= 0 and k ∈ Z≥2 . If
hold for any integer n ≥ m: characteristic equation
∀n ∈ Z+ , 4n + 4n−1 = n = (4n − 4n−1 )2
n n n t2 − At − B = 0
• Fibonacci Numbers
X X X
1. ak + bk = (ak + bk )
k=m k=m k=m has a single real root r then a0 , a1 , a2 , . . . is given by
∀n ∈ N, F0 = 0, F1 = 1, Fn = Fn−1 + Fn−2
n n explicit formula
X X
2. c· ak = c·ak (generalized distributive law) Explicit Formula:
an = Crn + Dnrn , ∀n ∈ N
k=m k=m n −n
φ − (−φ)
n
! n
! n ∀n ∈ N, Fn = √
Y Y Y 5 where C, D ∈ R as determined by the value a0 and any
3. ak · bk = (ak · bk ) √ other known value of the sequence
k=m k=m k=m where φ = (1 + 5)/2

Created using LATEX 2ε 5 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

CS1231: Sets Operation on Sets • Disjoint (Def 6.4.5, Slides):


S, T , being two sets, are disjoint iff S ∩ T = ∅
• Union (Def 6.4.1):
Basics Let S be a set of sets, then we say that T is the union
• Subset (Def 6.1.1, Slides): of the sets in S: • Mutually disjoint (Def 6.4.6, Slides):
S is subset of T (S is contained in T , T contains S) [ [ Let V be set of sets. The sets T ∈ V are mutually
T = S= X disjoint iff every two distinct sets are disjoint.
if all elements of S are elements of T . We write it as
X∈S
S⊆T
iff each element of T belongs to some set S, nothing less ∀X, Y ∈ V (X 6= Y → X ∩ Y = ∅)
• Empty set (Def 6.3.1, Slides): and nothing more. That is, given S, T is such that:
Empty set has no element, denoted by ∅ or {} (e.g. V = {{1, 2}, {3}, {{1}, {2}}})
∀Y ((Y ∈ T ) ↔ ∃Z((Z ∈ S) ∧ (Y ∈ Z)))
• Empty set is a subset of all sets (6.2.4, Epp):
∀X∀Z((∀Y ∼(Y ∈ X)) → (X ⊆ Z)) • Proposition 6.4.2 (Slides): • Partition (Def 6.4.7, Slides):
S S Let S be set and let V be a set of non-empty subsets of
– ∅ = A∈∅ A = ∅ S. V is a partition of S iff
• Set Equality (Def 6.3.2, Slides): S
Two sets are equal iff they have same elements in them – {A} = A
– A ∪ B = B ∪ A (commutative) 1. The sets in V are mutually disjoint
∀X∀Y ((∀Z(Z ∈ X ↔ Z ∈ Y )) ↔ X = Y )
– A ∪ (B ∪ C) = (A ∪ B) ∪ C (associative)
2. The union of the sets in V equals S.
N.B. duplicates and order does not matter! – A∪A=A
– A⊆B ↔A∪B =B
• Prop 6.3.3: • Non-symmetric difference (Def 6.4.8, Slides):
For any sets X, Y ; X ⊆ Y & Y ⊆ X iff, X = Y : • Intersection (Def 6.4.3, Slides): Let S, T be two sets. The difference (or relative com-
Let S be a non-empty set of sets. The intersection plement) of S and T , denoted S − T is the set whose
∀X∀Y ((X ⊆ Y ∧ Y ⊆ X) ↔ X = Y ) of the sets in S is the set T whose elements belong to elements belong to S and do not belong to T
all the sets in S, nothing less and more:

• Empty Set is Unique (Col 6.2.5, Epp): ∀Y ((Y ∈ T ) ↔ ∀Z((Z ∈ S) → (Y ∈ Z))) ∀X(X ∈ S − T ⇐⇒ (X ∈ S ∧ ∼(X ∈ T )))
∀X1 ∀X2 , ((∀Y (∼(Y ∈ X1 )) ∧ (∀Y ∼(Y ∈ X2 )) → X1 = X2 )
We write it as:
• Power Set (Def 6.3.4, Slides): \ \ • Symmetric Difference [XORing] (Def 6.4.9, Slides):
S T = S= X Let S, T be two sets. The symmetric difference of S
Given set S, the power set of S, denoted P(S) or 2 ,
X∈S and T , denoted S T is the set whose elements belong
is the set whose elements are all the subsets of S, noth-
ing less and nothing more. to S or T but not both
• Proposition 6.4.4 (Slides):
That is, given set S, if T = P(S), then
– A∩∅=∅ ∀X(X ∈ S T ↔ (X ∈ S ⊕ X ∈ T ))
∀X((X ∈ T ) ↔ (X ⊆ S) – A∩B =B∩A
– A ∩ (B ∩ C) = (A ∩ B) ∩ C (associative)
• No. of elements in Power Set (Thm 6.3.1, Epp) • Set Complement (Def 6.4.10, Slides):
– A⊆B ↔A∩B =A Let U be the Universal set, let A ⊆ U. Then, the com-
For all integers n ≥ 0, if a set X has n elements, then
P(X) has 2n elements. – A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) plement of A, denoted Ac , is U − As
– A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)

Created using LATEX 2ε 6 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

CS1231: Functions Properties of Functions Let f : S → T be a function. f is bijective iff f is


both injective and surjective. We can also say: f is
• Injective/One-to-One (Def 7.2.1, Slides): a bijection.
Basics S T
• Inverse (Prop 7.2.4, Slides):
• Function (Def 7.1.1, Slides): Let f : S → T be a function and f −1 be the inverse
S T relation o f from T to S. Then, f is bijective iff f −1 is
a function.
• Composition (Prop 7.3.1, Slides):
Let f : S → T and g : T → U be functions. The
composition of f and g, g ◦ f , is a function from S to
U.
Let f : S → T be a function. f is injective iff
• Identity Function (Def 7.3.2, Slides):
∀Y ∈ T, ∀x1 , x2 ∈ S((f (x1 ) = y ∧ f (x2 ) = y) → x1 = x2 ) Given a set A, define function IA from A to A by:
Let f be a relation such that f ⊆ S × T . Then f is We can also say: f is an injection or one-to-one (i.e.
function from S to T (f : S → T ) ∀x ∈ A(IA (x) = x)
every dot in T has AT MOST one incoming arrow)
• Surjective/Onto (Def 7.2.2, Slides): IA is the identity function on A
∀x ∈ S, ∃!y ∈ T (x f y)
S T • Composition of Inverse (Prop 7.3.3, Slides):
Let f : A → A be injective function on A. Thus,
f −1 ◦ f = IA
Basic Function Definitions
Generalization
• Pre-image (Def 7.1.2):
Let f : S → T be a function. Let x ∈ S and y ∈ T such • (n-ary) operation (Def 7.3.4, Slides):
that f (x) = y. Then, x is the pre-image of y An (n-ary) operation on a set A is a function f :
Yn
A → A. n is called the arity or degree of the op-
Let f : S → T be a function. f is surjective iff
• Inverse image (Def 7.1.3): 1
eration.
Let f : S → T be a function. Let y ∈ T . The ∀y ∈ T, ∃x ∈ S(f (x) = y)
inverse image of y is the set of all its pre-images: • Unary operation (Def 7.3.5, Slides):
{x ∈ S | f (x) = y} We can also say: f is a surjection or onto (i.e. every
A unary operation on a set A is a function f : A → A
dot in T has AT LEAST one incoming arrow)
• Binary operation (Def 7.3.6):
• Bijective (Def 7.2.3, Slides):
• Inverse image (Def 7.1.4): A binary operation on a set A is a function f :
Let f : S → T be a function. Let U ⊆ T . The inverse S T A×A→A
image of U is the set that contains all the pre-images
of all elements in U : {x ∈ S | ∃y ∈ U, f (x) = y}

• Restriction (Def 7.1.5):


Let f : S → T be a function. Let U ⊆ S. The restric-
tion of f to U is the set: {(x, y) ∈ U × T | f (x) = y}

Created using LATEX 2ε 7 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

CS1231: Relations • Co-domain (Def 8.2.4): • Symmetric (Def 8.3.2)


The co-domain (range) of R is the set R is symmetric ⇐⇒ ∀x, y ∈ A, (x R y → y R x)
Basic Definitions
coDom(R) = T • Anti-Symmetric (Def 8.6.1)
• Ordered Pair (Def 8.1.1):
R is anti-symmetric ⇐⇒ ∀x, y ∈ A, ((x R y ∧ y R
Let S be a non-empty set and let x, y ∈ S. The or-
• Inverse (Def 8.2.6): x) → x = y)
dered pair, denoted (x, y), is a mathematical object in
Let S, T be sets and R ⊆ S×T be a binary relation. The
which the first element is x and second element is y.
inverse of the relation R, denoted R−1 , is the relation • Asymmetric (Tutorial 7)
(x, y) = (a, b) ⇐⇒ x = a, y = b from T to S such that: R is asymmetric ⇐⇒ ∀x, y ∈ A, (x R y → y R x)

• Ordered n-tuple (Def 8.1.2) ∀s ∈ S, ∀t ∈ T (t R−1 s ↔ s R t) • Transitive (Def 8.3.3)


R is transitive ⇐⇒ ∀x, y, z ∈ A, ((x R y ∧ y R z) → x R z)
• Cartesian product (Def 8.1.3): • n-ary relation (Def 8.2.7):
Let S, T be two sets. The Cartesian product (cross Let Si , for i = 1 to n, be n sets. An n-ary relation • Equivalence Relations (Def 8.3.4):
product) of S & T , denoted S × T , is the set such that:
QnSi , denoted R, is a subset of the Cartesian
on the sets Let R be a relation on set A.
product i=1 Si . We call n the arity or degree of the R is called an equivalence relation iff R is reflexive,
∀X∀Y ((X, Y ) ∈ S × T ↔ (X ∈ S) ∧ (Y ∈ T ))
relation. symmetric and transitive.
N.B. Cartesian product is NOT commutative nor as- • Composition (Def 8.2.8):
sociative and size of S × T = size of S× size of T • Equivalence Class (Def 8.3.5):
Let S, T, U be sets. Let R ⊆ S × T be a relation. Let
Let x ∈ A and R be an equivalence relation on A. The
• Generalized Cartesian Product (Def 8.1.4): R0 ⊆ T × U be a relation. The composition of R with
equivalence class of x, denoted [x] is the set of all
If V is a set of sets, the Generalized Cartesian product R0 , denoted R ◦ R0 , is the relation from S to U such
elemetns y ∈ A that are in relation with x.
of its elements is: that:
Y
S [x] = {y ∈ A | x R y}
∀X ∈ S, ∀z ∈ U (x R0 ◦ R z ↔ (∃y ∈ T (x R y ∧ y R0 z)))
S∈V

• Binary relations (Def 8.2.1): • Associativity of Composition (Prop 8.2.9): • Partition induced by an equivalence relation
Let S, T be two sets. A binary relation from S to T , Let S, T, U, V be sets. Let R ⊆ S × T , R0 ⊆ T × U , (Thm 8.3.4, Epp):
denoted R, is a subset of the Cartesian product S × T R00 ⊆ U × V be relations. Therefore, Let R be an equivalence relation on a set A. Then, the
set of distinct equivalence classes form a partition of A.
N.B. s R t is (s, t) ∈ R and s R t is (s, t) 6∈ R R00 ◦ (R0 ◦ R) = (R00 ◦ R0 ) ◦ R = R00 ◦ R0 ◦ R
• Lemma 8.3.2, Epp:
Properties of Binary Relations • Proposition 8.2.10: Let R be an equivalence relation on a set A and let a, b
Let S, T, U be sets. Let R ⊆ S × T and R0 ⊆ T × U be be two elements in A. If a R b then [a] = [b]
Let R ⊆ S × T be a binary relation from S to T
relations.
• Domain (Def 8.2.2): (R0 ◦ R)−1 = |R−1 {z
◦ R0−1} • Lemma 8.3.3, Epp:
The domain of R is the set reversed order If R is an equivalence relation on a set A and a, b are
elements in A, then, either [a] ∩ [b] = ∅ or [a] = [b].
Dom(R) = {s ∈ S | ∃t ∈ T (s R t)} Properties of Relations on a Set
• Equivalence relation induced by a partition (Thm
Let A be a set and R ⊆ A × A be a relation. We say that
• Image (Def 8.2.3): 8.3.1, Epp):
R is a relation on A.
The image of R is the set Given a partition S1 , S2 , ... of a set A, there exists an
• Reflexive (Def 8.3.1) equivalence relation R on A whose equivalence classes
Im(R) = {t ∈ T | ∃s ∈ S(s R t)} R is reflexive ⇐⇒ ∀x ∈ A, (x R x) make up precisely that partition.

Created using LATEX 2ε 8 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

Additional Definitions Converting to Hasse:


• Transitive closure (Def 8.5.1) 1. Draw the directed graph so that all arrows point
Let A be a set, R be a relation on A. The transitive upwards
closure of R, denoted Rt is a relation that satisfies 2. Eliminate all self-loops
these three properties:
3. Eliminate all arrows implied by the transitive prop-
1. Rt is transitive erty
2. R ⊆ Rt 4. Remove the direction of the arrows
3. If S is any other transitive relation such that • Comparable (Def 8.6.3)
R ⊆ S, then Rt ⊆ S Let  be a partial order on a set A. Elements a, b ∈ A
• Repeated compositions are comparable iff either a  b or b  a. Otherwise,
Let R be a relation on a set A. We adopt the following a, b are noncomparable.
notation for the composition of R with itself: • Total Order (Def 8.6.4)
1
1. We define R , R Let  be a partial order on a set A.  is a total order
iff
2. We define R2 , R ◦ R
∀x, y ∈ A(x  y ∨ y  x)
3. We define Rn , R
J
| ◦ .{z
. . ◦ R} = i=1 to n R
i.e.  is a total order if  is a partial order and all x, y
n
are comparable
• Proposition 8.5.2
Let R be a relation on set A. Then • Maximal (Def 8.6.5)

An element x is a maximal element iff
[
Rt = Ri ∀y ∈ A, (x  y → x = y)
i=1
• Maximum (Def 8.6.6)
Partial & Total Orders An element, usually noted >, is the maximum ele-
• Partial Order (Def 8.6.2) ment iff
R is said to be a partial order iff it is reflexive, anti- ∀x ∈ A, (x  >)
symmetric and transitive • Minimal (Def 8.6.7)
N.B. Partial order is denoted by  (note the curl) An element x is a minimal element iff
• Hasse Diagrams ∀y ∈ A, (y  x → x = y)
To convert from left diagram to right diagram:
• Minimum (Def 8.6.8)
18 18 An element, usually noted ⊥, is the minimum ele-
9 ment iff
9
2 2 ∀x ∈ A, (⊥  x)
• Well Ordering of Total Orders (Def 8.6.9)
Let  be a total order on a set A. A is well ordered
3 3 iff every non-empty subset of A contains a minimum
1 1 element
N.B. Only works for partially ordered sets! ∀S ∈ P(A)(S 6= ∅ → (∃x ∈ S, ∀y ∈ S, (x  y)))

Created using LATEX 2ε 9 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

CS1231: Counting & Probability


Basic Definition • Possible Ways in Tree • Inclusion-Exclusion rule for 2 or 3 sets (Thm
Possible ways are represented by the distinct paths 9.3.3)
• Sample Space & Event
from ”root” (start) to ”leaf” (terminal point) in the tree If A, B, C are any finite sets, then
A sample space is the set of all possible outcomes of
a random process or experiment. An event is a subset
of a sample space. Permutation N (A ∪ B) = N (A) + N (B) − N (A ∩ B)

• Equally Likely Probability Formula • Definition and


If S is a finite sample space in which all outcomes are A permutation of a set of objects is an ordering of the
equally likely & E is an event in S, then the proba- objects in a row. N (A ∪ B ∪ C) = N (A) + N (B) + N (C) − N (A ∩ B)
bility of E, denoted P (E) is
• No of Permutations (Thm 9.2.2) − N (A ∩ C) − N (B ∩ C) + N (A ∩ B ∩ C)
No. of outcomes in E N (E) The number of permutations of a set with n (n ≥ 1)
P (E) = =
Total no. of outcomes in S N (S) elements is n!
Pigeonhole Principle
• Probability of the Complement of an Event • r-permutation
If S is a finite sample space and A is an event in S, then An r-permutation of a set of n elements is an ordered • Pigeonhole Principle
P (Ac ) = 1 − P (A) selection of r elements taken from the set. The num- A function from one finite set to a smaller finite set can-
ber of r-permutations of a set of n elements is denoted not be one-to-one: There must be at least 2 elements in
• Number of Elements in a List (Thm 9.1.1)
P (n, r) the domain that have the same image in the co-domain
If m, n ∈ Z and m ≤ n, then there are (n − m) + 1
integers from m to n inclusive
• r-permutations from a set of n elements (Thm • Pigeonhole Principle (Thm 9.4.1)
• Multiplication Rule (Thm 9.2.1) 9.2.3) For any function f from a finite set X with n elements
If an operation consists of k steps and If n, r ∈ Z and 1 ≤ r ≤ n, then the number of r- to a finite set Y with m elements, if n > m, then f is
the first step can be preformed in n1 ways permutations of a set of n elements is given by the not one-to-one.
the second step can be performed in n2 ways formula
(regardless of how first step was performed)
.. P (n, r) = n(n − 1) . . . (n − r + 1) • One-to-one and Onto for Finite Sets
. Let X, Y be finite sets with the same number of ele-
the kth step can be performed in nk ways or, equivalently ments and suppose f is a function from X to Y . Then
(regardless of how preceding steps was performed) f is one-to-one iff f is onto.
Then, the entire operation can be performed in n!
P (n, r) =
n1 × n2 × . . . × nk ways (n − r)! • Generalised Pigeonhole Principle
For any function f from a finite set X with n elements
Possibility Tree Counting Elements of Sets to a finite set Y with m elements and for any k ∈ Z+ ,
if k < n/m, then there is some y inY such that y is the
A A • Addition Rule (Thm 9.3.1) image of at least k + 1 distinct elements of X.
A A A Suppose a finite set A equals the union of k distinct mu-
B B tually disjoint subsets A1 , A2 , . . . , Ak . Then, N (A) =
B B • Contrapositive Form of GPP
N (A1 ) + N (A2 ) + . . . + N (Ak )
Start A A For any function f from a finite set X with n elements
A A • Difference Rule (Thm 9.3.2) to a finite set Y with m elements and for any k ∈ Z+ ,
B B B if for each y ∈ Y , f −1 (y) has at most k elements, then
If A is a finite set and B is a subset of A, then
B B X has at most km elements, i.e., n ≤ km
N (A − B) = N (A) − N (B)

Created using LATEX 2ε 10 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

Combinations unordered selection of elements taken from X with rep- • Expected Value
etition allowed. If X = {x1 , x2 , . . . , xn }, we write an r- Suppose the possible outcomes of an experiment, or
• r-combination
combination with repetition allowed as [xi1 , xi2 , . . . , xir ] random process, are real numbers a1 , a2 , . . . , an which
Let n, r be non-negative integers with r ≤ n. An r-
where each xij is in X and some of the xij may equal occur with probabilities p1 , p2 , . . . , pn . The expected
combination of a set of n elements is a subset of r of
each other value of the process is
the n elements. nr , denotes the no. of subsets of size
n
r, that can be chosen from a set of n elements. • No. of r-combinations with repetition (Thm 9.6.1) X
ak pk = a1 p1 + a2 p2 + . . . + an pn
 
n The no. of r-combination with repetition allowed
k=1
• Formula for (Thm 9.5.1) (multisets of size r) that can be selected from a set of n
r elements is • Conditional Probability
The no. of subsets of size r (r-combinations) that can 
r + n − 1

Let A and B be events in a sample space S. If P (A) 6= 0,
be chosen from a set of n elements, nr , is given by the

r then the conditional probability of B given A, de-
formula   noted P (B | A) is
n P (n, r) This equals the number of ways r objects can be selected
=
r r! from n categories of objects with repetitions allowed P (A ∩ B)
P (B | A) =
or, equivalently P (A)
• Pascal’s Formula (Thm 9.7.1)
+
 
n n! Suppose n, r ∈ Z & r ≤ n. Then • Bayes’ Theorem (Thm 9.9.1)
= Suppose that a sample space S is a union of mutually
r r!(n − r)!
     
n+1 n n
= + disjoint events B1 , B2 , . . . , Bn .
where n, r are non-negative integers with r ≤ n. r r−1 r Suppose A is an event in S, and suppose A and all the
• Permutations with sets of indistinguishable ob- Bi have non-zero probabilities.
• Binomial Theorem (Thm 9.7.2)
jects (Thm 9.5.2) If k ∈ Z with 1 ≤ k ≤ n, then
Given any a, b ∈ R and any non-negative integer n,
Suppose a collection consists of n objects of which P (A | Bk ) · P (Bk )
n   P (Bk | A) =
X n P (A | B1 ) · P (B1 ) + . . . + P (A | Bn ) · P (Bn )
n1 of type 1 & are indistinguishable from each other (a + b)n = an−k bk
n2 of type 2 & are indistinguishable from each other k
k=0 • Independent Events
..  
n

n

If A, B are events in a sample space S, then A and B
. = an + an−1 b1 + . . . + a1 bn−1 + bn
nk of type k & are indistinguishable from each other 1 n−1 are independent iff P (A ∩ B) = P (A) · P (B)

and suppose that n1 + n2 + . . . + nk = n. Then, the no. • Pairwise/Mutually Independent


Probability Let A, B, C be events in a sample space S. A, B, C are
of distinguishable permutations of the n objects is
     • Probability Axioms pairwise independent, iff, they satisfy conditions 1
n n − n1 n − n1 − n2 − . . . nk−1 - 3 below. They are mutually independent, if, they
... Let S be a sample space. A probability function P
n1 n2 nk from the set of all events in S to the set of real numbers satisfy all four conditions below.
n! satisfies the following axioms: For all events A and B
= 1. P (A ∩ B) = P (A) · P (B)
n1 !n2 ! . . . nk ! in S,
2. P (A ∩ C) = P (A) · P (C)
• No. of Partitions of a Set into r subsets 1. 0 ≤ P (A) ≤ 1 3. P (B ∩ C) = P (B) · P (C)
(Stirling numbers of the Second Kind) 2. P (∅) = 0 and P (S) = 1 4. P (A ∩ B ∩ C) = P (A) · P (B) · P (C)
Sn,r = no. of ways a set of size n can be partitioned 3. If A and B are disjoint (A ∩ B = ∅), then • Generalised Mutually Independent Definition
into r subsets P (A ∪ B) = P (A) + P (B) Events A1 , A2 , . . . , An in a sample space S are mutu-
ally dependent iff the probability of the intersection
• r-combination with repetition • Probability of a General Union of Two Events
of any subset of the events is the product of the proba-
An r-combination with repetition allowed, or mul- If A and B are any events in a sample space S, then
bilities of the events in the subset
tiset of size r, chosen from a set X of n elements is an P (A ∪ B) = P (A) + P (B) − P (A ∩ B)

Created using LATEX 2ε 11 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

CS1231: Graphs
Basic Definitions • Subgraph of a Graph Trails, Paths and Circuits
A graph H is said to be a subgraph of graph G, iff,
• Graph Let G be a graph and let v, w be vertices of G.
every vertex in H is also a vertex in G, every edge in H
A graph G consists of 2 finite sets: a nonempty set is also an edge in G, and every edge in H has the same • Walk
V (G) of vertices and a set E(G) of edges, where each endpoints as it has in G. A walk from v to w is a finite alternating sequence of
edge is associated with a set consisting of either one or
adjacent vertices and edges of G. Thus, a walk has the
two vertices called its endpoints. • Complete Bipartite Graphs
form
A complete bipartite graph on (m, n) vertices,
A edge is said to connect its endpoints; two vertices v0 e1 v1 e2 . . . vn−1 en vn
where m, n > 0, denoted Km,n , is a simple graph with
that are connected by an edge are called adjacent ver- distinct vertices v1 , v2 , . . . , vm and w1 , w2 , . . . , wn that where the v’s represent vertices, the e’s represent edges,
tices; and a vertex that is an endpoint of a loop is said satisfies the following properties: v0 = v, vn = w and for all i ∈ {1, 2, . . . , n}, vi−1 and vi
to be adjacent to itself. are the endpoints of ei
For all i, k = 1, 2, . . . , m and for all j, l = 1, 2, . . . , n,
An edge is said to be incident on each of its endpoints,
• Trivial Walk
and two edges incident on the same endpoint are called 1. There is an edge from each vertex vi to each vertex
A trivial walk from v to v consists of the single vertex v
adjacent edges. wj
We write e = {v, w} for an edge e incident on vertices 2. There is no edge from any vertex vi to any other • Trail
vertex vk A trail from v to w is a walk from v to w that does
v and w.
3. There is no edge from any vertex w to any other not contain a repeated edge
j
• Directed Graph vertex wl • Path
A directed graph, or digraph, G, consists of 2 finite A path from v to w is a trail that does not contain a
• Degree of a Vertex and Total Degree of a Graph
sets: a nonempty set V(G) of vertices and a set D(G) repeated vertex
Let G be a graph and v a vertex of G. The degree
of directed edges, where each edge is associated with
of v, denoted deg(v), equals the number of edges that • Closed Walk
an ordered pair of vertices called its endpoints.
are incident on v, with an edge that is a loop counted A closed walk is a walk that starts and ends at the
If edge e is associated with the pair (v, w) of vertices, twice. same vertex
then e is said to be the (directed) edge from v to w. The total degree of G is the sum of the degrees of all
We write e = (v, w). the vertices of G. • Circuit/Cycle
A circuit/cycle is a closed walk thtat contains at
• Simple Graph • Handshake Theorem (Thm 10.1.1) least one edge and does not contain a repeated edge
A simple graph is a undirected graph that does not If G is any graph, then the sum of the degrees of all
have any loops or parallel edges. the vertices of G equals twice the number of edges of G. • Simple Circuit/Cycle
Specifically, if the vertices of G are v1 , v2 , . . . , vn , where A simple circuit/cycle is a circuit that does not have
• Complement of Simple Graph (Tutorial 10) n ≥ 0, then any other repeated vertex except first and last
If G is a simple graph, the complement of G, denoted
Total degree of G = deg(v1 ) + deg(v2 ) + . . . + deg(vn ) • Triangle
G0 , is obtained as follows: The vertex set of G0 is identi-
cal to the vertex set of G. However, two distinct vertices = 2 · (the no. of edges of G) A simple circuit of length three is called a triangle
0
v and w of G are connected by an edge iff v & w are • Connectedness
• Corollary 10.1.2
not connected by an edge in G. Vertices v and w in graph G are connected iff there is
The total degree of a graph is even
a walk from v to w
• Complete Graph • Proposition 10.1.3
A complete graph on n vertices, n > 0, denoted Kn , In any graph there are an even numer of vertices of odd • Connected Graph
is a simple graph with n vertices and exactly one edge degree The graph G is connected, iff, given any two vertices
connecting each pair of distinct vertices. v and w in graph G, there is a walk from v to w

Created using LATEX 2ε 12 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

• Lemma on Connectedness • Theorem 10.2.4: USE THIS FOR EULER Matrix Representation of Graphs
Let G be a graph A graph G has an Euler circuit ⇐⇒ G is connected
• Matrix
and every vertex of G has positive even degree
1. If G is connected, then any two distinct vertices in An m × n matrix A over a set S is a rectangular array
G can be connected by a path of elements of S arranged into m rows and n columns
• Euler Trail
2. If vertices v and w are part of a circuit in G and Let G be a graph, and let v and w be two distinct ver- • Adjacency Matrix of a Directed Graph
one edge is removed from the circuit, then there tices of G. An Euler trail/path from v to w is a Let G be a directed graph with ordered vertices
still exists a trail from v to w in G sequence of adjacent edges and vertices that starts at v1 , v2 , . . . , vn . The adjacency matrix of G is the n×n
v, ends at w, passes through every vertex of G at least matrix A = (aij ) over the set of non-negative integers
3. If G is connected and G contains a circuit, then an
once, and traverses every edge of G exactly once. such that
edge of the circuit can be removed without discon-
nected G aij = the number of arrows from vi to vj
• Corollary 10.2.5
• Connected Component Let G be a graph and let v and w be two distinct ver- for all i, j = 1, 2, . . . , n.
A graph H is a connected component of a graph G tices of G. There is an Euler trail from v to w ⇐⇒ G
• Adjacency Matrix of an Undirected Graph
iff, is connected, v and w have odd degree, and all other
let G be an undirected graph with ordered verices
vertices of G have positive even degree.
1. The graph H is a subgraph of G v1 , v2 , . . . , vn . The adjacency matrix of G is the n×n
matrix A = (aij ) over the set of non-negative integers
2. The graph H is connected such that
3. No connected subgraph of G has H as a subgraph
Hamiltonian Circuits
aij = the number of edges connecting vi and vj
and contains vertices or edges that are not in H • Hamiltonian Circuit
Given a graph G, a Hamiltonian circuit for G is a for all i, j = 1, 2, . . . , n.
Euler Circuits simple circuit that includes every vertex of G. • Symmetric Matrix
That is, a Hamiltonian circuit for G is a sequence of ad- An n × n square matrix A = (aij ) is called symmetric
• Euler Circuit
jacent vertices and distinct edges in which every vertex ⇐⇒ for all i, j = 1, 2, . . . , n
Let G be a graph. An Euler circuit for G is a circuit
that contains every vertex and every edge of G. of G appears exactly once, except for the first and aij = aji
last, which are the same.
That is, an Euler circuit for G is a sequence of adja- (i.e. mirror image along main diagonal)
cent vertices and edges in G that has at least one edge, N.B. Hamiltonian circuit does not have to use all edges,
starts and ends at the same vertex, uses every vertex of but since it is a circuit, it cannot use the same edge more • Theorem 10.3.1
G at least once, and uses every edge of G exactly once. than once. Let G be a graph with connected componenets
G1 , G2 , . . . , Gk . If there are ni vertices in each con-
• Theorem 10.2.2 • Proposition 10.2.6 nected component Gi and these vertices are numbered
If a graph is an Euler circuit, then every vertex of the If a graph G has a Hamiltonian circuit, then G has a consecutively, then the adjacency matrix of G has the
graph has positive even degree subgraph H with the following properties: form:  
A1 O O O O
• Contrapositive of 10.2.2  O A2 O . . . O O 
1. H contains every vertex of G 
 O O A3 O O

If some vertex of a graph has odd degree, then the graph  
does not have an Euler circuit 2. H is connected
 .. .. .. 
 . . . 
• Theorem 10.2.3 3. H has the same number of edges as vertices O O O ... O Ak
If a graph G is connected and the degree of every ver- where each Ai is ni × ni adjacency matrix of Gi for all
tex of G is a positive even integer, then G has an 4. Every vertex of H has degree 2 i = 1, 2, . . . , k, and the O’s represent matrices whose
Euler circuit entries are all 0s

Created using LATEX 2ε 13 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

• Scalar Product • Identity Matrix II 4. has m vertices of degree k


Suppose that all entries in matrices A and B are real For any n × n matrix A, the powers of A are defined 5. has a circuit of length k
numbers. If the number of elements, n, in the ith row of as follows:
0 6. has a simple circuit of length k
A equals the number of elements in the jth column of A = I where I is the n × n identity matrix
n n−1
B, then the scalar product or dot product of the ith A = AA for all integers n ≥ 1 7. has m simple circuits of length k
row of A and the jth column of B is the real number 8. is connected
• No. of walks in Adjacency Matrix (Thm 10.3.2)
obtained as follows
  If G is a graph with vertices v ,
1 2 v , . . . , v m and A is the 9. has an Euler circuit
b1j adjacency matrix of G, then for each n ∈ Z+ and for all
10. has a Hamiltonian circuit
   b2j 
 integers i, j = 1, 2, . . . , m, the ij-th entry of An = the
ai1 ai2 . . . ain  .  = ai1 b1j +ai2 b2j +. . .+ain bnj number of walks of length n from vi to vj .
 ..  • Graph Isomorphism for Simple Graphs
bnj If G and G0 are simple graphs, then G is isomorphic
Isomorphisms of Graphs to G0 ⇐⇒ there exists a one-to-one correspondence
• Matrix Multiplication g from vertex set V (G0 ) of G0 that preserves the edge-
• Isomorphic Graph endpoint functions of G and G0 in the sense that for all
Let A = (aij ) be an m × k matrix and B = (bij ) an
Let G and G0 be graphs with vertex sets V (G) and vertices u and v of G,
k × n matrix with real entries. The (matrix) product of
V (G0 ) and edge sets E(G) and E(G0 ) respectively. G
A times B, denoted AB, is the matrix (cij ) defined as
is isomorphic to G0 ⇐⇒ there exist one-to-one cor- {u, v} is an edge in G ⇐⇒ {g(u), g(v)} is an edge in G0
follows: 0 0
 ..  respondences g : V (G) → V (G ) and h : E(G) → E(G )
c11 c12 . . . c1j . c1n  that preserve the edge-endpoint functions of G and G0
 ..  in the sense that for all v ∈ V (G) and e ∈ E(G),
c21 c22 . . . c2j . c2n 
 .. .. .. .. 
 
 . . . .  v is an endpoint of e ⇐⇒ g(v) is an endpoint of h(e).
 
 ci1 ci2 . . . cij ... cin  • Graph Isomorphism is an Equivalence Relation
 
(Thm 10.4.1)
 
 . .. .. .. 
 ..

 . . .  Let S be a set of graphs and let R be the relation of
.. graph isomorphism on S. Then, R is an equivalence
ck1 ck2 . . . c1j . ckn
relation on S.
where
X k • Self-Complementary Graph (Tutorial 10)
cij = ai1 b1j + ai2 b2j + . . . + aik bkj = air brj A self-complementary graph is isomorphic with its
r=1 complement
for all i = 1, 2, . . . , m and j = 1, 2, . . . , n. • Invariant-ness
• Identity Matrix A property P is called an invariant for graph isomor-
For each n ∈ Z+ , the n × n identity matrix, denoted phism ⇐⇒ given any graphs G ad G0 , if G has property
In = (δij ) or just I, if the size of matrix is obvious from P and G0 is isomorphic to G, then G0 has property P .
context, is the n × n matrix in which all the entries in • Invariants for Graph Isomorphism (Thm 10.4.2)
the main diagonal are 1’s and all other entries are 0’s. Each of the following properties is an invariant for graph
In other words, isomorphism, where n, m, k are all non-negative integers
(
1, if i = j 1. has n vertices
δij =
0, if i 6= j 2. has m edges
for all i, j = 1, 2, . . . , n. 3. has a vertex of degree k

Created using LATEX 2ε 14 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

CS1231: Trees • Level • Full Binary Tree Theorem (Thm 10.6.1)


The level of a vertex is the number of edges along the If T is a full binary tree with k internal vertices, then
Basic Definition unique path between it and the root T has a total of 2k + 1 vertices and has k + 1 terminal
vertices (leaves)
• Circuit-Free • Height
A graph is said to be circuit-free ⇐⇒ it has no The height of a rooted tree is the maximum level of • Maximum no. of terminal vertices (Thm 10.6.2)
circuits any vertex of the tree For non-negative integers h, if T is any binary tree with
height h and t terminal vertices (leaves), then
• Tree
• Children
A graph is said to be a tree ⇐⇒ it is circuit-free and t ≤ 2h
Given the root or any internal vertex v of a rooted tree,
connected
the children of v are all those vertices that are adjacent Equivalently: log2 t ≤ h
• Trivial Tree to v and are one level farther away from the root than
A trivial tree is a graph that consists of a single vertex v
Binary Tree Traversal
• Forest • Parent • Breath-First Search
A graph is called a forest ⇐⇒ it is circuit-free and If w is a child of v, then v is called the parent of w, In BFS, start at the root and visit the adjacent vertices,
not connected and two distinct vertices that are both children of the then move on to the next level
same parent are called sibilings
• Minimum vertex of non-trivial tree (Lem 10.5.1) • Depth-First Search
Any non-trivial tree has at least one vertex of degree 1 • Ancestor/Descendant There are three kinds of DFS, pre-order, in-order and
Given two distinct vertices v and w, if v lies on the post-order.
• Terminal vertex (leaf ) & internal vertex
unique path between w and the root, then v is an an-
Let T be a tree. If T has only one or two vertices, then Pre-Order
cestor of w, and w is a descendant of v
each is called a terminal vertex (or leaf ). If T has
at least three vertices, then a vertex of degree 1 in T – Print the data of the root (or current vertex)
is called a terminal vertex (or leaf ), and a vertex of Binary Trees – Traverse the left subtree by recursively calling the
degree greater than 1 in T is called an internal vertex. pre-order f (x)
• Binary Tree
• Theorem 10.5.2 – Traverse the right subtree by recursively calling
A binary tree is a rooted tree in which every parent
Any tree with n vertices (n > 0) has n − 1 edges the pre-order f (x)
has at most two children. Each child is designated
either a left child or a right child (but not both), and In-Order
• Lemma 10.5.3 every parent has at most one left and one right child.
If G is any connected graph, C is any circuit in G, and – Traverse the left subtree by recursively calling the
one of the edges of C is removed from G, then the graph • Full Binary Tree pre-order f (x)
that remains is still connected A full binary tree is a binary tree in which each parent – Print the data of the root (or current vertex)
has exactly two children
• Determining a Tree (Thm 10.5.4) – Traverse the right subtree by recursively calling
If G is a connected graph with n vertices and n − 1 • Left/Right Subtree the pre-order f (x)
edges, then G is a tree Given any parent v in a binary tree T , if v has a left Post-Order
child, then the left subtree of v is the binary tree whose
Rooted Trees root is the left child of v, whose vertices consist of the – Traverse the left subtree by recursively calling the
left child of v and all its descendants, and whose edges pre-order f (x)
• Rooted Tree
consists of all those edges of T that connect the vertices – Traverse the right subtree by recursively calling
A rooted tree is a tree in which there is one vertex
of the left subtree the pre-order f (x)
that is distinguished from the others and is called the
root The right subtree of v is defined analogously – Print the data of the root (or current vertex)

Created using LATEX 2ε 15 License: Creative Commons BY-NC-SA 4.0 International License.
created by Syed Abdullah

Spanning Trees & Shortest Paths • Prim’s Algorithm (Alg 10.7.2) – D(u) ← v
Input: G [a connected weighted graph with n vertices] (c) Find a vertex x in F with the smallest label.
• Spanning Tree
Algorithm: Add vertex x to V (T ), and add edge {D(x), x}
A spanning tree for a graph G is a subgraph of G that
contains every vertex of G and is a tree to E(T ). v ← x
1. Pick a vertex v of G and let T be the graph with
this vertex only Output: L(z) [this is the length of the shortest path
• Proposition 10.7.1
2. Let V be the set of all vertices of G except v. from a to z]
1. Every connected graph has a spanning tree 3. For i = 1 to n − 1
2. Any two spanning trees for a graph have the same (a) Find an edge e of G such that (1) e connects
no. of edges T to one of the vertices in V , and (2) e has
the least weight of all edges connecting T to a
• Weighted Graph vertex in V . Let w be the endpoint of e that
A weighted graph is a graph for which each edge has is in V
an associated positive real number weight. The sum
(b) Add e and w to the edge and vertex sets of T ,
of the weights of all edges is the total weight of the
delete w from V .
graph
Output: T [T is the MST for G]
• Minimum Spanning Tree
A minimum spanning tree for a connected weighted • Dijkstra’s Algorithm (Alg 10.7.3)
graph is a spanning tree that has the least possible to- Input: G [a connected weighted graph with positive
tal weight compared to all other spanning trees for the weight for every edge], ∞ [a no. greater than the sum
graph of the weights of all the edges in G], w(u, v) [the weight
of edge {u, v}], a [the source vertex], z [the dest vertex]
• w(e) & w(G) Algorithm:
If G is a weighted graph and e is an edge of G, then
w(e) denotes the weight of e and w(G) denotes the 1. init T to be the graph with vertex a and no edges.
total weight of G Let V (T ) be the set of vertices of T , and let E(T )
be the set of edges of T
• Kruskal’s Algorithm (Alg 10.7.1)
Input: G [a connected weighted graph with n vertices] 2. Let L(a) = 0, and for all vertices in G except a, let
Algorithm: L(u) = ∞ [The number L(x) is called the label of
x]
1. Init T to have all the vertices of G and no edges 3. Init v to equal a and F to be {a}. [The symbol v
2. Let E be the set of all edges of G, and let m = 0 is used to denote the vertex most recently added
to T ]
3. While (m < n − 1)
4. Let Adj(x) denote the set of vertices adjacent to
(a) Find an edge e in E of least weight vertex x
(b) Delete e from E
5. while (z 6∈ V (T ))
(c) If addition of e to the edge set of T does not
produce a circuit, then add e to the edge set (a) F ← (F − {v}) ∪ {vertices ∈ Adj(v) and
of T and set m = m + 1 6∈ V (T )} [Set F is set of fringe vertices]
(b) For each vertex u ∈ Adj(v) and 6∈ V (T ),
4. End While
– If L(v) + w(v, u) < L(u) then
Output: T [T is the MST for G] – L(u) ← L(v) + w(v, u)

Created using LATEX 2ε 16 License: Creative Commons BY-NC-SA 4.0 International License.

You might also like