Set Theory Introduction We introduce the use of Set Theory in - - PDF document

set theory introduction
SMART_READER_LITE
LIVE PREVIEW

Set Theory Introduction We introduce the use of Set Theory in - - PDF document

Set Theory Introduction We introduce the use of Set Theory in specifying computer systems We introduce: Z schemas for defining states and events/relationships between states. Some basic set notation. is (not) an element


slide-1
SLIDE 1

Set Theory

slide-2
SLIDE 2

Introduction

We introduce the use of Set Theory in

specifying computer systems

We introduce:

  • Z schemas for defining states and

events/relationships between states.

Some basic set notation.

  • “is (not) an element of”,
  • “Set Union”,
  • “Set Difference”
slide-3
SLIDE 3

System Lifecycle

  • Requirements analysis
  • System Specification
  • Design
  • Implementation
  • Testing and Integration
  • Support and Enhancement
slide-4
SLIDE 4

Abstraction?!

Geographical Representation 1932 Abstract Representation 1933

Maps from London Underground , Idea from Woodcock and Davies

slide-5
SLIDE 5

Scenario

Your software company has been

approached to design and build a software system to manage the book loans in a library.

slide-6
SLIDE 6

Exercise: Library system

We want to describe a system to track the

borrowing of books from a library.

Identify three elements of a real library system

that you will want to retain in your description.

Identify six elements of a real library system that

you will want to abstract away.

What kind of things should your specification

describe?

slide-7
SLIDE 7

Informal Library System

Library a set stock a set members A rule is_on_loan_to Acquire(book b) b is not already in the set stock Add b to the set stock Join(person p) p is not already in the set members Add p to the set members Dispose(book b) Leave(person p)

STATE EVENTS

slide-8
SLIDE 8

Return(book b ,person p) Library a set stock a set members A rule is_on_loan_to Borrow(book b, person p) b is not already on loan to anyone Add b is on loan to p

Borrowing and returning books

slide-9
SLIDE 9

Library a set stock a set Members A link is_on_loan_to Dispose(book b) Remove b from the set stock b is not in the set stock b is in the set stock Acquire(book b) Add b to the set stock

Towards a Formal Description:

stock b∉

stock b∈

slide-10
SLIDE 10

Acquire(book b) Library a set stock a set Members A link is_on_loan_to

Add b to the set stock

{ }

b Books s Book \ = ′

After the event stock is what stock was before the event with b added

Changing State 1: Acquire

stock b∉

} { ' b stock stock ∪ =

slide-11
SLIDE 11

Dispose(book b) stock b∈ Library a set stock a set members A link is_on_loan_to

Remove b from the set stock

{ }

b stock stock \ ' =

After the event stock is what stock was before the event with b removed

Changing State 2: Dispose

slide-12
SLIDE 12

Exercise: Complete Join and

Leave.

Library a set stock a set members A link is_on_loan_to Join(person p) p is not already in the set Members

Add p to the set Members

Leave(person p) p is in the set Members

Remove p from the set Members

slide-13
SLIDE 13

Return(book b ,person p)

Toward a Formal Description:

Borrowing and returning

Library a set stock a set members A link is_on_loan_to Borrow(book b, person p) b is not already on loan to anyone Add b is on loan to p

Question: What is “is_on_loan_to”?

slide-14
SLIDE 14

Summary

Software life cycle Specification Sets a is an element of A

:

a is not an element of A : The Union of two sets A and B : The set difference of two sets A and B:

A a∈

A a∉

B A∪

B A \

slide-15
SLIDE 15

Sets: Basics

slide-16
SLIDE 16

Sets: Basics

In this lecture we introduce:

  • The basic concept of a set
  • Notations for denoting sets
  • Set enumeration
  • Set comprehension
  • Basic set operations
  • Union, intersection, set difference
  • Use of Venn Diagrams

[Haggarty chapter 3]

and [Currie chapter 3]

slide-17
SLIDE 17

Sets: Basic Concept, Notation and Constructions

What is a set?

set g r

  • u

p f a m i l y ensemble b u n c h class g a t h e r i n g collection h e r d

We could have sets of……………? Some examples of sets of “numbers”…

[c.f. Haggerty p36]

N = The set of Natural Numbers

{ 1,2,3,…}

Z = The set of Integers

{ …-3,-2,-1,0,1,2,3,…}

Q = The set of Rational Numbers { p/q : p,q integers, not(q= 0) } R = The set of Real Numbers

all decimals?

slide-18
SLIDE 18

Notation

“A set is a collection of objects called elements”

[Haggarty p34]

“A set is a collection of distinct objects called

elements or members” [Currie p20]

} prime" is x |" N {x ∈

} even" is x |" N {x ∈

{1,2,3,4} {Anne of Cleves, Anne Boleyn} {2,4,6,8,…} {2,4,6,8,…,2n,…} {2,3,5,7,11,…} The set of wives of Henry VIII called Anne The set of all natural numbers that are even The set of all natural numbers that are prime

A(x)} | W {x ∈

W: set of wives of Henry A(x): x is called Anne

slide-19
SLIDE 19

Exercise:

Enumerate the following sets using set brackets as

  • n the previous slide. You may need to use dots

E.g.

  • 0,1,2,3}

