Mathematical Preliminaries Fall 2005 Costas Busch RPI 1
Mathematical Preliminaries Fall 2005 Costas Busch - RPI 1
Mathematical Preliminaries • Sets • Functions • Relations • Graphs • Proof Techniques Fall 2005 Costas Busch - RPI 2
SETS A set is a collection of elements We write Fall 2005 Costas Busch - RPI 3
Set Representations C = { a, b, c, d, e, f, g, h, i, j, k } C = { a, b, …, k } finite set S = { 2, 4, 6, … } infinite set S = { j : j > 0, and j = 2 k for some k>0 } S = { j : j is nonnegative and even } Fall 2005 Costas Busch - RPI 4
A = { 1, 2, 3, 4, 5 } U A 6 1 7 2 4 10 Universal Set: 8 3 5 9 all possible elements U = { 1 , … , 10 } Fall 2005 Costas Busch - RPI 5
Set Operations A = { 1, 2, 3 } B = { 2, 3, 4, 5} B A • Union A U B = { 1, 2, 3, 4, 5 } 2 3 1 4 5 • Intersection U A B = { 2, 3 } 2 3 • Difference A-B={1} 1 B - A = { 4, 5 } Venn diagrams Fall 2005 Costas Busch - RPI 6
• Complement Universal set = {1, …, 7} A = { 1, 2, 3 } 4 A = { 4, 5, 6, 7} A 1 5 A 2 6 3 7 A=A Fall 2005 Costas Busch - RPI 7
{ even integers } = { odd integers } Integers 1 odd 2 3 Fall 2005 even 0 4 Costas Busch - RPI 5 6 7 8
De. Morgan’s Laws Fall 2005 U AUB=A B B=AUB Costas Busch - RPI 9
Empty, Null Set: ={} SU =S S = U S- = Universal Set =S -S= Fall 2005 Costas Busch - RPI 10
Subset A = { 1, 2, 3} B = { 1, 2, 3, 4, 5 } B U Proper Subset: A U A B B A Fall 2005 Costas Busch - RPI 11
Disjoint Sets A = { 1, 2, 3 } A Fall 2005 U A B = { 5, 6} B= B Costas Busch - RPI 12
Set Cardinality • For finite sets A = { 2, 5, 7 } |A| = 3 (set size) Fall 2005 Costas Busch - RPI 13
Powersets A powerset is a set of sets S = { a, b, c } Powerset of S = the set of all the subsets of S 2 S = { , {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c} } Observation: | 2 S | = 2|S| Fall 2005 Costas Busch - RPI ( 8 = 23 ) 14
Sequences and Tuples • A sequence of objects is a list of these objects in some order. • We usually designate a sequence by writing the list within parentheses. • For example, the sequence 7, 21, 57 would be written: (7, 21, 57). • The order doesn’t matter in a set, but in a sequence it does. Hence (7, 21, 57) is not the same as (57, 7, 21). Fall 2005 Costas Busch - RPI 15
Sequences and Tuples • Repetition does matter in a sequence, but it doesn’t matter in a set. • (7, 7, 21, 57) is different from both of the other sequences, whereas the set {7, 21, 57} is identical to the set {7, 7, 21, 57}. • As with sets, sequences may be finite or infinite. Fall 2005 Costas Busch - RPI 16
Sequences and Tuples • Finite sequences often are called tuples. § A sequence with k elements is a k-tuple. Ø Thus (7, 21, 57) is a 3 -tuple. Ø A 2 -tuple is also called an ordered pair. Fall 2005 Costas Busch - RPI 17
Cartesian Product A = { 2, 4 } B = { 2, 3, 5 } A X B = { (2, 2), (2, 3), (2, 5), ( 4, 2), (4, 3), (4, 5) } |A X B| = |A| |B| Generalizes to more than two sets AXBX…XZ Fall 2005 Costas Busch - RPI 18
Exercise • If A is the set {0, 1}, § What is the power set of A. § What is The set of all ordered pairs of A. § If A = {1, 2} and B = {x, y, z}, § find Ax. B § Find Ax. Bx. A Fall 2005 Costas Busch - RPI 19
FUNCTIONS domain 4 5 A 1 2 3 If A = domain range B f(1) = a a b c f : A -> B then f is a total function otherwise f is a partial function Fall 2005 Costas Busch - RPI 20
RELATIONS R = {(x 1, y 1), (x 2, y 2), (x 3, y 3), …} x i R yi e. g. if R = ‘>’: 2 > 1, 3 > 2, 3 > 1 Fall 2005 Costas Busch - RPI 21
Equivalence Relations • Reflexive: x. Rx • Symmetric: x. Ry • Transitive: x R y and y R z y. Rx x. Rz Example: R = ‘=‘ • x=x • x=y • x = y and y = z Fall 2005 y=x x=z Costas Busch - RPI 22
Equivalence Classes For equivalence relation R equivalence class of x = {y : x R y} Example: R = { (1, 1), (2, 2), (1, 2), (2, 1), (3, 3), (4, 4), (3, 4), (4, 3) } Equivalence class of 1 = {1, 2} Equivalence class of 3 = {3, 4} Fall 2005 Costas Busch - RPI 23
GRAPHS A directed graph e b node d a edge c • Nodes (Vertices) V = { a, b, c, d, e } • Edges E = { (a, b), (b, c), (b, e), (c, a), (c, e), (d, c), (e, b), (e, d) } Fall 2005 Costas Busch - RPI 24
Labeled Graph 2 6 a Fall 2005 b 1 5 3 e 6 2 d c Costas Busch - RPI 25
Walk e b d a c Walk is a sequence of adjacent edges (e, d), (d, c), (c, a) Fall 2005 Costas Busch - RPI 26
Path e b d a c Path is a walk where no edge is repeated Simple path: no node is repeated Fall 2005 Costas Busch - RPI 27
Cycle base a 3 2 e b 1 d c Cycle: a walk from a node (base) to itself Simple cycle: only the base node is repeated Fall 2005 Costas Busch - RPI 28
Euler Tour 8 b 4 a 7 3 6 5 base e 1 2 d c A cycle that contains each edge once Fall 2005 Costas Busch - RPI 29
Hamiltonian Cycle 5 b 4 a 3 base e 1 2 d c A simple cycle that contains all nodes Fall 2005 Costas Busch - RPI 30
Finding All Simple Paths e b d a c Fall 2005 Costas Busch - RPI origin 31
Step 1 e b d a c (c, a) origin (c, e) Fall 2005 Costas Busch - RPI 32
Step 2 e b d a (c, a) c (c, a), (a, b) origin (c, e), (e, b) (c, e), (e, d) Fall 2005 Costas Busch - RPI 33
Step 3 e b d a (c, a) c (c, a), (a, b) origin (c, a), (a, b), (b, e) (c, e), (e, b) (c, e), (e, d) Fall 2005 Costas Busch - RPI 34
Step 4 e b (c, a) d a (c, a), (a, b) c (c, a), (a, b), (b, e) origin (c, a), (a, b), (b, e), (e, d) (c, e), (e, b) (c, e), (e, d) Fall 2005 Costas Busch - RPI 35
root Trees parent leaf child Trees have no cycles Fall 2005 Costas Busch - RPI 36
root Level 0 Level 1 Height 3 leaf Level 2 Level 3 Fall 2005 Costas Busch - RPI 37
Binary Trees Fall 2005 Costas Busch - RPI 38
Strings and Languages • Strings of characters are fundamental building blocks in computer science. • The alphabet over which the strings are defined may vary with the application. • For our purposes, we define an alphabet to be any nonempty finite set. • The members of the alphabet are the symbols of the alphabet. Fall 2005 Costas Busch - RPI 39
Strings and Languages • We generally use capital Greek letters Σ and Γ to designate alphabets and a typewriter font for symbols from an alphabet. • The following are a few examples of alphabets. Σ 1 = {0, 1} Σ 2 = {a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z} § Γ = {0, 1, x, y, z} § § Fall 2005 Costas Busch - RPI 40
Strings and Languages • A string over an alphabet is a finite sequence of symbols from that alphabet, usually written next to one another and not separated by commas. v If Σ 1 = {0, 1}, then 01001 is a string over Σ 1. v If Σ 2 = {a, b, c, . . . , z}, then abracadabra is a string over Σ 2. v If w is a string over Σ, the length of w, written |w|, is the number of symbols that it contains. Fall 2005 Costas Busch - RPI 41
Strings and Languages • The string of length zero is called the empty string and is written ε. • The empty string plays the role of 0 in a number system. • If w has length n, we can write w = w 1 w 2 ··· wn where each wi ∈ Σ. • The reverse of w, written w. R, is the string obtained by writing w in the opposite order (i. e. , wnwn− 1 ··· w 1). • String z is a substring of w if z appears consecutively within w. For example, cad is a substring of abracadabra. Fall 2005 Costas Busch - RPI 42
Strings and Languages • If we have string x of length m and string y of length n, the concatenation of x and y, written xy, is the string obtained by appending y to the end of x, as in x 1 ··· xmy 1 ··· yn. • To concatenate a string with itself many times, we use the superscript notation xk to mean k. Fall 2005 Costas Busch - RPI 43
Strings and Languages • The lexicographic order of strings is the same as the familiar dictionary order. • We’ll occasionally use a modified lexicographic order, called shortlex order or simply string order, that is identical to lexicographic order, except that shorter strings precede longer strings. • Thus the string ordering of all strings over the alphabet {0, 1} is (ε, 0, 1, 00, 01, 10, 11, 000, . . . ). Fall 2005 Costas Busch - RPI 44
Boolean Logic • Boolean logic is a mathematical system built around the two values TRUE and FALSE. • Though originally conceived of as pure mathematics, this system is now considered to be the foundation of digital electronics and computer design. • The values TRUE and FALSE are called the Boolean values and are often represented by the values 1 and 0. • We use Boolean values in situations with two possibilities, such as a wire that may have a high or a low voltage, a proposition that may be true or false, or a question that may be answered yes Fall 2005 Costas Busch - RPI 45
Boolean Logic • We can manipulate Boolean values with the Boolean operations. • The simplest Boolean operation is the negation or NOT operation, designated with the symbol ¬. • The negation of a Boolean value is the opposite value. • Thus ¬ 0=1 and ¬ 1=0. Fall 2005 Costas Busch - RPI 46
Boolean Logic • We designate the conjunction or AND operation with the symbol ∧. The conjunction of two Boolean values is 1 if both of those values are 1. • The disjunction or OR operation is designated with the symbol ∨. The disjunction of two Boolean values is 1 if either of those values is 1. Fall 2005 Costas Busch - RPI 47
Boolean Logic • The exclusive or, or XOR, operation is designated by the ⊕ symbol and is 1 if either but not both of its two operands is 1. • The equality operation, written with the symbol ↔, is 1 if both of its operands have the same value. • Finally, the implication operation is designated by the symbol → and is 0 if its first operand is 1 and its second operand is 0; otherwise, → is 1. • We summarize this information as follows: Fall 2005 Costas Busch - RPI 48
Boolean Logic Fall 2005 Costas Busch - RPI 49
PROOF TECHNIQUES • Proof by induction • Proof by contradiction Fall 2005 Costas Busch - RPI 50
Induction We have statements P 1, P 2, P 3, … If we know • for some b that P 1, P 2, …, Pb are true • for any k >= b that P 1, P 2, …, Pk imply Pk+1 Then Every Pi is true Fall 2005 Costas Busch - RPI 51
Proof by Induction • Inductive basis Find P 1, P 2, …, Pb which are true • Inductive hypothesis Let’s assume P 1, P 2, …, Pk are true, for any k >= b • Inductive step Show that Pk+1 is true Fall 2005 Costas Busch - RPI 52
Example Theorem: A binary tree of height n has at most 2 n leaves. Proof by induction: let L(i) be the maximum number of leaves of any subtree at height i Fall 2005 Costas Busch - RPI 53
We want to show: L(i) <= 2 i • Inductive basis L(0) = 1 (the root node) • Inductive hypothesis Let’s assume L(i) <= 2 i for all i = 0, 1, …, k • Induction step we need to show that L(k + 1) <= 2 k+1 Fall 2005 Costas Busch - RPI 54
Induction Step height k k+1 From Inductive hypothesis: L(k) <= 2 k Fall 2005 Costas Busch - RPI 55
Induction Step height L(k) <= 2 k k k+1 L(k+1) <= 2 * L(k) <= 2 * 2 k = 2 k+1 (we add at most two nodes for every leaf of level k) Fall 2005 Costas Busch - RPI 56
Remark Recursion is another thing Example of recursive function: f(n) = f(n-1) + f(n-2) f(0) = 1, f(1) = 1 Fall 2005 Costas Busch - RPI 57
Proof by Contradiction We want to prove that a statement P is true • we assume that P is false • then we arrive at an incorrect conclusion • therefore, statement P must be true Fall 2005 Costas Busch - RPI 58
Example Theorem: is not rational Proof: Assume by contradiction that it is rational = n/m n and m have no common factors We will show that this is impossible Fall 2005 Costas Busch - RPI 59
= n/m Therefore, 2 m 2 = 4 k 2 n 2 2 m 2 = n 2 is even m 2 = 2 k 2 n is even n=2 k m is even m=2 p Thus, m and n have common factor 2 Contradiction! Fall 2005 Costas Busch - RPI 60
- Slides: 60