functions and relationsphaas/info150/slides/s... · 2019. 10. 30. · functions and relations...

38
Functions and Relations Reading: EC 4.1–4.5 Peter J. Haas INFO 150 Fall Semester 2019 Lecture 12 1/ 23

Upload: others

Post on 06-Oct-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Functions and Relations

Reading: EC 4.1–4.5

Peter J. Haas

INFO 150Fall Semester 2019

Lecture 12 1/ 23

Page 2: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Functions and RelationsFunction Notation and TerminologyBinary RelationsInverse Relations and FunctionsComposition of FunctionsProperties of FunctionsOrdering RelationsEquivalence Relations

Lecture 12 2/ 23

Page 3: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Notation and Terminology of Functions 1

Definition

A function f : A ! B associates with each input from the domain A one and only oneoutput in the codomain B according to some rule

Terminology

I We say that “f is a function from A to B”

I If the rule associates to element a 2 A the element b 2 B, then we writef (a) = b and say that “f maps a to b” or “that value of f at a is b” or “f of aequals b”

Exercise: Define f : N ! N by the rule f (x) = 2x + 1

I Q: is every element of the codomain an output of one and only one input to f ?

Exercise: Define f : Z ! Z by the rule f (x) = x2

I Q: is every element of the codomain an output of one and only one input to f ?

Lecture 12 3/ 23

Page 4: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Notation and Terminology of Functions 1

Definition

A function f : A ! B associates with each input from the domain A one and only oneoutput in the codomain B according to some rule

Terminology

I We say that “f is a function from A to B”

I If the rule associates to element a 2 A the element b 2 B, then we writef (a) = b and say that “f maps a to b” or “that value of f at a is b” or “f of aequals b”

Exercise: Define f : N ! N by the rule f (x) = 2x + 1

I Q: is every element of the codomain an output of one and only one input to f ?

Exercise: Define f : Z ! Z by the rule f (x) = x2

I Q: is every element of the codomain an output of one and only one input to f ?

Lecture 12 3/ 23

Page 5: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Notation and Terminology of Functions 1

Definition

A function f : A ! B associates with each input from the domain A one and only oneoutput in the codomain B according to some rule

Terminology

I We say that “f is a function from A to B”

I If the rule associates to element a 2 A the element b 2 B, then we writef (a) = b and say that “f maps a to b” or “that value of f at a is b” or “f of aequals b”

Exercise: Define f : N ! N by the rule f (x) = 2x + 1

I Q: is every element of the codomain an output of one and only one input to f ?

Exercise: Define f : Z ! Z by the rule f (x) = x2

I Q: is every element of the codomain an output of one and only one input to f ?

Lecture 12 3/ 23

No .

fix )=O,

i - e; 2×41=0

,

impliesX= - Igel R

NO . ft - 2) = Plz ) = 4-

Page 6: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Notation and Terminology of Functions 2

Definition

A function f : A ! B associates with each input from the domain A one and only oneoutput in the codomain B according to some rule

Functions come in many guises

I Phone directories

I Word-processing software

I Addition: f (3, 4) = 7

I Truth tables: f : {T ,F}2 ! {T ,F}, e.g., f (p, q) = p ^ q

I Cutting the top card: (HCDS) = SHCD

Lecture 12 4/ 23

p q p ^ q

T T TT F FF T FF F F

Page 7: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Representing a Function

An example function

I Name: f

I Domain: {1, 2, 3, 4, 5}I Codomain: NI Rule: To each number in the domain, associate the square of the number

Representations of the rule

1. The above sentence

2. Algebraic formula: f (x) = x2

3. Set-based description: f = {(1, 1), (2, 4), (3, 9), (4, 16), (5, 25)}

4. Table:Input: 1 2 3 4 5

Output: 1 4 9 16 25

5. Arrow diagram:

Lecture 12 5/ 23

1 2 30

{} {a} {b} {c} {a,b} {a,c} {b,c} {a,b,c}

1 2 3 4 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 250

Another functionexample:

r inputoutput

exactlyone outgoing →

arrow

Page 8: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Binary Relations

Definition

A binary relation consists of a domain A, a codomain B, and a subset of A⇥ B calledthe rule for the relation.

Example: Relation E

I Domain: The set S of all UMass students this semester

I Codomain: The set C of classes o↵ered at UMass this semester

I Rule: (x , y) is in E if student x is enrolled in class y this semester