{-3,-2,-1, 10} x | Z {x

2

= < ∈

B(x)} | A {x ∈

integer} another double is x | Z {x ∈

} r" " letter e contain th not does x | year the

  • f

months {x ∈

5} x and x | Z {x < < ∈ 1} x | Z {x

2 =

slide-20
SLIDE 20

Venn Diagrams

A convenient way of visualising/illustrating sets is the

use of Venn Diagrams using circles to represent sets and shading to illustrate/distinguish areas of interest.

A Venn Diagram illustrating a set A with…

A y A x ∉ ∈ and A y x

A Venn Diagram illustrating …

sets two

  • f

Union The B A ∪ A B B A ∪

slide-21
SLIDE 21

Basic Operations on Sets

A B

B A ∪

A B

B A \

A A B

B A ∩

A B

A B \

A B B x

  • r

A x B A x ∈ ∈ ∪ ∈ if

  • nly

and if B x a A x B A x ∈ ∈ ∩ ∈ nd if

  • nly

and if B x a A x B A x ∉ ∈ ∈ nd if

  • nly

and if \

slide-22
SLIDE 22

Subset

A B

B A ⊆

Examples

{ } { }

7 , 6 , 5 , 4 , 3 , 2 , 1 4 , 3 , 2 ⊆

{ }

N 7 , 6 , 5 , 4 , 3 , 2 , 1 ⊆

{ }

Months July June, May, ⊆ B A A ∪ ⊆ A B A ⊆ ∩

B A B A ⊆ denoted is "

  • f

subset a is "

Set A is a subset of set B if every element of A is an element of B

slide-23
SLIDE 23

1.

Union

2.

Intersection

3.

Subset

4.

Member of

5.

Set difference

U n i

  • n

I n t e r s e c t i

  • n

S u b s e t M e m b e r

  • f

S e t d i f f e r e n c e

0% 0% 0% 0% 0%

? in used being is symbol What B A∩

slide-24
SLIDE 24

1.

Union

2.

Intersection

3.

Subset

4.

Member of

5.

Set difference

U n i

  • n

I n t e r s e c t i

  • n

S u b s e t M e m b e r

  • f

S e t d i f f e r e n c e

0% 0% 0% 0% 0%

? in used being is symbol What B A ⊆

slide-25
SLIDE 25

1.

Union

2.

Intersection

3.

Subset

4.

Member of

5.

Set difference

U n i

  • n

I n t e r s e c t i

  • n

S u b s e t M e m b e r

  • f

S e t d i f f e r e n c e

0% 0% 0% 0% 0%

? in used being is symbol What B a∈

slide-26
SLIDE 26

Use of a Sequence of Venn diagrams

) \ ( ) \ ( ) ( \ show To C A B A C B A ∩ = ∪

A B C

C B ∪ ( )

C B A ∪ \

B A \

C A \

( ) ( )

C A B A \ \ ∩

The shaded areas for and are the same. Thus

) \ ( ) \ ( ) ( \ C A B A C B A ∩ = ∪ ) ( \ C B A ∪ ) \ ( ) \ ( C A B A ∩

slide-27
SLIDE 27

Venn Diagram Exercise

? ) ( ) ( that it true Is C B A C B A ∩ ∪ = ∩ ∪

? ) \ ( ) \ ( ) ( \ that it true Is C A B A C B A ∪ = ∩ ? ) ( ) ( that it true Is C B A C B A ∪ ∩ ⊆ ∪ ∩

slide-28
SLIDE 28

1.

Yes

2.

No

3.

Don’t know

Y e s N

  • D
  • n

’ t k n

  • w

0% 0% 0%

? ) \ ( ) \ ( ) ( \ that it true Is C A B A C B A ∪ = ∩

slide-29
SLIDE 29

1.

Yes

2.

No

3.

Don’t know

Y e s N

  • D
  • n

’ t k n

  • w

0% 0% 0%

? ) ( ) ( that it true Is C B A C B A ∩ ∪ = ∩ ∪

slide-30
SLIDE 30

1.

Yes

2.

No

3.

Don’t know

Y e s N

  • D
  • n

’ t k n

  • w

0% 0% 0%

? ) ( ) ( that it true Is C B A C B A ∪ ∩ ⊆ ∪ ∩

slide-31
SLIDE 31

Size of set

Notation: # A denotes the number of

elements in the set A.

E.g.

slide-32
SLIDE 32

1 2 3 N

  • n

e

  • f

t h e a b

  • v

e

0% 0% 0% 0%

  • 1. 1
  • 2. 2
  • 3. 3

4.

None of the above

A B

slide-33
SLIDE 33

Membership tables 1

( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )

form... in tabular this do can We cases. eight all for check this to need We . and and , deduce may then we and , if example For . and

  • f

ship member s ' for ies possibilit various the g considerin by this do can We versa.

  • vice

and

  • f

member a also is it then

  • f

element an is whenever that show must we show To : Example C B A x C B x C A B A x C A x B A x C x B x A x C A, B x C A B A C B A x C A B A C B A ∪ ∩ ∉ ∪ ∈ ∩ ∪ ∩ ∉ ∩ ∉ ∩ ∉ ∉ ∈ ∉ ∩ ∪ ∩ ∪ ∩ ∩ ∪ ∩ = ∪ ∩

slide-34
SLIDE 34

Membership tables 2

. if and if under 1 place we table In the SET x SET x SET ∉ ∈ A B C C B ∪

( )

C B A ∪ ∩ B A∩ C A∩

( ) ( )

C A B A ∩ ∪ ∩

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

slide-35
SLIDE 35

Membership tables: Observation

A B C C B ∪

( )

C B A ∪ ∩ B A∩ C A∩

( ) ( )

C A B A ∩ ∪ ∩

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

A B C

Each row in the membership table corresponds to precisely one “zone” in the Venn Diagram. The “1”s under a Set Expression will indicate the “zones” that correspond to that set

slide-36
SLIDE 36

Membership tables: Observation continued

A B C C B ∪

( )

C B A ∪ ∩ B A∩ C A∩

( ) ( )

C A B A ∩ ∪ ∩

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

A B C

slide-37
SLIDE 37

Membership tables: Exercise

Which of the following are true?

) ( \ ) ?( ) \ ( ) \ ( ) \ ?( ) \ ( C B C A C B A C B C A C B A ∩ ∩ = ∩ ∪ = ∪

slide-38
SLIDE 38

Summary

The basic concept of a set Notations for denoting sets

Set Enumeration Set Comprehension

Basic set operations:

Union, intersection, set difference

Use of Venn diagrams Use of membership tables

{ }

4 , 3 , 2 , 1

{ }

even" is " | N x x∈

{ }

prime" is " | N x x∈ B A ∩

{Anne Boleyn, Anne of Cleves}

A B C

( )

1 1 1 1 1 1 1 1 1 B A B B A B A ∪ ∩ ∪

slide-39
SLIDE 39

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.