Slide 1

Slide 1 text

Class 8: Functions and Relations cs2102: Discrete Mathematics | F16 uvacs2102.github.io David Evans | University of Virginia

Slide 2

Slide 2 text

Plan Functions Paradox / PS3 Questions Relations

Slide 3

Slide 3 text

Function Mathematical Data Type Domain Codomain

Slide 4

Slide 4 text

Function Mathematical Data Type Domain 4 2102 { 1, 2, 3, …} : $ Codomain ARCH 6.042 : ⟶

Slide 5

Slide 5 text

Operation Set Function ∈ Membership Test

Slide 6

Slide 6 text

Operation Set Function ∈ Membership Test = () Association

Slide 7

Slide 7 text

Defining a Function

Slide 8

Slide 8 text

Defining a Function Domain (Set) Codomain (Set) Associate elements of Domain with elements of Codomain

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

Example: FTFF Domain Codomain A B FTFF(A, B) T T F T F T F T F F F F

Slide 11

Slide 11 text

Cartesian Product Definition. A Cartesian product of sets 7 ×$ × ⋯ ×: is a set consisting of all possible sequences of elements where the th element is chosen from = . × = , ∈ , ∈ } 7 ×$ × ⋯ ×: = 7 , $,…,DE = ∈ = }

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

Example: FTFF Domain Codomain A B FTFF(A, B) T T F T F T F T F F F F

Slide 14

Slide 14 text

Example: Doubling ∷= 2 Domain Codomain

Slide 15

Slide 15 text

Example: Absolute Value ∷= || Domain Codomain

Slide 16

Slide 16 text

Example: Division , ∷= / Domain Codomain

Slide 17

Slide 17 text

Example: Square Root ∷= Domain Codomain

Slide 18

Slide 18 text

Total and Partial A function is total is every element in the domain has an associated codomain element. A partial function may have domain elements with no associated codomain element.

Slide 19

Slide 19 text

Total? , ∷= /

Slide 20

Slide 20 text

Total? , ∷= / Domain ⟶ Codomain: ℤ × ℤ ⟶ ℝ

Slide 21

Slide 21 text

Total? , ∷= / Domain ⟶ Codomain: ℤ × ℤU ⟶ ℝ

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Functions in Programming Java Python java.util.Arrays.sort Math.sqrt System.out.println (int n) -> n + 1 math.sqrt list.sort print lambda n: n + 1

Slide 24

Slide 24 text

Mathematical Functions Programming Functions

Slide 25

Slide 25 text

Mathematical Functions cannot do this!

Slide 26

Slide 26 text

Slack break… Questions about PS3 topics Questions about functions What is the smallest natural number that cannot be described in eleven words?

Slide 27

Slide 27 text

What is the smallest natural number that cannot be described in eleven words?

Slide 28

Slide 28 text

The smallest natural number that cannot be described in eleven words. 1 2 3 4 5 6 7 8 9 10 11 What is the smallest natural number that cannot be described in eleven words?

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Relations

Slide 32

Slide 32 text

Binary Relation

Slide 33

Slide 33 text

Binary Relation Is a binary relation a function?

Slide 34

Slide 34 text

Relation Properties A B

Slide 35

Slide 35 text

Relation Properties A B function: ≤ 1 out total: ≥ 1 out injective: ≤ 1 in surjective: ≥ 1 in

Slide 36

Slide 36 text

Relation Properties A B function: ≤ 1 out total: ≥ 1 out injective: ≤ 1 in surjective: ≥ 1 in bijective: = 1 out, = 1 in

Slide 37

Slide 37 text

: , , ⊆ × =

Slide 38

Slide 38 text

: , , ⊆ × <

Slide 39

Slide 39 text

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