CSCI 115 Chapter 1 Fundamentals
CSCI 115 §1.1 Sets and Subsets
§1.1 – Sets and Subsets Definition Element Order does not matter Special Sets (Z, Z +, Z –, Q,, R, C, {}) Other Sets Equality Subsets Cardinality Power Set
CSCI 115 §1.2 Operations on Sets
§1.2 – Operations on Sets Union Intersection Special notation Disjoint Sets Complement (B with respect to A) Symmetric Difference
§1.2 – Operations on Sets Theorem –Algebraic Properties handout Theorem –Addition Principle for 2 sets: |A B| = |A| + |B| - |A B| Theorem –Addition Principle for 3 sets: |A B C| = |A| + |B| + |C| - |A B| - |B C| - |A C| + |A B C|
CSCI 115 §1.3 Sequences
§1.3 – Sequences List of objects in a definite order –Finite –Infinite –Recursively defined –Explicitly defined –Arrays
§1.3 – Sequences Characteristic Function –For a set A, f A (x) = 1x A 0x A Theorem –Characteristic functions satisfy the following i) f A B = f A f B ii) f A B = f A + f B –f A f B iii) f A ⊕ B = f A + f B – 2f A f B {
§1.3 – Sequences Computer representations of sets –Utilizes the characteristic function –Universal set must be clearly defined –Stored in Arrays U = {1, 2, 3, 4, 5, 6} A = {1, 3, 6} –Computer representation of A f A = {1, 0, 1, 0, 0, 1}
§1.3 – Sequences Cardinality –Finite –Infinitely countable –Infinitely uncountable
§1.3 – Sequences Strings and Regular Expressions Given a set A, A* is the set of all finite sequences of elements in A ( A*) –A – alphabet –A* – set of words Concatenation
§1.3 – Sequences Regular Expressions – a regular expression over A is a string constructed from the elements of A, (, ), v, *, and according to: –RE1: is a regular expression –RE2: If x A, x is a regular expression –RE3: If a and b are regular expressions, then ab is a regular expression –RE4: If a and b are regular expressions, then a v b is a regular expression –RE5: If a is a regular expression, then a* is a regular expression We will not be covering regular subsets
CSCI 115 §1.4 Properties of Integers
§1.4 – Properties of Integers Theorem –If n and m are integers and n > 0, we can write m = qn + r for integers q and r with 0 r < n. Moreover, there is just one way to do this. If the r in theorem is 0, we say n divides m, and write n|m. Then m = qn with n m.
§1.4 – Properties of Integers Theorem –Let a, b, and c be integers 1.If a|b and a|c, then a|(b + c) 2.If a|b and a|c, where b > c, then a|(b – c) 3.If a|b or a|c, then a |bc 4.If a|b and b|c, then a|c
§1.4 – Properties of Integers A integer p is prime if p > 1 and the only positive integers that divide p are p and 1 Theorem –Every positive integer n > 1 can be written uniquely as, where p 1 <p 2 <…<p s are distinct primes that divide n and the k’s are positive integers giving the number of times each prime occurs as a factor of n
§1.4 – Properties of Integers Greatest Common Divisor –If a, b, and k are in Z +, and k|a and k|b, we say that k is a common divisor of a and b. If d is the largest such k, d is called the greatest common divisor, or GCD, of a and b, and we write d = GCD(a, b).
§1.4 – Properties of Integers Theorem –If d is GCD(a, b), then 1.d = sa + tb for some integers s and t. (s and t may not be positive) 2.If c is any other common divisor of a and b, then c|d Theorem –If a and b are in Z +, then: GCD(a, b) = GCD(b, b a)
§1.4 – Properties of Integers Algorithm 1 to find GCD(a, b) (assume a > b) Euclidean Algorithm 1.Find q and r such that a = qb + r (as in Thm 1.4.1) 2.Replace a with b, b with r 3.Continue process from step 1 until r = 0 4.The GCD is the last of the non-zero divisors Ex: Find GCD (5797, 68355) using Algorithm 1
§1.4 – Properties of Integers Algorithm 2 to find GCD(a, b) 1.Find the prime factorizations of a and b 2.Find the product of only those prime numbers represented in both factorizations, to the lowest power represented Ex: Find GCD (5797, 68355) using Algorithm 2
§1.4 – Properties of Integers Least Common Multiple –If a, b, and k are in Z +, and a|k and b|k, we say k is a common multiple of a and b. The smallest such k, called c, is called the least common multiple, or LCM, of a and b, and we write c = LCM(a, b).
§1.4 – Properties of Integers Theorem –If a and b are two positive integers, then GCD(a, b) · LCM(a, b) = ab
§1.4 – Properties of Integers Algorithm to find LCM(a, b) 1.Find the prime factorizations of a and b 2.Find the product each of the prime numbers represented in either factorization, to the greatest power represented Ex: Find LCM (5797, 68355)
§1.4 – Properties of Integers Theorem –If b > 1 is an integer, then every positive integer n can be uniquely expressed in the form: where This is called the base b expansion of n. –Example: Find the base 7 representation of 381.
§1.4 – Properties of Integers Cryptology – Sir Francis Bacon’s code DISCRETE OREGO NISAS TATEI NTHEU NITED STATE SOFAM ERICA Message sent: OREGON IS A STATE IN THE UNITED STATES OF AMERICA
§1.4 – Properties of Integers Example – decode the following WILLIAM IS A FAMOUS AUTHOR FROM THE SIXTEENTH CENTURY Key: Underlined and bold text stands for 0 Steganography
CSCI 115 §1.5 Matrices
§1.5 – Matrices Matrix – Rectangular array –i th row, j th column, i,j element –Square matrix, diagonal –Diagonal matrix –Equality –Zero Matrix (additive identity) –Identity Matrix (multiplicative identity)
Addition Theorem –i) A + B = B + A –ii) (A + B) + C = A + (B + C) –iii) A + 0 = 0 + A = A §1.5 – Matrices
Multiplication Theorem –i) A(BC) = (AB)C –ii) A(B + C) = AB + AC –iii) (A + B)C = AC + BC §1.5 – Matrices
Commutativity of Multiplication? Let A be size m x p, B be size p x n BA: –May not be defined –May be defined, but a different size than AB –May be defined, same size as AB, but AB BA –May be equal to AB §1.5 – Matrices
Other properties / definitions: –If A is m x n, then I m A = AI n = A –If A is square (n x n): A p = AAA … A (p factors) A 0 = I n A p A q = A (p+q) (A p ) q = A pq –(AB) p = A p B p if and only if AB = BA §1.5 – Matrices
Transposition Theorem –i) (A T ) T = A –ii) (A + B) T = A T + B T –iii) (AB) T = B T A T Symmetry (A T = A) –A is symmetric if and only if a i,j = a j,i for all i and j §1.5 – Matrices
Boolean Matrices (all elements are 0 or 1) Operations on Boolean Matrices: –Let A and B be boolean Matrices –The join of A and B (C = A B): C i,j = 1 if A i,j = 1 or B i,j = 1 C i,j = 0 if A i,j = 0 and B i,j = 0 –The meet of A and B (C = A B): C i,j = 1 if A i,j = 1 and B i,j = 1 C i,j = 0 if A i,j = 0 or B i,j = 0 §1.5 – Matrices
Boolean Matrices (all elements are 0 or 1) Operations on Boolean Matrices: –Let A and B be boolean Matrices –The boolean product of A (m x p) and B (p x n ) is (C = A B): C i,j = 1 if A i,j =1 and B k,j = 1 for some k, 1 k p C i,j = 0 otherwise §1.5 – Matrices
Theorem (Inverses – not discussed) Theorem If A, B, and C are boolean matrices of appropriate sizes, then: i) A B = B A A B = B A ii) (A B) C = A (B C) (A B) C = A (B C) iii) A (B C) = (A B) (A C) A (B C) = (A B) (A C) iv) (A ⊙ B) ⊙ C = A ⊙ (B ⊙ C) §1.5 – Matrices
CSCI 115 §1.6 Mathematical Structures
§1.6 – Mathematical Structures Mathematical structure (system) –A collection of objects with an operation or operations defined on those objects
§1.6 – Mathematical Structures Types of operations –Unary – operates on a single object –Binary – operates on two objects Properties of operations –Closure –Commutativity –Associativity –Distribution of one over another –De Morgan’s laws for a unary operation * and binary operations and (x y)* = x* y* and (x y)* = x * y*
Identities –A structure with binary operation may contain a distinguished object e, with the property x e = e x = x for all x in the collection. We call e an identity for . Theorem –If e is an identity for a binary operation , then e is unique. §1.6 – Mathematical Structures
Inverses –If a binary operation has an identity e, we say y is a -inverse of x if x y = y x = e. Theorem –If is an associative operation and x has a -inverse y, then y is unique. §1.6 – Mathematical Structures