Example: Relation L

I Domain: A = {1, 2, 3, 4}I Codomain: B = {2, 3, 5}I Rule: L = {(1, 2), (1, 3), (1, 5), (2, 3), (2, 5), (3, 5), (4, 5)}I Succinct representation: L = {(x , y) 2 A⇥ B : x < y}I Infix notation: 1 L 2, 1 L 3, 2 L 5, 4 L 5, . . .

Observation

A function F : A ! B is a special case of a relation such that for every x 2 A, thereexists exactly one element y 2 B for which (x , y) 2 F (exactly one outgoing arrow)

Lecture 12 6/ 23

Relation L

2 3 5

1 2 3 4

ILL , 1<3,225,. .

.

Page 9: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Inverse Relations 1

Definition

Given a relation R with domain A and codomain B, the inverse R�1 of R is the

relation with domain B and codomain A such that

(x , y) 2 R if and only if (y , x) 2 R�1.

ExampleI Relation R: domain N and codomain Z with rule R = {(x , y) 2 N⇥ Z : x = y

2}or equivalently R = {(y2, y) : y 2 Z}

I Relation S : domain Z and codomain N with rule S = {(x , y) 2 Z⇥ N : y = x2}

or equivalently S = {(x , x2) : x 2 Z}

I Claim: R and S are inverses of each other1. If (x , y) 2 R, then x = y

2, which means that (y , x) = (y , y2) 2 S X2. If (x , y) 2 S , then x

2 = y , which means that (y , x) = (x2, x) 2 R X

Lecture 12 7/ 23

ex i ( 4,4 , ( 4,

-2 )

ex : 12,4 ),

C - 44 )

ed in verse of a L b C i.e.,

a ab ) from last slide

is G such that Ca,b) G G if a > b

ca,b)c. L iff a ab

,so ( b

,

a ) G G,

since b > a

Page 10: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Inverse Relations 2

Example: Relation E

I Domain is A = {1, 2, 3} and codomain is P(A)

I (x , y) 2 E (or equivalently x E y) if and only if x 2 y

I (y , x) 2 E�1 (or equivalently y E

�1x) if and only if x 2 y (also written y 3 x)

b ca

{} {a} {b} {c} {a,b} {a,c} {b,c} {a,b,c}b ca

{} {a} {b} {c} {a,b} {a,c} {b,c} {a,b,c}

Lecture 12 8/ 23

E E�1

" ycontains

x"

. I

Page 11: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Inverse Relations 3

Example: Arrow diagram when domain and codomain are the same

R = {(A, A), (A, B), (A, C), (A, E), (C , B), (C ,D), (E , A), (E , B), (E , C), (E ,D)}

R�1 = {(A, A), (B, A), (C , A), (E , A), (B, C), (D, C), (A, E), (B, E), (C , E), (D, E)}

A

B

D

E

C

A

B

D

E

C

Lecture 12 9/ 23

R R�1

Page 12: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Inverse Functions 1

Definition

Functions f : A ! B and g : B ! A are inverses of each other if

f (a) = b if and only if g(b) = a

for all a 2 A and b 2 B. We often write f�1 for the inverse of f .

Example: Prove that f : Z ! Z with rule f (x) = x + 3 and g : Z ! Z with ruleg(y) = y � 3 are inverses of each other

I Claim 1: For all a 2 A and b 2 B, if f (a) = b then g(b) = a

I Let a, b 2 Z be given such that f (a) = b, i.e., a+ 3 = b

I Then a = b � 3, i.e., g(b) = a. X

I Claim 2: For all a 2 A and b 2 B, if g(b) = a then f (a) = b

I Let a, b 2 Z be given such that g(b) = a, i.e., b � 3 = a

I Then a+ 3 = b, i.e., f (a) = b. X

Lecture 12 10/ 23

Page 13: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Inverse Functions 1

Definition

Functions f : A ! B and g : B ! A are inverses of each other if

f (a) = b if and only if g(b) = a

for all a 2 A and b 2 B. We often write f�1 for the inverse of f .

Example: Prove that f : Z ! Z with rule f (x) = x + 3 and g : Z ! Z with ruleg(y) = y � 3 are inverses of each other

I Claim 1: For all a 2 A and b 2 B, if f (a) = b then g(b) = a

I Let a, b 2 Z be given such that f (a) = b, i.e., a+ 3 = b

