EDAA40 EDAA40 Discrete Structures in Computer Science Discrete - - PDF document

edaa40 edaa40 discrete structures in computer science
SMART_READER_LITE
LIVE PREVIEW

EDAA40 EDAA40 Discrete Structures in Computer Science Discrete - - PDF document

EDAA40 EDAA40 Discrete Structures in Computer Science Discrete Structures in Computer Science 2: Relations 2: Relations Jrn W. Janneck, Dept. of Computer Science, Lund University where this journey is headed, part 1 sets relations


slide-1
SLIDE 1

EDAA40 EDAA40 Discrete Structures in Computer Science Discrete Structures in Computer Science 2: Relations 2: Relations

Jörn W. Janneck, Dept. of Computer Science, Lund University

2

where this journey is headed, part 1

sets relations functions infinity

3

relations

Mathematical relations are about connections between objects. relations between numbers a divides b, a is greater than b, a and b are prime to each other relations between sets subset of, same size as, smaller than relations between people customer/client, parent/child, spouse, employer/employee We will focus on relations between two things. Often, they have distinct roles in a relation (superset/subset, parent/child, …), i.e. we cannot model them simply as unordered pairs {a, b}. In order to properly model relations, we first need to introduce

  • rdered pairs.
slide-2
SLIDE 2

4

  • rdered pairs, tuples
  • rdered pair

corollary: n-tuple 5

cartesian product

The (cartesian) product of a pair of sets, or more generally a finite family of sets, is the set of all ordered pairs or n-tuples. When the sets are the same, we also write Occasionally, to avoid fussiness, the following are treated as equal: If A and B are different, then 6

cartesian product

Examples: Note:

slide-3
SLIDE 3

7

relations

A (binary, dyadic) relation R from A to B (or over A x B) is a subset of the cartesian product: If A and B are the same, i.e. , we also say that R is a binary relation over A. Of course, this generalizes to... An n-place relation R over A1 x … x An is a subset of that product: 8

notation, examples

For binary relations , these are equivalent: Therefore: but 9

examples

Suppose What does this relation signify? When is ? Let's define

slide-4
SLIDE 4

10

source, target, domain, range

For binary relations : A is a source. B is a target. Note that for any R, source and target are not uniquely determined: For any and , we have . By contrast, these are uniquely determined: the domain of R: the range of R: For any relation it is always the case that and 11

example

We can represent the same information as a relation from P to Q: So that but . 12

relations as tables

1 1 1 1 1 1 1 1 1 1 1

Charlie Linus Lucy Patty Sally Violet Peggy Lydia Schroeder LRHG Mrs Othmar Charlie Linus Lucy Patty Sally Violet Peggy Lydia Schroeder

P Q

slide-5
SLIDE 5

13

drawing relations: digraphs

Linus Charlie Lucy Patty Sally Violet Peggy Lydia Schroeder Linus Charlie Lucy Patty Sally Violet Peggy Lydia Schroeder LRHG

  • Mrs. Othmar

P Q 14

drawing relations: digraphs

Linus Charlie Lucy Patty Sally Violet Peggy Lydia Schroeder LRHG

  • Mrs. Othmar

Q 15

converse, complement

For a binary relation its converse (inverse) is the relation For a binary relation its complement is the relation Notation: There is no firm standard for denoting converse or complement. When using symbols such as or , the complement is often indicated by striking through the symbol, i.e. or , while the converse is denoted by reversing the symbol . Notation: There is no firm standard for denoting converse or complement. When using symbols such as or , the complement is often indicated by striking through the symbol, i.e. or , while the converse is denoted by reversing the symbol . some properties: some properties:

slide-6
SLIDE 6

16

converse vs complement

Especially when source and target are the same, converse and complement seem to have a lot in common. Hence the importance of understanding the differences.

a b A c a b A c a b A c a b A c a b A c a b A c

converse: invert the arrows complement: absent arrows For finite A, B, given What are and ? 17

converse vs complement

R a b c a

1 1

b

1 1

c

1 1

R a b c a

1 1

b

1 1

c

1 1

R a b c a

1

b

1

c

1 converse: mirror at the diagonal complement: flip zeros and ones 18

