Functions Multiplicities Relations can be associated with - - PDF document

functions multiplicities
SMART_READER_LITE
LIVE PREVIEW

Functions Multiplicities Relations can be associated with - - PDF document

Functions Multiplicities Relations can be associated with multiplicities. (e.g. in UML diagrams) m..n B A The annotation ` m..n on B means that each A is associated with between m and n members of B Multiplicity annotations m..n


slide-1
SLIDE 1

Functions

slide-2
SLIDE 2

Multiplicities

Relations can be associated with

  • multiplicities. (e.g. in UML diagrams)

The annotation ` m..n’ on B means that

each A is associated with between m and n members of B

A B

m..n

slide-3
SLIDE 3

Multiplicity annotations

m..n means ` between m and n’ * means ` any number’ m..* means ` any number greater than

  • r equal to m’

m means ` exactly m’

slide-4
SLIDE 4

A common annotation

The annotation ` 1’ is particularly

common.

This means each A is associated with

exactly one B

This kind of relation is termed a

function

A B

1

slide-5
SLIDE 5

Functions more formally

slide-6
SLIDE 6

Example: favourite

Abigail Barney Charlotte Dora Emily CS189 CS153 CS154 CS173 CS183

slide-7
SLIDE 7

Examples

slide-8
SLIDE 8

Would be a function?

Y e s N

  • D

e p e n d s

0% 0% 0%

1.

Yes

2.

No

3.

Depends

slide-9
SLIDE 9

Would be a function?

Y e s N

  • D

e p e n d s

0% 0% 0%

1.

Yes

2.

No

3.

Depends

slide-10
SLIDE 10

Would be a function?

Y e s N

  • D

e p e n d s

0% 0% 0%

1.

Yes

2.

No

3.

Depends

slide-11
SLIDE 11

Would be a function?

Y e s N

  • D

e p e n d s

0% 0% 0%

1.

Yes

2.

No

3.

Depends

slide-12
SLIDE 12

Partial functions

Partial functions are like functions, except

that not all A’s have to relate to a B.

They have a weaker multiplicity

requirement.

A B

0..1

slide-13
SLIDE 13

Partial functions more formally

slide-14
SLIDE 14

Example: on_loan_to

War and Peace Bleak House Madame Bovary Lord of the Rings Using Z Neil Olivia Petra Quentin Ulysses Catch-22

slide-15
SLIDE 15

Examples

slide-16
SLIDE 16

Would be a partial function?

Y e s N

  • D

e p e n d s

0% 0% 0%

1.

Yes

2.

No

3.

Depends

slide-17
SLIDE 17

Would be a partial function?

Y e s N

  • D

e p e n d s

0% 0% 0%

1.

Yes

2.

No

3.

Depends

slide-18
SLIDE 18

Would be a partial function?

Y e s N

  • D

e p e n d s

0% 0% 0%

1.

Yes

2.

No

3.

Depends

slide-19
SLIDE 19

Injective functions

Multiplicity requirements on the domain of

the function are also useful.

If each B relates to 0 or 1 A’s then the

relation is injective.

Different A’s must relate to different B’s

A B

0..1

slide-20
SLIDE 20

Injective functions more formally

YES NO

slide-21
SLIDE 21

Example: exam numbers

Abigail Barney Charlotte Dora Emily 1455673 1522368 1415926 1556398 1529937

slide-22
SLIDE 22

Examples

Exam numbers: different students need

different numbers

Fingerprints: different people have

different fingerprints

Biometrics: different people have

different biometrics

slide-23
SLIDE 23

Partial injective functions

slide-24
SLIDE 24

Example: passport numbers

Abigail Barney Charlotte Dora Emily 31258734 48219347 32452263 62399853 34182730 32452275

slide-25
SLIDE 25

Would be a partial injective function?

Y e s N

  • D

e p e n d s

0% 0% 0%

1.

Yes

2.

No

3.

Depends

slide-26
SLIDE 26

Exercise

slide-27
SLIDE 27

Which symbol best matches the relation diagram?

0% 0% 0% 0%

1. 2. 3. 4.

A B

0..1 1

slide-28
SLIDE 28

Using relational notation

Functions are (special kinds of) relations, and so the relational notation can be used:

slide-29
SLIDE 29

A new library Z spec: state

  • n_loan_to declared

as a partial function

slide-30
SLIDE 30

Event: Borrowing a book

ΔLibrary means that the Library state changes

slide-31
SLIDE 31

Event: Looking up a borrower

b? is an input p! is an output ΞLibrary means the

Library state does not change

slide-32
SLIDE 32

Surjective functions (in brief)

slide-33
SLIDE 33

Multiplicities

A surjective function from A to B

involves every element of B

So every B relates to at least one A.

A B

1..*

slide-34
SLIDE 34

Bijective functions (in brief)

slide-35
SLIDE 35

Examples

slide-36
SLIDE 36

Summary

slide-37
SLIDE 37

Please ensure you return your handset before leaving.

The handset is useless outside of this class and non-returns will decease the likelihood of future voting system use on this course.