I Then a = b � 3, i.e., g(b) = a. X

I Claim 2: For all a 2 A and b 2 B, if g(b) = a then f (a) = b

I Let a, b 2 Z be given such that g(b) = a, i.e., b � 3 = a

I Then a+ 3 = b, i.e., f (a) = b. X

Lecture 12 10/ 23

-

Page 14: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Inverse Functions 2: Computing an Inverse

Example: for f : Q ! Q with rule f (x) = 25 x � 2, find f

�1

I Let a, b 2 Q be given such that f (a) = b, i.e., 25a� 2 = b

I Solving for a, we have a = 52b + 5

I So take f�1(y) = g(y) = 5

2 y + 5

Lecture 12 11/ 23

Page 15: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Inverses and Arrow Diagrams

An inverse is obtained by reversing the arrows

2

3

4

a

b

c

d

1

b

c

d

1

2

3

4

a

Example: Why is there is no function whose inverse g : {a, b, c, d} ! {1, 2, 3, 4} isgiven below?

2

3

4

a

b

c

d

1

b

c

d

1

2

3

4

a

Lecture 12 12/ 23

g-' ?

g. yrs ) = ?

g-'

air ?

Page 16: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Composition of Functions

Definition

Given f : A ! B and g : B ! C , the composition g � f of g and f has domain A,codomain C and rule (g � f )(x) = g(f (x)).

Example:

I f : R�0 ! R with rule f (x) =px

I g : R ! R with rule g(x) = 2x

I Then (g � f )(x) = g(f (x)) = g(px) = 2

px

I Then (f � g)(x) = f (g(x)) = f (2x) =p2x (what is the problem here?)

Composition via arrow diagrams

Lecture 12 13/ 23

a

b

c

d

x

y

z

a

b

c

d

2

1

2

1x

y

z

a

b

c

d2

1x

y

z

yes::b.

ate

,evaluate

first

domain of fog = domain of g= IR

,but - I ER and

I fog)th -

- Fn 4 IR

if we define 5 : Pio → 11230 with rule gun-

- H

Ithen fog is well defined

Page 17: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Inverse Functions Revisited

Definition

For a given set A, the identity function on A is the function ◆A : A ! A with the rule◆A(x) = x for all x 2 A. We’ll often simply write ◆ when A is clear from context. Wecan also write ◆A = {(x , x) : x 2 A} when we wish to view ◆A as a binary relation.

Theorem

Functions f : A ! B and g : B ! A are inverses of each other if and only iff � g = ◆B and g � f = ◆A. In other words, f �1

�f (x)

�= x and f

�f�1(y)

�= y

Example 1:I Let f : Q ! Q be the function with rule f (x) = 2

5 x � 2

I Let g : Q ! Q be the function with rule g(x) = 52 x + 5

I Then (g � f )(x) = g(f (x)) = g( 25 x � 2) = 52 (

25 x � 2) + 5 = (x � 5) + 5 = x

I Also, (f � g)(x) = f (g(x)) = f ( 52 x + 5) = 25 (

52 x + 5)� 2 = (x + 2)� 2 = x

Example 2: f : A ! A⇥ A with f (a) = (a, a) and g : A⇥ A ! A with g(x , y) = x

I Given a 2 A: (g � f )(a) = g(f (a)) = g(a, a) = a, so g � f = ◆AI Given (1, 2) 2 A⇥ A: (f � g)(1, 2) = f (1) = (1, 1) 6= (1, 2), so f � g 6= ◆A⇥A

Lecture 12 14/ 23

Page 18: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Inverse Functions Revisited

Definition

For a given set A, the identity function on A is the function ◆A : A ! A with the rule◆A(x) = x for all x 2 A. We’ll often simply write ◆ when A is clear from context. Wecan also write ◆A = {(x , x) : x 2 A} when we wish to view ◆A as a binary relation.

Theorem

Functions f : A ! B and g : B ! A are inverses of each other if and only iff � g = ◆B and g � f = ◆A. In other words, f �1

�f (x)

�= x and f

�f�1(y)

�= y

Example 1:I Let f : Q ! Q be the function with rule f (x) = 2

5 x � 2

I Let g : Q ! Q be the function with rule g(x) = 52 x + 5

I Then (g � f )(x) = g(f (x)) = g( 25 x � 2) = 52 (

25 x � 2) + 5 = (x � 5) + 5 = x

