set theory introduction
play

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


  1. Set Theory

  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” �

  3. System Lifecycle Requirements analysis � System Specification � Design � Implementation � Testing and Integration � Support and Enhancement �

  4. Abstraction?! Abstract Representation 1933 Geographical Representation 1932 Maps from London Underground , Idea from Woodcock and Davies

  5. Scenario � Your software company has been approached to design and build a software system to manage the book loans in a library.

  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?

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

  8. Borrowing and returning books 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 Return( book b , person p) Add b is on loan to p

  9. Towards a Formal Description: Library a set stock a set Members A link is_on_loan_to Acquire( book b) b ∉ stock b is not in the set stock Add b to the set stock Dispose( book b) b is in the set stock b ∈ stock Remove b from the set stock

  10. Changing State 1: Acquire Library a set stock a set Members A link is_on_loan_to Add b to the set stock After the event stock is what stock was before the event Acquire( book b) with b added b ∉ stock { } ′ = = ∪ \ Book s Books b ' { } stock stock b

  11. Changing State 2: Dispose Library a set stock a set members A link is_on_loan_to Remove b from the set stock After the event stock is what stock was before the event Dispose( book b) with b removed b ∈ stock { } ' = \ stock stock b

  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

  13. Toward a Formal Description: Borrow ing and return ing Borrow( book b, person p) b is not already on loan to anyone Library Add b is on loan to p a set stock a set members A link is_on_loan_to Return( book b , person p) Question: What is “is_on_loan_to”?

  14. Summary � Software life cycle � Specification � Sets a ∈ A � a is an element of A : a ∉ A � a is not an element of A : A ∪ B � The Union of two sets A and B : � The set difference of two sets A and B: A \ B

  15. Sets: Basics

  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]

  17. Sets: Basic Concept, Notation and Constructions b g r u o u n p c h � What is a set? set g n i r e h t a g d r class e h f a m i l y collection ensemble 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?

  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] {1,2,3,4} W: set of wives of Henry A(x): x is called Anne The set of wives of {Anne of Cleves, {x ∈ W | A(x)} Henry VIII called Anne Anne Boleyn} The set of all natural numbers {x ∈ {2,4,6,8,…} N |" x is even" } that are even {2,4,6,8,…,2n,…} The set of all natural numbers {x ∈ N |" x is prime" } {2,3,5,7,11,…} that are prime

  19. {x ∈ Exercise: A | B(x)} � Enumerate the following sets using set brackets as on the previous slide. You may need to use dots ∈ < = 2 � E.g. {x Z | x 10} {-3,-2,-1, 0,1,2,3} 2 = ∈ � {x Z | x 1} ∈ < < � {x Z | 0 x and x 5} � {x ∈ months of the year | x does not contain th e letter " r" } {x ∈ � Z | x is double another integer}

  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 A Venn Diagram illustrating … illustrating a set A with… A ∪ The Union of two sets B ∈ ∉ and x A y A y A A ∪ B x A B

  21. Basic Operations on Sets A A B A ∪ A ∩ B B ∈ ∪ x A B ∈ ∩ x A B if and only if if and only if ∈ ∈ x A or x B ∈ ∈ nd x A a x B A B A B A \ B \ B A ∈ \ x A B if and only if A B A B ∈ ∉ nd x A a x B

  22. Subset Set A is a subset of set B if every element of A is an element of B ⊆ " is a subset of " is denoted A B A B A ⊆ B Examples { } { } ⊆ 2 , 3 , 4 1 , 2 , 3 , 4 , 5 , 6 , 7 { } ⊆ B 1 , 2 , 3 , 4 , 5 , 6 , 7 N A { } ⊆ May, June, July Months ⊆ ∪ A A B ∩ ⊆ A B A

  23. A ∩ What symbol is being used in ? B Union 1. Intersection 2. Subset 3. Member of 4. Set difference 5. 0% 0% 0% 0% 0% n f e n t o e o c o s n i r i n t b e c e b U u e r m e S s f r f e e i d M t n t I e S

  24. A ⊆ What symbol is being used in ? B Union 1. Intersection 2. Subset 3. Member of 4. Set difference 5. 0% 0% 0% 0% 0% n f e n t o e o c o s n i r i n t b e c e b U u e r m e S s f r f e e i d M t n t I e S

  25. a ∈ What symbol is being used in ? B Union 1. Intersection 2. Subset 3. Member of 4. Set difference 5. 0% 0% 0% 0% 0% n f e n t o e o c o s n i r i n t b e c e b U u e r m e S s f r f e e i d M t n t I e S

  26. Use of a Sequence of Venn diagrams ∪ = ∩ To show \ ( ) ( \ ) ( \ ) A B C A B A C A \ B A B A \ C B ∪ C C ( ) ( ) ∩ ( ) \ \ A B A C ∪ \ A B C ∪ ∩ \ ( ) ( \ ) ( \ ) The shaded areas for and A B C A B A C ∪ = ∩ are the same. Thus \ ( ) ( \ ) ( \ ) A B C A B A C

  27. Venn Diagram Exercise ∩ = ∪ Is it true that \ ( ) ( \ ) ( \ ) ? A B C A B A C ∪ ∩ = ∪ ∩ Is it true that ( ) ( ) ? A B C A B C ∩ ∪ ⊆ ∩ ∪ Is it true that ( ) ( ) ? A B C A B C

  28. ∩ = ∪ Is it true that \ ( ) ( \ ) ( \ ) ? A B C A B A C Yes 1. No 2. Don’t know 3. 0% 0% 0% s o w e N o Y n k t ’ n o D

  29. ∪ ∩ = ∪ ∩ Is it true that ( ) ( ) ? A B C A B C Yes 1. No 2. Don’t know 3. 0% 0% 0% s o w e N o Y n k t ’ n o D

  30. ∩ ∪ ⊆ ∩ ∪ Is it true that ( ) ( ) ? A B C A B C Yes 1. No 2. Don’t know 3. 0% 0% 0% s o w e N o Y n k t ’ n o D

  31. Size of set � Notation: # A denotes the number of elements in the set A. � E.g. � � �

  32. 0% e v o b a e h t f 0% o e n 3 o N 0% 2 0% 1 None of the above B 1. 1 3. 3 2. 2 A 4.

  33. Membership tables 1 ( ) ( ) ( ) ∩ ∪ = ∩ ∪ ∩ Example : To show we must show that A B C A B A C ( ) ∩ ∪ whenever is an element of x A B C ( ) ( ) ∩ ∪ ∩ then it is also a member of A B A C and vice - versa. We can do this by considerin g the various possibilit ies for ' s member ship of and . x A, B C ∉ ∈ ∉ For example if , and then we may deduce x A x B x C ( ) ( ) ( ) ( ) ∉ ∩ ∉ ∩ ∉ ∩ ∪ ∩ , and x A B x A C x A B A C ( ) ( ) ∈ ∪ ∉ ∩ ∪ and . x B C x A B C We need to check this for all eight cases. We can do this in tabular form...

  34. Membership tables 2 ( ) ( ) ( ) ∩ ∪ ∩ ∪ ∩ B ∪ A ∩ A ∩ A B C A B A C C C C A B B 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 0 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 ∈ ∉ In the table we place 1 under if and 0 if . SET x SET x SET

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend