+ All Categories
Home > Documents > CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

Date post: 31-Dec-2015
Category:
Upload: gordon-lucas
View: 235 times
Download: 0 times
Share this document with a friend
42
CSCI 115 Chapter 1 Fundamentals
Transcript
Page 1: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

CSCI 115

Chapter 1

Fundamentals

Page 2: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

CSCI 115

§1.1

Sets and Subsets

Page 3: 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

QQ

Q

Page 4: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

CSCI 115

§1.2

Operations on Sets

Page 5: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.2 – Operations on Sets

• Union• Intersection• Special notation• Disjoint Sets• Complement (B with respect to A)• Symmetric Difference

Page 6: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.2 – Operations on Sets

• Theorem 1.2.2– Addition Principle for 2 sets:

|A B| = |A| + |B| - |A B|

• Theorem 1.2.3– Addition Principle for 3 sets:

|A B C| = |A| + |B| + |C| - |A B| - |B C| - |A C| + |A B C|

Page 7: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

CSCI 115

§1.3

Sequences

Page 8: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.3 – Sequences

• List of objects in a definite order– Finite– Infinite– Recursively defined– Explicitly defined– Arrays

Page 9: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.3 – Sequences

• Characteristic Function– For a set A, fA(x) = 1 xA

0 xA

• Theorem 1.3.1– Characteristic functions satisfy the following

• i) fAB = fAfB

• ii) fAB = fA + fB –fAfB

• iii) fA⊕B = fA + fB – 2fAfB

{

Page 10: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§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

• fA = {1, 0, 1, 0, 0, 1}

Page 11: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.3 – Sequences

• Cardinality– Finite– Infinitely countable– Infinitely uncountable

Page 12: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§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

Page 13: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§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

Page 14: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

CSCI 115

§1.4

Properties of Integers

Page 15: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.4 – Properties of Integers

• Theorem 1.4.1– 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 1.4.1 is 0, we say n divides m, and write n|m. Then m = qn with n m.

Page 16: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.4 – Properties of Integers

• Theorem 1.4.2– 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

Page 17: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§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 1.4.3– Every positive integer n > 1 can be written uniquely

as , where p1<p2<…<ps 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

sks

kk ppp 21

21

Page 18: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§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).

Page 19: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.4 – Properties of Integers

• Theorem 1.4.4– 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 1.4.5– If a and b are in Z+, then:

GCD(a, b) = GCD(b, ba)

Page 20: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§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 r3. Continue process from step 1 until r = 04. The GCD is the last of the non-zero divisors

Ex: Find GCD (5797, 68355) using Algorithm 1

Page 21: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§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

Page 22: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§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).

Page 23: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.4 – Properties of Integers

• Theorem 1.4.6– If a and b are two positive integers, then

GCD(a, b) · LCM(a, b) = ab

Page 24: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§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)

Page 25: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.4 – Properties of Integers

• Theorem 1.4.7– 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.

11 1 0...k k

k kn d b d b d b d

0 , 0,1,..., , and 0.i kd b i k d

Page 26: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.4 – Properties of Integers

• Cryptology – Sir Francis Bacon’s code

DISCRETE00011 01000 10010 00010 10001 00100 10011 00100OREGO NISAS TATEI NTHEU NITED STATE SOFAM ERICA

Message sent:

OREGON IS A STATE IN THE UNITED STATES OF AMERICA

Page 27: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.4 – Properties of Integers

• Example – decode the followingWILLIAM IS A FAMOUS AUTHOR FROM THE SIXTEENTH CENTURY

Key: Underlined and bold text stands for 0

• Steganography

Page 28: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

CSCI 115

§1.5

Matrices

Page 29: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.5 – Matrices

• Matrix – Rectangular array– ith row, jth column, i,j element– Square matrix, diagonal– Diagonal matrix– Equality– Zero Matrix (additive identity)– Identity Matrix (multiplicative identity)

Page 30: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

• Addition

• Theorem 1.5.1– i) A + B = B + A– ii) (A + B) + C = A + (B + C)– iii) A + 0 = 0 + A = A

§1.5 – Matrices

Page 31: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

• Multiplication

• Theorem 1.5.2– i) A(BC) = (AB)C– ii) A(B + C) = AB + AC– iii) (A + B)C = AC + BC

§1.5 – Matrices

Page 32: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

• 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 ABBA– May be equal to AB

§1.5 – Matrices

Page 33: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

• Other properties / definitions:– If A is m x n, then ImA = AIn = A

– If A is square (n x n):• Ap = AAA…A (p factors)

• A0 = In

• ApAq = A(p+q)

• (Ap)q = Apq

– (AB)p = ApBp if and only if AB = BA

§1.5 – Matrices

Page 34: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

• Transposition

• Theorem 1.5.3– i) (AT)T = A– ii) (A + B)T = AT + BT

– iii) (AB)T = BTAT

• Symmetry (AT = A)– A is symmetric if and only if ai,j = aj,i for all i and j

§1.5 – Matrices

Page 35: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

• 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):

• Ci,j = 1 if Ai,j = 1 or Bi,j = 1• Ci,j = 0 if Ai,j = 0 and Bi,j = 0

– The meet of A and B (C = A B):• Ci,j = 1 if Ai,j = 1 and Bi,j = 1• Ci,j = 0 if Ai,j = 0 or Bi,j = 0

§1.5 – Matrices

Page 36: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

• 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):• Ci,j = 1 if Ai,j =1 and Bk,j = 1 for some k, 1 k p• Ci,j = 0 otherwise

§1.5 – Matrices

Page 37: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

• Theorem 1.5.4 (Inverses – not discussed)• Theorem 1.5.5

If A, B, and C are boolean matrices of appropriate sizes, then:i) A B = B A A B = B Aii) (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

Page 38: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

CSCI 115

§1.6

Mathematical Structures

Page 39: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§1.6 – Mathematical Structures

• Mathematical structure (system)– A collection of objects with an operation or

operations defined on those objects

Page 40: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

§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*

Page 41: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

• 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 1.6.1– If e is an identity for a binary operation , then e is

unique.

§1.6 – Mathematical Structures

Page 42: CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.

• Inverses– If a binary operation has an identity e, we say y is a -inverse of x if x y = y x = e.

• Theorem 1.6.2– If is an associative operation and x has a -inverse y,

then y is unique.

§1.6 – Mathematical Structures


Recommended