I Also, (f � g)(x) = f (g(x)) = f ( 52 x + 5) = 25 (

52 x + 5)� 2 = (x + 2)� 2 = x

Example 2: f : A ! A⇥ A with f (a) = (a, a) and g : A⇥ A ! A with g(x , y) = x

I Given a 2 A: (g � f )(a) = g(f (a)) = g(a, a) = a, so g � f = ◆AI Given (1, 2) 2 A⇥ A: (f � g)(1, 2) = f (1) = (1, 1) 6= (1, 2), so f � g 6= ◆A⇥A

Lecture 12 14/ 23

Page 19: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Inverse Functions Revisited

Definition

For a given set A, the identity function on A is the function ◆A : A ! A with the rule◆A(x) = x for all x 2 A. We’ll often simply write ◆ when A is clear from context. Wecan also write ◆A = {(x , x) : x 2 A} when we wish to view ◆A as a binary relation.

Theorem

Functions f : A ! B and g : B ! A are inverses of each other if and only iff � g = ◆B and g � f = ◆A. In other words, f �1

�f (x)

�= x and f

�f�1(y)

�= y

Example 1:I Let f : Q ! Q be the function with rule f (x) = 2

5 x � 2

I Let g : Q ! Q be the function with rule g(x) = 52 x + 5

I Then (g � f )(x) = g(f (x)) = g( 25 x � 2) = 52 (

25 x � 2) + 5 = (x � 5) + 5 = x

I Also, (f � g)(x) = f (g(x)) = f ( 52 x + 5) = 25 (

52 x + 5)� 2 = (x + 2)� 2 = x

Example 2: f : A ! A⇥ A with f (a) = (a, a) and g : A⇥ A ! A with g(x , y) = x

I Given a 2 A: (g � f )(a) = g(f (a)) = g(a, a) = a, so g � f = ◆AI Given (1, 2) 2 A⇥ A: (f � g)(1, 2) = f (1) = (1, 1) 6= (1, 2), so f � g 6= ◆A⇥A

Lecture 12 14/ 23

fawnby

notinverses

Page 20: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Properties of Functions 1

Definition

The function f : A ! B is invertible if there is a function f�1 : B ! A such that

f (x) = y if and only if f �1(y) = x . By symmetry of the definition, (f �1)�1 = f .

Example

I With A = B = R�0, if f has rule f (x) = x2, then f

�1(x) =px

I Arrow diagram:

A non-invertible function g

I Problem 1: no arrow points to 4 (g is not onto)

I Problem 2: two arrows point to 3 (g is not one-to-one)

Lecture 12 15/ 23

2

3

4

a

b

c

d

1

b

c

d

1

2

3

4

a

(f �1�f )(x) = x

Page 21: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Properties of Functions 1

Definition

The function f : A ! B is invertible if there is a function f�1 : B ! A such that

f (x) = y if and only if f �1(y) = x . By symmetry of the definition, (f �1)�1 = f .

Example

I With A = B = R�0, if f has rule f (x) = x2, then f

�1(x) =px

I Arrow diagram:

A non-invertible function g

I Problem 1: no arrow points to 4 (g is not onto)

I Problem 2: two arrows point to 3 (g is not one-to-one)

Lecture 12 15/ 23

2

3

4

a

b

c

d

1

b

c

d

1

2

3

4

a

2

3

4

a

b

c

d

1

b

c

d

1

2

3

4

a

(f �1�f )(x) = x

-

Page 22: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Properties of Functions 2

Definition

The function f : A ! B is onto if 8y 2 B, 9x 2 A, f (x) = y . The function f isone-to-one if (x 6= y) !

�f (x) 6= f (y)

�.

Theorem

A function f : A ! B is invertible if and only if it is both one-to-one and onto.

Exercise: Which functions are invertible?

I f : Z ! Z with f (x) = 2x + 3

I g : Z ! N with g(x) =

(�2z if z 0

2z � 1 if z > 0

I h : N ! N with h(n) = sum of digits in the numeral n

Lecture 12 16/ 23

2

3

4

a

b

c

d

1

X

not onto.

flex ) -

-O implies LXt3=o ,

so HI -3g ¢ #✓ gt - 11--2

, go-25-4,91-31--6, - -

-

c. to . I and onto 90=9 guk '

9123=3,433--5,

. --

,

"

Anot I - tot : htt 3) = honor ) -

- 4

Page 23: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

(Direct) Proofs About Functions

