relations discrete structures (cs 173) madhusudan parthasarathy, university of illinois van gogh 1

26
Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Upload: luke-clark

Post on 18-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Relations

Discrete Structures (CS 173)Madhusudan Parthasarathy, University of Illinois

Van Gogh

1

Page 2: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Midterm 1

• Oct 1 in class• Skills list on website, under exams• Practice midterm and practice problems will

also be up soon.

2

Page 3: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Last Class: Sets

3

mother father

sister

grandfather

Beethoven

memy friend

Madonna

A set is an unordered collection of objects

Page 4: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Last Class: Sets

4

mother father

sister

grandfather

Beethoven

me

Family

my friend

Madonna

Page 5: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Today’s class: Relations

5

Beethoven

my friend

Madonna

mother father

sister

grandfather

me

parent

parent

sibling

Page 6: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Today’s class

• How to represent relations

• Properties and types of relations: reflexive, symmetric, transitive, partial order, etc.

• Practice proofs with relations

6

Page 7: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Representing relationsA relation on a set is a set of ordered pairs of elements from i.e.

• Consider relation to stand for “parent” on the set of people– mother me– = {(grandfather, mother), (mother, me), (father, me), (mother, sister), (father, sister)}

• Relation stands for “sibling”– {(sister, me), (me, sister)}

7

mother father

sister

grandfather

me

parent

parent

sibling

Page 8: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Relations with numbers

8

1 2 3 4 5 6 7 8

“less than”

“divides”

“congruent mod 3”

1 2 3 4 5 6 7 8

1 2 3 4 5 6 7 8

Page 9: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Application: Relational Databases, SQL- A database can be seen as a relation (or sets of relations)- Represented as tables

- Query languages (like SQL)- SELECT statements combine relations to get new relations- SELECT * FROM Book WHERE price > 100.00 ORDER BY

title;- Uses JOINs, etc. Uses Boolean connectives, etc.- http://en.wikipedia.org/wiki/SQL

9

Page 10: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Reflexivity

Reflexive: all elements relate to self

Irreflexive: no elements relate to self ( means “”)

Is irreflexive the negation of reflexive? No!

10

Page 11: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Symmetry

Symmetric:

Antisymmetric: equivalent:

11

Page 12: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Transitivity

Transitive:

Example of a relation that is transitive?

Not transitive?

12

Page 13: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Practice identifying relation properties

13

Reflexiv

e

Irrefle

xive

Symmetric

Antisym

metric

Transit

iveAll to self None to self

If one way then both

Never both ways if not same

if x->y->z, x->z

Page 14: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Practice identifying relation properties

14

Reflexiv

e

Irrefle

xive

Symmetric

Antisym

metric

Transit

iveAll to self None to self

If one way then both

Never both ways if not same

if x->y->z, x->z

“less than”

“divides”

“congruent mod k”

“is square of”

Page 15: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Disproof of transitive

15

Claim: “is square of” is not transitive.Definition: Relation on set is transitive iff

Page 16: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Proof of antisymmetric

16

Claim: “is square of” is antisymmetric.Definition: Relation on set is antisymmetric if , or equivalently

Page 17: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Types of relationsPartial order:reflexive, antisymmetric, transitive

17

Page 18: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Types of relationsLinear order: partial order (reflexive, antisymmetric, transitive) in which every pair of elements is comparable:

18

Page 19: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Types of relationsStrict partial order: irreflexive, antisymmetric, transitive

19

Page 20: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Types of relationsEquivalence relation: reflexive, symmetric, transitive

20

Page 21: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Equivalence exampleRelation on : iff

contains all points on the unit circle

21

Page 22: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Proof of equivalence

22

Claim: “congruent mod k” is an equivalence relationDefinition: An equivalence relation is reflexive, symmetric, and transitive

Page 23: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

The subset relation

23

What kind of ordering is the subset () relation sets?

Page 24: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Types of relations

24

Reflexiv

e

Irrefle

xive

Symmetric

Antisym

metric

Transit

ive

Partial Order

Linear Order

Strict Partial Order

Equivalence Relation

Page 25: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

Things to remember

• How to illustrate a relation graphically

• Be able to identify basic properties of relations: reflexivity, symmetry, transitivity

• Types of relations: partial order, strict partial order, linear order

• When proving (or disproving) a property of a relation, write down definition of relation and property

25

Page 26: Relations Discrete Structures (CS 173) Madhusudan Parthasarathy, University of Illinois Van Gogh 1

See you next week!

• Functions and more functions

26