composition

Given two binary relations and their composition is a binary relation on

a b x y z 1 2 a b 1 2 A B C

slide-7
SLIDE 7

19

composition

S 1 2 x

1

y

1

z

1

SoR 1 2 a

1

b

1 1

R x y z a

1 1

b

1 1

s i d e b a r

What is the relationship between the tables for R and S, and their composition? 20

image

Given a binary relation from A to B, for any its image under R, written R(a), is defined as

  • 1. What is ?
  • 2. What does it mean?

Can be “lifted” to subsets : Note: 21

properties: refmexivity

A binary relation is reflexive iff for all

a b A c a b A c

R a b c a

1 1

b

1 1

c

1 1 Other examples? What is the difference between irreflexive and not reflexive? A binary relation is irreflexive iff there is no such that

slide-8
SLIDE 8

22

properties: transitivity

A binary relation is transitive iff for all

a b A c a b A c

R a b c a

1 1 1

b

1

c

1 Other examples?

a b A c a b A c

R a b c a

1 1 1

b

1 1

c

1 23

properties: symmetry

A binary relation is symmetric iff for all

a b A c a b A c

R a b c a

1 1

b

1

c

1 1 Other examples? 24

properties: a(nti)symmetry

A binary relation is antisymmetric iff for all Consider and on the natural numbers. Neither is symmetric, but in slightly different ways. For , it is never the case that and . This is called asymmetry. For , it sometimes is, but only when . This is called antisymmetry. Both relations are antisymmetric. Only is asymmetric. A binary relation is asymmetric iff for all

slide-9
SLIDE 9

25

equivalence relations

A binary relation is an equivalence relation iff it is

  • 1. reflexive
  • 2. symmetric
  • 3. transitive

What about these:

  • equality
  • having the same number of elements:
  • divides:
  • relatively prime:

26

partitions

Given a set A, a partition of A is a set of pairwise disjoint sets , such that A: EU citizens, I: EU member states, B

i: citizens of country i

A: atoms, I: elements, Bi: atoms of element i A: natural numbers, I: primes, B

i: multiples of i (excluding i)

27

equivalence class, quotient set

Equivalence relations and partitions are really the same thing! Given a set A and an equivalence relation on A, for any we define the equivalence class of a as Alternative syntax:

SLAM when the relation is understood

Given a set A and an equivalence relation on A, the quotient (set) is defined as SLAM 2.5.4:

  • 1. Every partition is the quotient of an equivalence relation.
  • 2. Every quotient set is a partition.

Review the proof in the book. Connect it to these definitions.

slide-10
SLIDE 10

28

similarity relations

A binary relation is a similarity relation iff it is

  • 1. reflexive
  • 2. symmetric

What about these:

  • divides:
  • close to:

Why is close-to not an equivalence relation? 29

  • rder relation, poset

A binary relation is an (inclusive or non-strict) (partial)

  • rder iff it is
  • 1. reflexive
  • 2. antisymmetric
  • 3. transitive

What about these:

  • divides:
  • set inclusion:
  • on numbers: and
  • proper set inclusion:

A pair where A is a set and a partial order on A is called a partially ordered set or poset. Examples: 30

strict (partial) order

A binary relation is a strict (partial) order iff it is

  • 1. irreflexive
  • 2. transitive

Note: Irreflexivity and transitivity imply asymmetry. How? irreflexivity: transitivity: asymmetry:

slide-11
SLIDE 11

31

total (or linear) order

A binary relation is a (non-strict) total (or linear) order iff it is

  • 1. reflexive
  • 2. antisymmetric
  • 3. transitive
  • 4. total (complete):

What about these:

  • divides:
  • set inclusion:
  • on numbers: and

32

transitive closure

The transitive closure of a binary relation is defined as follows: What is the meaning of ? What are its properties? 33

how stufg is represented: pairs

s i d e b a r

If all you have is (unordered) sets, how do you represent (ordered) pairs? For a pair (a, b), we need to be able to tell which is the first element, and which is the second. This is how (Kuratowski, 1921) : So the singleton set contains the first element, and the one with two elements the second. Suppose they are the same, what does (a, a) look like? Show that Show that