Proposition 1

If f : A ! B is one-to-one and g : B ! C is one-to-one, then (g � f ) : A ! C isone-to-one.

Proof

1. Write h = g � f and let x1, x2 2 A be given such that h(x1) = h(x2)

2. This means that g(f (x1)) = g(f (x2))

3. Since g is one-to-one, this means that f (x1) = f (x2)

4. Since f is one-to-one, this means that x1 = x2 X

Example: f : N ! N wih f (x) = 5x + 7 and g : N ! Q with g(n) = 5n+2

1. Write h = g � f and let x1, x2 2 A be given such that h(x1) = h(x2)

2. This means that g(f (x1)) = g(f (x2)) or 5f (x1)+2 = 5

f (x2)+2 or f (x1)+25 = f (x2)+2

5

3. Multiply by 5 and subtract 2 on both sides: f (x1) = f (x2) or 5x1 + 7 = 5x2 + 7

4. Subtract 7 and divide by 5 on both sides to get x1 = x2 X

Lecture 12 17/ 23

I - to -I : ( x

, + 4) → Lf exit ftp.D

Xcx,k f Hr ) ) → cry ,

= XD

Page 24: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

(Direct) Proofs About Functions

Proposition 1

If f : A ! B is one-to-one and g : B ! C is one-to-one, then (g � f ) : A ! C isone-to-one.

Proof

1. Write h = g � f and let x1, x2 2 A be given such that h(x1) = h(x2)

2. This means that g(f (x1)) = g(f (x2))

3. Since g is one-to-one, this means that f (x1) = f (x2)

4. Since f is one-to-one, this means that x1 = x2 X

Example: f : N ! N wih f (x) = 5x + 7 and g : N ! Q with g(n) = 5n+2

1. Write h = g � f and let x1, x2 2 A be given such that h(x1) = h(x2)

2. This means that g(f (x1)) = g(f (x2)) or 5f (x1)+2 = 5

f (x2)+2 or f (x1)+25 = f (x2)+2

5

3. Multiply by 5 and subtract 2 on both sides: f (x1) = f (x2) or 5x1 + 7 = 5x2 + 7

4. Subtract 7 and divide by 5 on both sides to get x1 = x2 X

Lecture 12 17/ 23

of contrapositive I flexi -

-flair ) ) → µ,- uhh )

Page 25: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

(Direct) Proofs About Functions

Proposition 1

If f : A ! B is one-to-one and g : B ! C is one-to-one, then (g � f ) : A ! C isone-to-one.

Proof

1. Write h = g � f and let x1, x2 2 A be given such that h(x1) = h(x2)

2. This means that g(f (x1)) = g(f (x2))

3. Since g is one-to-one, this means that f (x1) = f (x2)

4. Since f is one-to-one, this means that x1 = x2 X

Example: f : N ! N wih f (x) = 5x + 7 and g : N ! Q with g(n) = 5n+2

1. Write h = g � f and let x1, x2 2 A be given such that h(x1) = h(x2)

2. This means that g(f (x1)) = g(f (x2)) or 5f (x1)+2 = 5

f (x2)+2 or f (x1)+25 = f (x2)+2

5

3. Multiply by 5 and subtract 2 on both sides: f (x1) = f (x2) or 5x1 + 7 = 5x2 + 7

4. Subtract 7 and divide by 5 on both sides to get x1 = x2 X

Lecture 12 17/ 23

,Tracing the proof

Page 26: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Properties of Relations

Definition

Let R be a binary relation on a set A

1. R is reflexive if (a, a) 2 R for all a 2 A (must have loops)

2. R is antisymmetric if (a, b) 2 R and a 6= b implies (b, a) 62 R (no double arrows)

3. R is transitive if (a, b), (b, c) 2 R implies (a, c) 2 R (if you can get from a to c

following two arrows, you can also get there following one arrow)

Definition

A relation R on a set A is partial order if it is antisymmetric, transitive, and reflexive

Examples

1. A = {1, 2, 3, 4}: a R1 b means a b

2. A = P({1, 2, 3}): a R2 b means a ✓ b

3. A = {1, 2, 3, 6}: a R3 b means a divides b

Lecture 12 18/ 23

L-

- { C 1,27 ,( 3,4)

, ④7) I 122,324 ,"

LE s fl :D ,134 ,

.. . I

)

Page 27: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Properties of Relations

Definition

