Slide 1

Slide 1 text

Class 8: Sequences, Relations, Functions cs2102: Discrete Mathematics David Evans and Mohammad Mahmoody

Slide 2

Slide 2 text

Plan 1. Sequences 2. Relations 3. Functions

Slide 3

Slide 3 text

Sequence vs. Set • Set 1. Has elements 2. Unordered 3. Distinct elements 4. finite or infinite • Sequence 1. Has components 2. Ordered 3. Might have repetition 4. finite or infinite -4 2102 1/2

Slide 4

Slide 4 text

Operations on Sequences • Sets , 1. ∈ 2. Union: ∪ 3. Intersection ∩ 4. Complement 5. Size: |A| • Sequences , 1. is a component of 2. Concatenation: || 3. ? 4. ? 5. Length: |S| -4 2102 1/2 = (−4, 2101, , 1/2) = (−4, −4,2101, , 1/2,4)

Slide 5

Slide 5 text

Terminology • Tuple: same thing as a sequence • Pair: a sequence of length 2 • triple, quadruple, quintuple, … • -tuple

Slide 6

Slide 6 text

Sets of Sequences and Vice Versa • Set of sequences • Sequence of Sets (a,b) (1,2,3,1) (x, {y,z}) ( , , , {, , })

Slide 7

Slide 7 text

Cartesian Product: Getting a set of -tuples from sets Definition. A Cartesian product of sets 1 × 2 × ⋯ × is a set consisting of all possible sequences of elements where the th element is chosen from . × = , ∈ , ∈ } 1 × 2 × ⋯ × = 1 , 2 … , ∈ }

Slide 8

Slide 8 text

Definition. A Cartesian product of sets 1 × 2 × ⋯ × is a set consisting of all possible sequences of elements where the th element is chosen from . × = , ∈ , ∈ } 1 × 2 × ⋯ × = 1 , 2 … , ∈ } How many elements are in × ? Cartesian Product: Getting a set of -tuples from sets

Slide 9

Slide 9 text

Relations and Functions

Slide 10

Slide 10 text

Relations: Subsets of Cartesian Products = 1 × 2 × ⋯ × = 1 , 2 … , ∈ } If ⊆ , then describes a `relation’ between some elements from 1 , … , Example: = { , , , ∣ person drove car in street on day } Important special case: when = 2 called binary relations.

Slide 11

Slide 11 text

Binary Relation

Slide 12

Slide 12 text

Functions: an important form of binary relations Domain Codomain Main property: every element in Domain is in relation with exactly one element in Codomain

Slide 13

Slide 13 text

Steps of Defining a Function 1. Domain (Set) 2. Codomain (Set) 3. Describe how to map every element of Domain to one element of Codomain

Slide 14

Slide 14 text

Notation Function Relation (, ) ∈

Slide 15

Slide 15 text

Example: NOT (Boolean Function) Domain Codomain P NOT(P ) T F F T

Slide 16

Slide 16 text

Example: XOR as Boolean Function Domain Codomain A B XOR(A, B) T T F T F T F T T F F F

Slide 17

Slide 17 text

Example: Doubling ∷= 2 Domain Codomain

Slide 18

Slide 18 text

Example: Absolute Value ∷= || Domain Codomain

Slide 19

Slide 19 text

Example: Division , ∷= / Domain Codomain

Slide 20

Slide 20 text

Example: Square Root ∷= Domain Codomain

Slide 21

Slide 21 text

Charge • PS3 Due Friday (6:29pm) • Next week: – Cardinality (MCS 4.5) – Start Induction (MCS 5.1)