Cheat Sheet
Cheat Sheet
Direct Proof: base on showing that p -> q is true Rooted Tree: directed tree, only one vertex R call root, have path from R
1. assuming p is T 2. to show that q must also be T to every vertex
A is root (depth or path length = 0) B A ancestors of E & F
Proof by Contraposi4ve: base on showing that -q -> -p is true - (height of a tree = 3) E F are sibling
1. Assume -q is T 2. to show that -p must also be T B parent of D (depth or path length = 1) B D interna; nodes.
- (height = 2) C E F external node
Proof by Contradic4on: assume the statement is false, then show this assump4on lead to a false C children of A (height = 0)
Injective . Surjective bijective is function not function 1. assume –p is T 2. to show –p is F 3. conclude wrong to assume p is F, p must be T m-ary tree is a rooted tree each vertex has m or fewer children (Binary = 2, Ternary = 3 )
one-to one correspondence
m-ary regular tree every internal node has exactly m children, at most mh vertices at level h
Principle of Mathema4cal Induc4on: Binary search tree: calculate middle = floor(min+max), height of tree = ceiling(log2(N+1))
1. Basis Step: Verify that P(1) is T 2. Assume P(k) is T 3. Induc4ve Step show P(K+1) is T
Then we can show that the condi4onal statement P(k) -> P(k+1) is T for all posi4ve integers k. Rela4on: always use R to refer to a rela4on , 𝑅̸ for not relate to, if x is related to y , we write x R y
(Complementation law)
- Sets A & B, binary rela4on from A to B is a subset of a Cartesian product A X B
Strong Induction:
- R⊆ A x B means R is a set of ordered pairs of the form (x,y) where x ∈ A and y ∈ B.
1. Basis Step: Verify that P(1) is T 2. Assume P(1) - P(k) is T 3. Inductive Step show P(K+1) is T
- (x, y)∈ R means x R y (x is related to y)
Then we can show that the conditional statement P(k) -> P(k+1) is T for all positive integers k.
- Rela4on matrix similar to adjacent matrix 1 represent related to but 0 not
Combining Rela4on: same as set theory
f: A -> B ( x in A -> f(x) = y in B Well-ordering Property: is an axiom about N we assume to be T.
1. The number 1 is a positive integer. 2: If n in N, then n+1, the successor of n, is also a
- Join = union of 2 matrix. Meet = intersec4on of 2 matrix
A: Domain of f. (Df = A). B: Co-domain of f (co-Df=B) Set contain all output: Range (Rf)
positive integer. 3. Every positive integer other than 1 is the successor of a positive integer. Rela4ons à Diagraph: When (a, b)∈ R arrows are drawn from a to b
y is image of x, x is pre-image of y ie. f(-1) = f(1) = 1, pre-images of 1 = {-1, 1}
4. the well –ordering property: every nonempty subset of the set of positive integers has at
For Example: Let A = {1, 2, 3, 4, 5} (x, y)∈ R iff x < y
Linear function f(x) = mx + c least 1 element.
- ( m > 0 increasing | m < 0 decreasing) Reflexive: R of a set S is said to be reflexive iff xRx , ∀x ∈ S. (x, x) ∈ R , ∀x ∈ S
Quadratic function f(x) = ax2+bx+c Mathematical induction -> well-ordering property -> strong induction -> mathematical induction - The diagraph of a reflexive rela4on on elements in a set S contains a loop on every element of S.
= Exponential function f(x) = bx where b > 0 and b ≠ 1 - Matrix of a reflexive rela4on, which all the values of the diagonal of Matrix are equal to 1
- (exponential growth when b > 1) Linear Recurrence : each term of a sequence is a linear function of earlier terms Symmetry: R of a set S is said to be symmetry iff ∀a, b ∈ S if aRb then bRa
= - The diagraph of a symmetry rela4on will have cycle between both elements
- (exponential decay when 0 < b < 1) - Linear homogenous recurrences as an = c1an-1 +…+ckan-k (c1, …ck)in R, k is degree of relation
Logarithmic function Growth Decay - Linear non homogenous as an = c1an-1 +…+ckan-k + f(n) where (c1, …ck)in R f(n) is a function and - The adjacency matrix of a symmetric rela4on is symmetric.
- logbx = y iff x = bx where b > 0 and b ≠ 1 k is the degree of the relation. An4-symmetric: R of a set S is said to be an4-symmetric iff ∀a, b ∈ S if aRb and bRa then a=b
(logbx is the inverse of x = bx ) - The digraph of an an4-symmetric rela4on on elements in a set S contains no parallel edges
Define and conquer recurrence: 1. Divide problem to smaller subproblem 2. solving each between any 2 difference ver4ces. (if i≠ j and mij≠ 0, then mji = 0)
problem (recursively, 3. combine solu4on to find a solu4on to original problem. Transi4vity: A rela4on R on set S is called transi4ve iff ∀a, b, c ∈ S if, if(aRb, bRc) then aRc
(Complement law) Composi4on (f o g)(x) = f(g(x)) is not commuta4ve
Equivalence rela4on: R is an equivalence rela4on iff R is reflexive, symmetric and transi4ve.
Bijec4ve func4on is also an inver4ble func4on Characteris4c equa4on: is the first setup finding a solu4on to linear recurrence Equivalence class: R be an equivalence rela4on on set S, equivalence class of a ∈ S is :
Tautology = Always True let an = c1an-1+…+ ckan-k be a linear homogenous recurrence If combina4on of geometric - The subset of S containing all the elements related to a through ‘R’ [a] = { x: x ∈ S and x R a}
p->q = ¬𝑝 ∨ 𝑞 (Condi4onal disjunc4on Equivalences) (f o f-1 ) (x) = (f-1 o f) = x
Contradic4on = Always False sequence an=rn is solu4on to this recurrence, rn = c1rn-1+…ckrn-k By dividing both side by rn-k, we Example: Z = {1, 2, 3, 4, 5} R = {(a, b) ∈ Z2 |a-b is even number} [1]=[3]=[5]={1, 3, 5} [2]=[4]={2,4}
Let f: A->B,
if f is inver4ble, then f-1 exists f-1 : B -> A get rk = c1rk-1+…ck fn = fn-1 + fn-2 -> r2=+r+1 -> r2-r-1=0 -> fn = a1r1n + a2r2n. Par4al order: R is a par4al order iff R is reflexive, an4-symmetric and transi4ve.
f and f-1 are symmetric with respect to y = x an=-3an-1-3an-2-an-3 -> r3+3r2+3r+1=0 -> r1=-1 one dis4nct root an= (b0+b1n+b2n2)r1n Total order: R is a par4al order and ∀a, b ∈ S we have with aRb or bRa
NOT OR AND XOR NAND
Show Graph G= (V,E): Contain non empty set of ver4ces (node, point) and edge (path, connec4on)
Directed graph (digraph) (V,E) order pair (u,v) start at u and end at v. Pigeonhole principle: if N objects placed into k boxes, at least 1 box containing ceiling(N/k) object.
n ≤ x < n+1 Adjacent: ver4ces with same edges. Incident: rela4on between connected edge and ver4ces (prove by contraposi4ve, assume no boxes contain more than ceiling(N/K)-1 objects
floor(x) = n Walk: sequence of ver4ces and edges of a graph (V & E can be repeated) Example: 52 cards, 4 suits, need 5 cards same suit ceiling(N/4)≥ 5 N is number of card selected
Walk of length k: the walk contain k edges (ie. v1v2,v2v4,v4v7 = e1,e2,e4 = v1, v2, v4)
Trial: a walk with no edge repeat, ver4ces can. Circuit: Close Trial R-permuta4on: P(n, r)
Path: trail with no edge or ver4ces repeat. Cycle: close path R-combina4on: C(n, r) =
Truth set: p be a proposition on a set S, truth set of p is the set of elements of S for which p is T. Eulerian Path: use each edge precisely once, the graph is called traversable. -also know as binomial coefficient
Hamiltonian Path: path visit each vertex exactly once, the graph is call traceable graph Binomial theorem
Negation ¬ | Conjunction ∧ | Disjunction ∨ | Exclusive or ⨁ Hamiltonian cycle: Close Hamiltonian pat, the graph is call Hamiltonian graph
Connected: undirected graph which any node to any other by following a sequence of edges
Implication A: p -> q if. P then q, Strongly Connected: directed graph if there is a directed path from any node to any other node
Converse: q -> p | contrapositive : ¬q -> ¬p | inverse: ¬p -< ¬q
Degree of vertex: number of edges incident on V, loop contributes 2 Pascal’s iden4ty: If n and k are integers with n ≥ k ≥ 1, then
Uniqueness quantifier : (E!) | symmetric Difference (A ⨁ B) Isolated vertex: degree = 0. Deg(V) = Out-deg(V) + IN-deg (V)
In-deg(V): number of edges going into V Out-deg(V): number of edges going out of V r-permuta4on without repe44on: k dis4nguish objects and n dis4nguish boxes with exclusion
Order not ma+er Degree sequence: undirected graph G, monotonic nonincreasing sequence of V degrees of all V - Distribu4ng k balls (1 to k) into n boxes (1 to n) in such a way no box receives more than 1 ball
Order not ma+er Number of edges = sum of degree sequence / 2
Universal modus ponens
Simple graph: connected or not connected graph contain no loops or parallel edges, given r-permuta4on with repe44on: k dis4nguish objects and n dis4nguish boxes without exclusion
Order ma+er simple graph G with n ver4ces, the the degree of each vertex of G is at most equal to n-1 - Making an ordered selec4on of k boxes from n with repe44on, and the balls do the selec4ng for us
Regular graph: all local degree are same number is call regular of degree r (r-regular graph)
Complete graph: simple graph when every pair of ver4ces are adjacent (n ver4ces symbol Kn) r-combina4on with repe44on: k indis4nguish objects and n dis4nguish boxes with exclusion
Order ma+er - Every vertex has degree(n-1), sum of degree n(n-1) - Forming a combina4on of size k from a set of size n
Universal modus tollens
Variable is bound if it is within the scope of a quantifier
Isomorphic graph: G1 an G2 are isomorphic if bijection f: G1 -> G2 r-combina4on without repe44on: k indis4nguish objects and n dis4nguish boxes without exclusion
Variable is free if not bound by a quantifier (Ǝx P(x,y) x bound, y free)
- different degree sequence not isomorphic; same deg sequence not necessary isomorphic
Bipartite graph: able separate to two nonempty disjoint sets V, edges endpoint are V1 and V2
Set builder notation S = { 2n+1 | n ∊ Z}
Boolean algebra variables take values on the set {0,1} Matching: set of pairwise non-adjacent edges, no loops; no edges with common endpoint.
Cardinality of Power Set |P(A)| = 2|A| - is matched (or saturated) if it is an endpoint of the edges in matching
Operator (+) (.) and (‘) correspond to (OR) (AND) and (NOT)
Inclusion-exclusion principle: Same precedence as predicate logic Maximum matching: if any edge is added, no longer a matching
∣S1∪S2∣=∣S1∣+∣S2∣−∣S1∩S2∣
Double Complement Hun4ngton’s Postulates Hopcroft-Karp Algorithm: solve maximum matching in bipartite graph
6 axioms: 1. Breadth First Search (BFS) 分解成細份 2. performance DFS (Depth first search)
Closure: any result in {0,1} 3. Find Augmenting Path BFS cycle then DFS
Truth table
Dis4nct elements: 0 ≠ 1
Adjacency List: Adjacency matrix: Adjacency matrix of digraph:
Principle of duality
6 axioms (identity)
build another equivalent Boolean rela4on by
. Change each OR(+) to AND(.)
. Change each AND(.) to OR (+)
. Change each 0 to 1 and each 1 to 0 Undirect graph : symmetric
∑element / 2 = edges # Only count move away from
Ways to prove Boolean rela4on equivalence
6 axioms (Commutative) Acyclic Graph: iff no cycles Adjacency matrix2: M2
of Proving Set Identity 1. Truth table (perfect induc4on)
2. Axioma4c proof (use laws) Tree: connected acyclic undirected graph (no loop or parallel)
3. Duality principle - Iff unique simple path between any two ver4ces. (proof by
4. Contradic4on (assume hypothesis is F) contradic4on) Fallacy of affirming the conclusion: ((p –>q )^q) -> p
- Tree with n ver4ces has n-1 edges
Fallacy of denying the hypothesis: ((p –>q )^-p) -> -q
Sum-of-products form. F(x,y,z) = xy = xz + yz Forest: disconnected graph containing no cycle
6 axioms (Distributive)
Product of sum F(x,y,z)=(x+y)(x+z)(y+z) Spanning tree: connected sub graph, all ver4ces, no cycles. M2 show # of path Euler circuit: every vertex of graph has a posiOve even integer
For converting built truth table first - Cost of spanning tree = sum of costs of its edges
- Minimum cost = lowest weight Dijkstra’s Algorithm
A combinational circuit is a circuit that Kruskal’s Algorithm: find min cost
implements a Boolean function 1. Draw all ver4ces w/o edges, 2. start filling lowest cost
Membership Table Venn diagram Priml’s Algorithm: find min cost
Par>>on of A is a set of subsets Ai of A such Karnaugh maps 1. Draw one ver4ce w/o edges, 2. draw ver4ces by lowest
(K maps)
that: all the subsets Ai are disjoints, the
union of all subsets Ai is qual to A. 6 axioms (complements)
If p, then q | if p, q | p is sufficient for q | q if p | q when p | a necessary condition for p is q |q unless not p | p implies q | p only if q | a sufficient condition for q is p |q whenever p | q is necessary for p | q follows from p | q provided that p