Let R be a binary relation on a set A

1. R is reflexive if (a, a) 2 R for all a 2 A (must have loops)

2. R is antisymmetric if (a, b) 2 R and a 6= b implies (b, a) 62 R (no double arrows)

3. R is transitive if (a, b), (b, c) 2 R implies (a, c) 2 R (if you can get from a to c

following two arrows, you can also get there following one arrow)

Definition

A relation R on a set A is partial order if it is antisymmetric, transitive, and reflexive

Examples

1. A = {1, 2, 3, 4}: a R1 b means a b

2. A = P({1, 2, 3}): a R2 b means a ✓ b

3. A = {1, 2, 3, 6}: a R3 b means a divides b

Lecture 12 18/ 23

Page 28: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Properties of Relations

Definition

Let R be a binary relation on a set A

1. R is reflexive if (a, a) 2 R for all a 2 A (must have loops)

2. R is antisymmetric if (a, b) 2 R and a 6= b implies (b, a) 62 R (no double arrows)

3. R is transitive if (a, b), (b, c) 2 R implies (a, c) 2 R (if you can get from a to c

following two arrows, you can also get there following one arrow)

Definition

A relation R on a set A is partial order if it is antisymmetric, transitive, and reflexive

Examples

1. A = {1, 2, 3, 4}: a R1 b means a b

2. A = P({1, 2, 3}): a R2 b means a ✓ b

3. A = {1, 2, 3, 6}: a R3 b means a divides b

Lecture 12 18/ 23

3

2

1

1

2 3

6

1

4{1,2,3}

{1,3}{2,3}

{1}{2}

{3}

{}

{1,2}

R1 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)} Hasse diagrams=p

antisymmetric : ( atb )s7[ca ,HeRrcb,aIER ]

Page 29: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Proofs About Properties

Example: Prove the reflexive property for R = {(a, b) 2 Z⇥ Z : a� b is even}1. Let a 2 Z be given

2. Since a� a = 0, which is even, we have that (a, a) 2 R X

Example: Prove the transitive property for R = {(a, b) 2 Z⇥ Z : a� b is even}1. Let (a, b), (b, c) 2 R be given [We’ll prove that (a, c) 2 R]

2. Since a� b and b � c are even, we can write a� b = 2K and b � c = 2L forsome integers K and L

3. Therefore a� c = (a� b) + (b � c) = 2K + 2L = 2(K + L)

4. Thus (a� c) is even and hence (a, c) 2 R X

Example: Prove the antisymmetric property for R = {(s, t) 2 P({1, 2, 3, 4})2 : s ✓ t}I Show: for all s, t 2 P({1, 2, 3, 4}), if (s, t) 2 R and (t, s) 2 R, then s = t

1. Let s, t 2 P({1, 2, 3, 4}) be given2. Since (s, t) 2 R and (t, s) 2 R, we have that s ✓ t and t ✓ s

3. It follows that s = t by definition of set equality X

Lecture 12 19/ 23

Page 30: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Proofs About Properties

Example: Prove the reflexive property for R = {(a, b) 2 Z⇥ Z : a� b is even}1. Let a 2 Z be given

2. Since a� a = 0, which is even, we have that (a, a) 2 R X

Example: Prove the transitive property for R = {(a, b) 2 Z⇥ Z : a� b is even}1. Let (a, b), (b, c) 2 R be given [We’ll prove that (a, c) 2 R]

2. Since a� b and b � c are even, we can write a� b = 2K and b � c = 2L forsome integers K and L

3. Therefore a� c = (a� b) + (b � c) = 2K + 2L = 2(K + L)

4. Thus (a� c) is even and hence (a, c) 2 R X

Example: Prove the antisymmetric property for R = {(s, t) 2 P({1, 2, 3, 4})2 : s ✓ t}I Show: for all s, t 2 P({1, 2, 3, 4}), if (s, t) 2 R and (t, s) 2 R, then s = t

1. Let s, t 2 P({1, 2, 3, 4}) be given2. Since (s, t) 2 R and (t, s) 2 R, we have that s ✓ t and t ✓ s

3. It follows that s = t by definition of set equality X

Lecture 12 19/ 23

Page 31: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Proofs About Properties

Example: Prove the reflexive property for R = {(a, b) 2 Z⇥ Z : a� b is even}1. Let a 2 Z be given

2. Since a� a = 0, which is even, we have that (a, a) 2 R X

