(Coequal in Order) (Coequal in Order)
(Coequal in Order) (Coequal in Order)
Prove that there exist irrational numbers p and q such pq is rational. The contrapositive of “if P then Q” is “if ~Q then ~P”. Prove that 7 is not colourful (an integer n is said to be colourful
1. We know from Theorem 4.7.1 (Epp) that √2 is irrational Both statements are logically equivalent. if there exists some integer k such that n = 3k).
√2
2. Consider √2 : it is either rational or unrational
Prove that if x 2 is irrational then x is irrational. 1. Suppose 7 is colourful.
3. Case 1: It is rational 2. Then, by definition of colourful, 7 = 3k for k ∈ Z
3.1 Let p = q = √2, and we are done
Proof Techniques
The disjunction of p and q is “p or q”, denoted as p ꓦ q. The converse of conditional statement “if p then q” is “if q then p”,
Definition 2.1.5 – Statement/Propositional Form denoted q → p. Definition 2.3.2 – Sound and Unsound Arguments
A statement/propositional form is an expression made up of statement An argument is sound if, and only if, it is valid and all
variables and logical connectives that becomes a statement when Definition 2.2.4 – Inverse (i.e. inverse error) its premises are true. Otherwise, it is unsound.
actual statements are substituted for the component statement The inverse of conditional statement “if p then q” is “if ~p then ~q”,
variables. denoted ~p → ~q.
Order of Operations
Definition 2.1.6 – Logical Equivalence Definition 2.2.5 – Only If
Two statements are logically equivalent only if they have identical truth Performed ~ (not)
If “p only if q”, it means “if not q then not p” or “if p then q”. first
values for each possible situation of statements for their statement
variables. The logical equivalence of p and q is denoted by p ≡ q. ꓥ (and), ꓦ (or)
Definition 2.2.6 – Biconditional {coequal in order}
Definition 2.1.7 – Tautology The biconditional of p and q is “p if, and only if q”, denoted p ↔ q. Performed → (if-then), ↔ (if, and only if)
A tautology is a statement form that is always true regardless of the last {coequal in order}
truth values of the individual statements substituted for its statement Definition 2.2.7 – Necessary and Sufficient Conditions
variables. The statement “p is a sufficient condition for q” means “if p then q”.
Definition 2.1.8 – Contradiction The statement “p is a necessary condition for q” means “if ~p then
A contradiction is a statement form that is always false regardless of ~q” or “if q then p”.
the truth values of the individual statements substituted for its
statement variables.
Theorem 2.1.1 – Logical Equivalences Table 2.3.1 – Rules of Inference
1 Commutative Laws pꓥq≡qꓥp pꓦq≡qꓦp 1 Modus Ponens p→q
p
2 Associative Laws (p ꓥ q) ꓥ r ≡ p ꓥ (q ꓥ r) (p ꓦ q) ꓦ r ≡ p ꓥ (q ꓦ r) ●q
A predicate is a sentence that contains a finite number of variables, and it becomes a statement when specific An existential statement is of the form “Ǝx ∈ D, such that Q(x)”. It is true if and only if
values are substituted for the variables. The domain of a predicate variable is the set of all values that may be Q(x) is true for at least one x in D. It is false if and only if Q(x) is false for at all x in D.
substituted in place of the variable.
Definition 3.1.2 – Truth Set Notation
If P(x) is a predicate and x has the domain D, the truth set is the set of all elements of D that make P(x) true when P(x) ⇒ Q(x): Every element in truth set of P(x) is in the truth set of Q(x), equivalently,
they are substituted for x. The truth set of P(x) is denoted {x ∈ D | P(x)}. “∀x, P(x) → Q(x)”.
Definition 3.1.3 – Universal Statement
P(x) ⇔ Q(x): P(x) and Q(x) have identical truth sets, equivalently, “∀x, P(x) ↔ Q(x)”.
A universal statement is of the form “∀x ∈ D, Q(x)”. It is true if and only if Q(x) is true for every x in D. It is false if
and only if Q(x) is false for at least one x in D. Such a value for x for which Q(x) is false is a counterexample.
Definition 3.2.1 – Contrapositive, Converse, Inverse Theorem 3.2.1 (Epp) – Negation of a Universal Statement Universal Modus Ponens
For statement “∀x ∈ D, if P(x) then Q(x)”: The negation of statement “∀x ∈ D, P(x)” is logically equivalent to ∀x, if P(x) then Q(x)
1. Contrapositive: “∀x ∈ D, if ~Q(x) then ~P(x)”. statement “Ǝx ∈ D, such that ~P(x)”. P(a) for a particular a.
2. Converse: “∀x ∈ D, if Q(x) then P(x)”. ● Q(a)
~(∀x ∈ D, P(x)) ≡ Ǝx ∈ D, such that ~P(x)
Logic of Quantified Statements
Definition 3.4.1 – Valid Argument Form Existential Instantiation Inverse Error (Quantified Form)
An argument is valid when no matter what particular predicates are substituted for If the existence of a certain kind of object is assumed or has been ∀x, if P(x) then Q(x)
the predicate symbols in its premises, if the resulting premise statements are all true, deduced then it can be given a name, as long as that name is not ~P(a) for a particular a.
then the conclusion is also true. An argument is valid if and only if its form is valid. currently being used to denote something else. ● ~Q(a)
(26 ∙ 0) + (27 ∙ 0)
the order in which the factors are written.
.
= (181)10 So (10110101)2 = (265)8 Take note there are multiple solutions to x and y (non-
Theorem 4.3.1 – Lower Bound uniqueness of Bézout’s Identity). Once a solution pair (x,
An integer b is said to be a lower bound for a set X ⊆ Z if b ≤ x for all Binary Notation – Base 2 to Base 16 (Hexadecimal) y) is found, additional pairs may be generated by
kb ka
x ∈ X. 0000 = 0 0001 = 1 0010 = 2 0011 = 3 (x + ,y- ), where k is any integer.
d d
0100 = 4 0101 = 5 0110 = 6 0111 = 7
Theorem 4.3.2 – Well Ordering Principle
1000 = 8 1001 = 9 1010 = A 1011 = B Definition 4.5.4 – Relatively Prime
If a non-empty set S ⊆ Z has a lower bound, then S has a least
1100 = C 1101 = D 1110 = E 1111 = F Integers a and b are relatively prime (or coprime) if, and
element.
i.e. (109)10 = (0110 1101)2 = (6D)16 only if, gcd(a, b) = 1.
Proposition 4.3.3 – Uniqueness of Least Element
If a set S of integers has a least element, then the least element is Definition 4.5.1 – Greatest Common Divisor Proposition 4.5.5
unique. Let a and b be non-zero integers. The greatest common divisor of a For any non-zero integers a and b, if c is a common divisor
and b, denoted gcd(a, b), is the integer d satisfying: of a and b, then c | gcd(a, b).
a. d | a and d | b
b. ∀c ∈ Z, if c | a and c | b, then c ≤ d
Definition 4.6.1 – Least Common Multiple Corollary 8.4.4 (Epp)
For any non-zero integers a and b, their least common multiple, denoted lcm(a, b), is the Let a, b and n be integers with n > 1. Then:
positive integer m such that: a. ab ≡ [(a mod n)(b mod n)] (mod n)
a. a | m and b | m b. am ≡ [(a mod n)m ] (mod n), for a positive integers m
b. ∀c ∈ Z, if a | c and b | c, then m ≤ c
Definition 4.7.2 – Multiplicative Inverse of Modulo n
Take note that gcd(a, b) x lcm(a, b) = ab. For any integers a and n with n > 1, if an integer s such that as ≡ 1 (mod n), then s is called the
Definition 4.7.1 – Congruence Modulo multiplicative inverse of a mod n, and the inverse may be written as a−1 .
Let m and n be integers, and let d be a positive integer. We say that m is congruent to n By commutative law (which still applies in modulo arithmetic),
modulo d, denoted as m ≡ n (mod d), if, and only if, d | (m – n). a−1 a ≡ 1 (mod n).
Number Theory
m ≡ n (mod d) ⇔ d | (m – n)
Theorem 4.7.3 – Existence of Multiplicative Inverses
Theorem 8.4.1 (Epp) – Modular Equivalences For any integer a, its multiplicative inverse modulo n (where n > 1) a−1 exists if, and only if, a and n are
Let a, b and n be any integers and suppose n > 1. The following statements are all equivalent: coprime.
a. n | (a – b)
b. a ≡ b (mod n) Corollary 4.7.4 – Special Case: n is Prime
c. a = b + kn, for some integer k If n = p is a prime number, then all the integers in the range 0 < a < p have multiplicative inverses
d. a and b have the same non-negative remainder when divided by n modulo p.
e. a mod n = b mod n
Theorem 8.4.9 (Epp)
Theorem 8.4.3 (Epp) – Modulo Arithmetic
For all integers a, b, c and n with n > 1 and a and n are coprime, if ab ≡ ac (mod n), then b ≡ c (mod n).
Let a, b, c, d and n be integers with n > 1 and suppose a ≡ c (mod n) and b ≡ d (mod n), then:
a. (a + b) ≡ (c + d) (mod n)
b. (a – b) ≡ (c – d) (mod n)
c. ab ≡ cd (mod n)
d. am ≡ c m (mod n), for all positive integers m
5.3.1 – Arithmetic Sequence 5.3.3 – Square Numbers 5.3.6 – Binomial Numbers (Pascal’s/Yang Hui’s Triangle) 5.4.0 – Solving Recurrences
Explicit Formula: an = a0 + nd Explicit Formula: □n = n2 1. Look it up.
n
Sum of first n terms: Sn = (2a + (n − 1)d)
2
5.3.4 – Triangle Numbers 2. Guess and check (aka iteration).
Sequences
n(n+1)
5.3.2 – Geometric Sequence Explicit Formula: △n =
2
Explicit Formula: an = a0 r n 3. Use formula (Theorem 5.8.1/5.8.3 (Epp)).
a(rn −1)
Sum of first n terms: Sn = 5.3.5 – Fibonacci Numbers
r−1
a (1+√5)n −(1−√5)n
Sum to infinity (where |r| < 1): S∞ = Explicit Formula: Fn = Explicit Formula (entry in nth row and kth column):
1−r 2n √5
n n−1 n−1
( )=( )+( )
k k−1 k
Definition 6.3.1 – Empty Set Proposition 6.3.3 Definition 6.3.4 – Power Set
An empty set has no element, and is denoted as ∅ or {}. For any two sets X and Y, X is a subset of Y and Y is a subset of X Given any set S, the power set of S, denoted by P(S), or 2S , is the
if, and only if, X = Y . set whose elements are all the subsets of S, nothing less and
Theorem 6.2.4 (Epp) – An Empty Set is a Subset of all Sets
∀X ∀Y ((Z ⊆ X ꓥ Z ⊆ Y) ↔ X = Y) nothing more. That is, given set S, if T = P(S), then:
Sets
Definition 8.1.1 – Ordered Pair Definition 8.1.3 – Cartesian Product Definition 8.2.3 – Image/Range
Let S be a non-empty set, and let x; y be two elements in S. The Let S and T be two sets. The Cartesian product (or cross product) of S The image (or the range) of R is the set Im(R) = {t ∈ T | ∃s ∈
ordered pair, denoted (x; y), is a mathematical object in which and T, noted S x T is the set such that: S (s R t)}.
the first element of the pair is x and the second element is y. ∀X ∀Y ((X, Y) ∈ S x T ↔ (X ∈ S) ꓥ (Y ∈ T))
Two ordered pairs (x, y) and (a, b) are equal if, and only if, x = a Definition 8.2.4 – Co-domain
and y = b. Definition 8.1.4 – Generalised Cartesian Product The co-domain of R is the set coDom(R) = T.
Given sets A1 , A2 , … , An , the Cartesian product of A1 , A2 , … , An,
Relations
Definition 8.1.2 – Ordered n-tuple denoted A1 × A2 × … × An, is the set of all ordered n-tuples Proposition 8.2.5
Let n be a positive integer and let x1 , x2 , … , xn be (not (a1 , a2 , … , an ) where a1 ∈ A1 , a2 ∈ A1 , . . . , an ∈ An . Let R be a binary relation. Then Im(R) ⊆ coDom(R).
necessarily distinct) elements. The ordered n-tuple,
(x1 , x2 , … , xn ), consists of x1 , x2 , … , xn together with the Definition 8.2.1 – Binary Relation Definition 8.2.6
ordering: first x1 , then x2 , and so forth up to xn . An ordered 2- Let S and T be two sets. A binary relation from S to T, noted R, is a Let S and T be sets. Let R ⊆ S x T be a binary relation. The
tuple is called an ordered pair, and an ordered 3-tuple is called subset of the Cartesian product S x T. inverse of the relation R, denoted R−1 , is the relation from
an ordered triple. T to S such that:
Definition 8.2.2 – Domain
∀s ∈ S, ∀t ∈ T (t R−1 s ↔ s R t)
The domain of R is the set Dom(R) = {s ∈ S | ∃t ∈ T (s R t)}.
Definition 8.2.7 Theorem 8.3.4 (Epp) – Partition Induced by an Equivalence Relation Hasse Diagrams
Let Si , for i = 1 to n, be n sets. An n-ary relation on the sets Si , Let R be an equivalence relation on a set A. Then the set of distinct
denoted R, is a subset of the Cartesian product ∏ni=1 Si . We call equivalence classes form a partition of A.
n the arity or degree of the relation.
Lemma 8.3.2 (Epp)
Definition 8.2.8 Let R be an equivalence relation on a set A and let a and b be two
Let S, T and U be sets. Let R ⊆ S x T be a relation. Let R’ ⊆ T x U elements in A. if a R b then [a] = [b].
be a relation. The composition of R with R’, denoted R’ o R, is
the relation from S to U such that: Lemma 8.3.3 (Epp)
∀x ∈ S, ∀z ∈ U (x R’ o R z ↔ (∃y ∈ T (x Ry ꓥ y R’ z)). If R be an equivalence relation on a set A and a and b are elements in
A, then either [a] ∩ [b] = ∅ or [a] = [b]. - Draw the directed graph so that all arrows point upwards.
Proposition 8.2.9 – Composition is Associative - Eliminate all self-loops.
Let S, T, U and V be sets. Let R ⊆ S x T be a relation. R’ ⊆ T x U Theorem 8.3.1 (Epp) – Equivalence Relation Induced by a Partition - Eliminate all arrows implied by the transitive property.
be a relation. Let R’’ ⊆ T x U be a relation. Given a partition S1 , S2 , … of a set A, there exists an equivalence - Remove the direction of the arrows.
R’’ o (R’ o R) = (R’’ o R’) o R = R’’ o R’ o R relation R on A whose equivalence classes make up precisely that
partition. Definition 8.6.3 – Comparable
Proposition 8.2.10 Let ≼ be a partial order on a set A. Elements a, b of A are
Let S, T, and U be sets. Let R ⊆ S x T be a relation. R’ ⊆ T x U be a Definition 8.5.1 – Transitive Closure said to be comparable if, and only if, either a ≼ b or b ≼ a.
relation. Let A be a set. Let R be a relation on A. The transitive closure of R, Otherwise, a and b are called noncomparable.
(R’ o R) −1 = R−1 o R′−1 denoted Rt , is a relation that satisfies these three properties:
1. Rt is transitive. Definition 8.6.4 – Total Order
Definition 8.3.1 – Reflexive 2. R⊆ Rt . Let ≼ be a partial order on a set A. ≼ is said to be a total
3. If S is any other transitive relation such that R⊆ S, then Rt ⊆ order if, and only if, ∀x, y ∈ A (x ≼ y ꓦ y ≼ x). In other
Relations
Definition 7.1.3 – Inverse Image (1) We also say that f is a surjection/onto. Let f : A → A be an injective function on A. Then f −1 o f = IA .
Let f : S → T be a function. Let y ∈ T. The inverse image of y is the Every dot in T has at least one incoming arrow.
set of all its pre-images: {x ∈ S | f(x) = y}. Definition 7.3.4 – n-ary Operation
Definition 7.2.3 – Bijective An n-ary operation on set A is a function f : ∏n1 A → A. n is
Definition 7.1.4 – Inverse Image (2) Let f : S → T be a function. f is bijective if, and only if, f called the arity or degree of the operation.
Let f : S → T be a function. Let U ⊆ T. The inverse image of U is is injective and f is surjective. We also say that f is a
the set of all the pre-images of all elements of U: bijection. Definition 7.3.5 – Unary Operation
{x ∈ S | ∃y ∈ U, f(x) = y}. Every dot in T has exactly one incoming arrow. An unary operation on a set A is a function f : A → A.
Definition 7.1.5 – Restriction Proposition 7.2.4 – Inverse Definition 7.3.6 – Binary Operation
Let f : S → T be a function. Let U ⊆ S. The restriction of f to U is Let f : S → T be a function and let f −1 be the inverse relation of f from A binary operation on a set A is a function f : A x A → A.
the set {(x, y) ∈ U x T | f(x) = y}. T to S. Then f is bijective if, and only if, f −1 is a function.
Definition – Sample Space Theorem 9.2.2 (Epp) – Permutations Theorem 9.4.1 (Epp)– The Pigeonhole Principle
A sample space is the set of all possible outcomes of a random process The number of permutations of a set with n ≥ 1 elements is n!. For any function f from a finite set X with n elements to
or experiment. a finite set Y with m elements, if n > m, then f is not
Theorem 9.2.3 (Epp) – r-permutations from a Set of n Elements one-to-one.
Notation If n and r are integers and 1 ≤ r ≤ n, then the number of r-
For a finite set A, N(A) denotes the number of elements in A. permutations of a set of n elements is given by the formulas Generalised Pigeonhole Principle: for any function f
n! from a finite set X with n elements to a finite set Y with
P(n, r) = n(n – 1)(n – 2)…(n – r + 1) or P(n, r) = (n−r)!
Equally Likely Probability Formula m elements and for any positive integer k, if k < n/m,
If S is a finite sample space in which all outcomes are equally likely and then there is some y ∈ Y such that y is the image of at
Counting & Probability
these vertices are numbered consecutively, then the the unique path between it and the root.
3. has a vertex of degree k; 8. is connected;
adjacency matrix of G has the form: 3. The height of a rooted tree is the maximum level
A1 O O 4. has m vertices of degree k; 9. has an Euler circuit;
O O of any vertex of the tree.
O A2 O ⋯ O O 5. has a circuit of length k; 10. has a Hamiltonian circuit.
O O A3 O O Definitions – Child, Parent, Sibling, Ancestor & Descendent
⋮ ⋮ Definition – Isomorphic
1. Given the root or any internal vertex v of a rooted
[O O O ⋯ O Ak ] If G and G' are simple graphs, then G is isomorphic to G' iff there exists a
tree, the children of v are all those vertices that
where each Ai is ni ni adjacency matrix of Gi, for all i = 1, 2, …, one-to-one correspondence g from the vertex set V(G) of G to the
are adjacent to v and are one level farther away
k, and the O’s represent matrices whose entries are all 0s. vertex set V(G') of G' that preserves the edge-endpoint functions of G
from the root than v.
and G' in the sense that for all vertices u and v of G, {u, v} is an edge in G
2. If w is a child of v, then v is called the parent of w,
Definition – nth Power of a Matrix {g(u), g(v)} is an edge in G'. and two distinct vertices that are both children of
For any n n matrix A, the powers of A are defined as follows: the same parent are called siblings.
1. A0 = I where I is the n n identity matrix 10.5 – Trees 3. Given two distinct vertices v and w, if v lies on the
2. An = A An – 1 for all integers n 1 Definitions – Circuit-Free, Tree, Trivial Tree & Forest unique path between w and the root, then v is an
1. A graph is said to be circuit-free if, and only if, it has no ancestor of w, and w is a descendant of v.
Theorem 10.3.2 (Epp) circuits.
If G is a graph with vertices v1, v2, …, vm and A is the adjacency 2. A graph is called a tree if, and only if, it is circuit-free and Definitions – Binary Tree & Full Binary Tree
matrix of G, then for each positive integer n and for all connected. 1. A binary tree is a rooted tree in which every
integers i, j = 1, 2, …, m, the ij-th entry of An = the number of 3. A trivial tree is a graph that consists of a single vertex. parent has at most two children. Each child is
walks of length n from vi to vj. 4. A graph is called a forest if, and only if, it is circuit-free and not designated either a left child or a right child (but
connected. not both), and every parent has at most one left
child and one right child.
Definitions – Terminal Vertex (Leaf) & Internal Vertex
2. A full binary tree is a binary tree in which each
Let T be a tree. If T has only one or two vertices, then each is called a
parent has exactly two children.
terminal vertex (or leaf). If T has at least three vertices, then a vertex of
degree 1 in T is called a terminal vertex (or leaf), and a vertex of degree
greater than 1 in T is called an internal vertex.
Definition – Left/Right Subtree 2. In-order (i.e. A, B, C, D, E, F, G, H, I) Definitions – Weighted Graph & Minimum Spanning Tree
Given any parent v in a binary tree T, if v has a left child, then 1. A weighted graph is a graph for which each edge
the left subtree of v is the binary tree whose root is the left has an associated positive real number weight.
child of v, whose vertices consist of the left child of v and all The sum of the weights of all the edges is the total
its descendants, and whose edges consist of all those edges of weight of the graph.
T that connect the vertices of the left subtree. The right 2. A minimum spanning tree for a connected
subtree of v is defined analogously. weighted graph is a spanning tree that has the
least possible total weight compared to all other
Theorem 10.6.1 (Epp) – Full Binary Tree Theorem
spanning trees for the graph.
If T is a full binary tree with k internal vertices, then T has a
3. If G is a weighted graph and e is an edge of G,
total of 2k + 1 vertices and has k + 1 terminal vertices (leaves).
then w(e) denotes the weight of e and w(G)
a. Traverse the left subtree by recursively calling the
Theorem 10.6.2 (Epp) denotes the total weight of G.
in-order function
For non-negative integers h, if T is any binary tree with height b. Print the data of the root (or current vertex)
h and t terminal vertices (leaves), then t 2h. Equivalently, Algorithm 10.7.1 – Kruskal
c. Traverse the right subtree by recursively calling the Input: G (a connected weighted graph with n vertices]
log2 t h. in-order function Algorithm:
Binary Tree Traversal 3. Post-order (i.e. A, C, E, D, B, H, I, G, F) 1. Initialize T to have all the vertices of G and no
Breadth-First Search: In breadth-first search (by E.F. Moore), it edges.
starts at the root and visits its adjacent vertices, and then 2. Let E be the set of all edges of G, and let m = 0.
moves to the next level. The figure below shows the order of 3. While (m < n – 1)
the vertices visited: a. Find an edge e in E of least weight.
Graphs & Trees
b. Delete e from E.
c. If addition of e to the edge set of T does not
produce a circuit, then add e to the edge set of T
and set m = m + 1
d. End while
a. Traverse the left subtree by recursively calling the Output: T (T is a minimum spanning tree for G]
post-order function
b. Traverse the right subtree by recursively calling the Algorithm 10.7.2 – Prim
Depth-First Search:
post-order function Input: G (a connected weighted graph with n vertices)
There are three types of depth-first traversal:
c. Print the data of the root (or current vertex) Algorithm:
1. Pre-order (i.e. F, B, A, D, C, E, G, I, H)
1. Pick a vertex v of G and let T be the graph with
10.7 – Spanning Trees & Shortest Paths this vertex only.
2. Let V be the set of all vertices of G except v.
Definition – Spanning Tree 3. For i = 1 to n – 1
A spanning tree for a graph G is a subgraph of G that contains every a. Find an edge e of G such that (1) e connects
vertex of G and is a tree. T to one of the vertices in V, and (2) e has the
Proposition 10.7.1 least weight of all edges connecting T to a
Every connected graph has a spanning tree. Also, any two spanning vertex in V. Let w be the endpoint of e that is
trees for a graph have the same number of edges. in V.
a. Print the data of the root (or current b. Add e and w to the edge and vertex sets of T,
vertex) and delete w from V.
b. Traverse the left subtree by recursively Output: T (T is a minimum spanning tree for G]
calling the pre-order function
c. Traverse the right subtree by recursively
calling the pre-order function
Algorithm 10.7.3 – Dijkstra
Input: G (a connected simple graph with positive weight for
every edge), (a number greater than the sum of the weights
of all the edges in G), w(u, v) (the weight of edge {u, v}), a (the
source vertex), z (the destination vertex).
Algorithm:
1. Initialize T to be the graph with vertex a and no
edges.
Let V(T) be the set of vertices of T, and let E(T) be
the set of edges of T.
2. Let L(a) = 0, and for all vertices in G except a, let L(u)
=.
Graphs & Trees