/
Discrete Structures for Computer Science Discrete Structures for Computer Science

Discrete Structures for Computer Science - PowerPoint Presentation

mitsue-stanley
mitsue-stanley . @mitsue-stanley
Follow
349 views
Uploaded On 2018-11-07

Discrete Structures for Computer Science - PPT Presentation

Presented By Andrew F Conn Lecture 22 Relations and Representations November 28 th 2016 Binary relations establish a relationship between elements of two sets Definition Let and be two sets A ID: 720822

set relation pairs relations relation set relations pairs definition symmetric divides elements transitive alice antisymmetric people bob charlie ordered

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Discrete Structures for Computer Science" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Discrete Structures for Computer Science

Presented By: Andrew F. Conn

Lecture #22: Relations and Representations

November 28

th

, 2016Slide2

Binary relations establish a relationship between elements of two sets

Definition:

Let

and be two sets. A binary relation from to is a subset of .In other words, a binary relation is a set of ordered pairs where and .Notation: We say that

 Slide3

Example: Course Enrollments

Let

s say that Alice and Bob are taking CS 441. Alice is also taking Math 336. Furthermore, Charlie is taking Art 212 and Business 444. Define a relation R that represents the relationship between people and classes.Solution:Let the set denote people, so Let the set denote classes, so By definition From the above statement, we know that

So,

 Slide4

A relation can also be represented as a graph

Alice

Bob

Charlie

Art 212

Business 444

CS 441

Math 336

Elements of

(i.e., people)

 

Elements of

(i.e., classes)

 

Let

s say that Alice and Bob are taking CS 441. Alice is also taking Math 336. Furthermore, Charlie is taking Art 212 and Business 444. Define a relation R that represents the relationship between people and classes.

 Slide5

A relation can also be represented as a table

R

Art 212

Business 444CS 441Math 336Alice

X

X

Bob

X

Charlie

X

X

Let

s say that Alice and Bob are taking CS 441. Alice is also taking Math 336. Furthermore, Charlie is taking Art 212 and Business 444. Define a relation R that represents the relationship between people and classes.

Elements of

(i.e., courses)

 

Elements of

(i.e., people)

 

Name of the relation

 Slide6

Wait, doesn

t this mean that relations are the same as functions?

Not quite… Recall the following definition from Lecture #9.Definition: Let and be nonempty sets. A function, , is an assignment of exactly one element of set to each element of set .Reconciling this with our definition of a relation, we see thatEvery function is also a relationNot every relation is a functionLet’s see some quick examples… 

This would mean that, e.g., a person only be enrolled in one course!Slide7

Short and sweet…

Consider

Clearly a function

Can also be represented as the relationConsider the set Clearly a relationCannot be represented as a function! 

 

Anna ●

Brian ●

Christine ●

● A

● B

● C

● D

● F

 

A ●

● 1

● 2Slide8

We can also define binary relations on a single set

Definition:

A

relation on the set is a relation from to . That is, a relation on the set is a subset of .Example: Let be the set . Which ordered pairs are in the relation ?Solution:1 divides everything2 divides itself and 43 divides itself4 divides itselfSo, R = {(1,1), (1,2), (1,3), (1,4), (2,2), (2,4), (3,3), (4,4)} (1,1), (1,2), (1,3), (1,4)(2,2), (2,4)(3,3)(4,4)Slide9

Representing the last example as a graph…

Example:

Let

be the set . Which ordered pairs are in the relation ? 1

2

3

4

1

2

3

4

1

2

3

4Slide10

Tell me what you know…

Question:

Which of the following relations contain each of the pairs

and ?

Answer:

 

Yes

Yes

No

No

Yes

No

No

Yes

Yes

No

Yes

No

No

Yes

Yes

Yes

No

No

No

Yes

No

No

Yes

No

No

Yes

Yes

Yes

Yes

No

Yes

Yes

No

No

Yes

No

No

Yes

Yes

No

Yes

No

No

Yes

Yes

Yes

No

No

No

Yes

No

No

Yes

No

No

Yes

Yes

Yes

Yes

No

These are all relations on an infinite set!Slide11

Properties of Relations

Definition:

A relation

on a set is reflexive if for every .Note: Our “divides” relation on the set is reflexive. 1

2

3

4

Every

divides itself!

 

1

2

3

4

1

X

X

X

X

2

X

X

3

X

4

XSlide12

Properties of Relations

Definition:

A relation

on a set is symmetric if whenever for every . If is a relation in which and implies that , we say that is antisymmetric.Mathematically:Symmetric:

Antisymmetric:

Examples:

Symmetric:

Antisymmetric:

 Slide13

Symmetric and Antisymmetric Relations

Symmetric relation

Diagonal axis of symmetry

Not all elements on the axis of symmetry need to be included in the relationAntisymmetric relationNo axis of symmetryOnly symmetry occurs on diagonalNot all elements on the diagonal need to be included in the relation1234

1

X

XXX2

X

3

X

4

X

1

2

3

4

1

X

X

X

X

2

X

X

3

X

X

4

X

X

 

 Slide14

Properties of Relations

Definition:

A relation

on a set is transitive if whenver and , then for every .Note: Our “divides” relation on the set is transitive. 

1

2

3

4

1 divides 2

2 divides 4

1 divides 4

This isn

t terribly interesting, but it is transitive nonetheless….

More common transitive relations include equality and comparison operators like <, >, ≤, and ≥.Slide15

Examples, redux

Question:

Which of the following relations are reflexive, symmetric, antisymmetric, and/or transitive?

Answer:

 

Reflexive

Symmetric

Antisymmetric

Transitive

R

1

Yes

No

Yes

Yes

R

2

No

No

Yes

Yes

R

3

Yes

Yes

No

Yes

R

4

Yes

Yes

Yes

Yes

R

5

No

No

Yes

No

R

6

No

Yes

No

NoSlide16

Relations can be combined using set operations

Example:

Let

be the relation that pairs students with courses that they have taken. Let be the relation that pairs students with courses that they need to graduate. What do the relations , , and represent?Solution: All pairs wherestudent a has taken course b ORstudent a needs to take course b to graduate All pairs whereStudent a has taken course b ANDStudent a needs course b to graduate All pairs whereStudent a needs to take course b to graduate BUTStudent a has not yet taken course b

 Slide17

Relations can be combined using functional composition

Definition:

Let R be a relation from the set A to the set B, and S be a relation from the set B to the set C. The

composite of R and S is the relation of ordered pairs (a, c), where a ∈ A and c ∈ C for which there exists an element b ∈ B such that (a, b) ∈ R and (b, c) ∈ S. We denote the composite of R and S by R º S.Example: What is the composite relation of R and S?So:  

 

 Slide18

Group Work!

Problem 1:

List the ordered pairs of the relation

from to where .Problem 2: Draw the graph and table representations of the above relation.Problem 3: Is the above relation reflexive, symmetric, antisymmetric, and/or transitive? Slide19

Final Thoughts

Relations allow us to represent and reason about the relationships between sets

Relations are more general than functions

Relations are use all over…Mathematical operatorsBindings between sets of objectsEtc.Next time: n-ary relations