Example: Prove the transitive property for R = {(a, b) 2 Z⇥ Z : a� b is even}1. Let (a, b), (b, c) 2 R be given [We’ll prove that (a, c) 2 R]

2. Since a� b and b � c are even, we can write a� b = 2K and b � c = 2L forsome integers K and L

3. Therefore a� c = (a� b) + (b � c) = 2K + 2L = 2(K + L)

4. Thus (a� c) is even and hence (a, c) 2 R X

Example: Prove the antisymmetric property for R = {(s, t) 2 P({1, 2, 3, 4})2 : s ✓ t}I Show: for all s, t 2 P({1, 2, 3, 4}), if (s, t) 2 R and (t, s) 2 R, then s = t

1. Let s, t 2 P({1, 2, 3, 4}) be given2. Since (s, t) 2 R and (t, s) 2 R, we have that s ✓ t and t ✓ s

3. It follows that s = t by definition of set equality X

Lecture 12 19/ 23

( at b) → Tla,

b) GR n lb,at ER ]

contrapositive : ca , b) f R A lb, a) ER# (a =D

Page 32: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Other Types of Orders

Definition

A relation R over a set A is irreflexive if (a, a) 62 R for all a 2 A. A strict partialordering on A is a relation R on A that is transitive, antisymmetric, and irreflexive.

Notes

I Irreflexive means no loops in an arrow diagram

I A relation R can be neither reflexive or irreflexive if some (but not all) nodes inthe arrow diagram have loops

Example:

I Strict subset relation: write A ⇢ B if A ✓ B and B � A 6= ;I Then R = {(A,B) 2 P({1, 2, 3, 4})2 : A ⇢ B} is a strict partial ordering

Definition

A relation R on A is a total ordering if it is a partial ordering and also satisfies theproperty:For all a, b 2 A, if a 6= b, then either (a, b) 2 R or (b, a) 2 R. A strict total orderinghas the same properties except that it is irreflexive.

Lecture 12 20/ 23

c :p no Boo

-

i.e. ,B has at least one element x

set . x ¢ A

Page 33: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Types of Orderings: Examples

Notation:

I A = {1, 2, 4, 8}, B = P({1, 2, 3}), C = {0, 1}4

I V (↵) = value of binary numeral ↵, e.g., V (0101) = 5

Example 1: R1 = {(x , y) 2 A2 : x y} total ordering

Example 2: R2 = {(x , y) 2 B2 : x ✓ y} partial ordering (incomparable subsets)

Example 3: R2 = {(S ,T ) 2 B2 : every element in S is every element in T} ?

Example 4: R2 = {(S ,T ) 2 B2 : n(S) < n(T )} ?

Example 5: R2 = {(S ,T ) 2 B2 : sum of elements in S is sum of elements in T} ?

Example 6: R2 = {(↵,�) 2 C2 : ↵ has fewer 1’s than � has} ?

Example 7: R2 = {(↵,�) 2 C2 : V (↵) V (�)} ?

Lecture 12 21/ 23

Base 10 : 234=4×1001-3×10 't 2140LBase 2 : 101 I l XI to . 2 't 1.22

= s

e.9 .1011

,

1100 ,-

--

+= go.info,

13×40,13×10,13

focuson

①Reflexive

lirncfkx.ve.

non. strict

I strict

② can youcompare

any pairof

element

11,449433and 1531411,23 yess

both

no ,partial

}partial ordering : reflexive

, lip ) huh incomparable orderingstrict partial ordering4 irreflexivc , 41,4 ,

$3,43,

incomparable

§ a

Total ordering : antisymmetric ,

transitive, reflexive ,

not incomparable

•strict partial order . 1100 and 0011 incomparable

7Total ordering cis condition were : Vlade Up)

,then strict total ordering

Page 34: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Equivalence Relations

Definition

A partition of a set A is a set S = {S1, S2, S3, . . .} such that

1. For all i , Si 6= 0

2. For all i , j : if Si 6= Sj , then Si \ Sj = ;3. S1 [ S2 [ S3 [ · · · = A

Definition

A relation R on A is an equivalence relation if there is a partition S of A such that(x , y) 2 R if and only if x and y are in the same part of S. We call S the partition ofA induced by R.

Example 1: A = {1, 2, 3, 4, 5, 6}I R = {(a, b) 2 A⇥ A : a� b is even}I S = {{1, 3, 5}, {2, 4, 6}}

Example 2:

I R = {(a, b) 2 Z⇥ Z : a� b is divisible by 4}I S = {P0,P1,P2,P3} where Pi = {a 2 Z : a = 4k + i for some k 2 Z}

Lecture 12 22/ 23

disjoint

Page 35: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Equivalence Relations

Definition

A partition of a set A is a set S = {S1, S2, S3, . . .} such that

1. For all i , Si 6= 0

2. For all i , j : if Si 6= Sj , then Si \ Sj = ;3. S1 [ S2 [ S3 [ · · · = A

Definition

A relation R on A is an equivalence relation if there is a partition S of A such that(x , y) 2 R if and only if x and y are in the same part of S. We call S the partition ofA induced by R.

Example 1: A = {1, 2, 3, 4, 5, 6}I R = {(a, b) 2 A⇥ A : a� b is even}I S = {{1, 3, 5}, {2, 4, 6}}

Example 2:

I R = {(a, b) 2 Z⇥ Z : a� b is divisible by 4}I S = {P0,P1,P2,P3} where Pi = {a 2 Z : a = 4k + i for some k 2 Z}

Lecture 12 22/ 23

disjoint

Page 36: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Equivalence Relations

Definition

A partition of a set A is a set S = {S1, S2, S3, . . .} such that

1. For all i , Si 6= 0

2. For all i , j : if Si 6= Sj , then Si \ Sj = ;3. S1 [ S2 [ S3 [ · · · = A

Definition

A relation R on A is an equivalence relation if there is a partition S of A such that(x , y) 2 R if and only if x and y are in the same part of S. We call S the partition ofA induced by R.

Example 1: A = {1, 2, 3, 4, 5, 6}I R = {(a, b) 2 A⇥ A : a� b is even}I S = {{1, 3, 5}, {2, 4, 6}}

Example 2:

I R = {(a, b) 2 Z⇥ Z : a� b is divisible by 4}I S = {P0,P1,P2,P3} where Pi = {a 2 Z : a = 4k + i for some k 2 Z}

Lecture 12 22/ 23

disjoint

part ion induced by R

odd - Odd is even

even- even is even

even- odd is even ,

odd - even is even

Page 37: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Equivalence Relations

Definition

A partition of a set A is a set S = {S1, S2, S3, . . .} such that

1. For all i , Si 6= 0

2. For all i , j : if Si 6= Sj , then Si \ Sj = ;3. S1 [ S2 [ S3 [ · · · = A

Definition

A relation R on A is an equivalence relation if there is a partition S of A such that(x , y) 2 R if and only if x and y are in the same part of S. We call S the partition ofA induced by R.

Example 1: A = {1, 2, 3, 4, 5, 6}I R = {(a, b) 2 A⇥ A : a� b is even}I S = {{1, 3, 5}, {2, 4, 6}}

Example 2:

I R = {(a, b) 2 Z⇥ Z : a� b is divisible by 4}I S = {P0,P1,P2,P3} where Pi = {a 2 Z : a = 4k + i for some k 2 Z}

Lecture 12 22/ 23

if a,be Pi

,

then a- 4kt is bintifor integers k and L

So a- b -

- 14kt i ) - Ltthti ) -

- 41k - L ),which is div . by 4

-

Page 38: Functions and Relationsphaas/INFO150/slides/s... · 2019. 10. 30. · Functions and Relations Function Notation and Terminology Binary Relations Inverse Relations and Functions Composition

Formal Properties of an Equivalence Relation

Definition

A relation R on A is symmetric if for all a, b 2 A, if (a, b) 2 A then (b, a) 2 A.

Theorem

A relation R on A is an equivalence relation if and only if it is reflexive, symmetric,and transitive.

Example: For each relation, determine whether it is an equivalence relation

I T1 = {(a, b) 2 Z2 : b � a is divisible by 5}

I T2 = {(a, b) 2 Z2 : a2 � b2 is divisible by 5}

I T3 = {(a, b) 2 Z2 : |a� b| 2}

Lecture 12 23/ 23

[email protected],

thenb-saymm-elgnj.bydub 'S

YGsimilar ③ a - b - 5k b - Ct 5h

a - Coca- b) tcb - c) ask -5L

NO V - 51k - D4" GT3 ↳ 4) ET,

Transitive

( 54 ) ¢T ,not transitive ie . II Land 2%4 but not 1154