Presentation is loading. Please wait.

Presentation is loading. Please wait.

Jim Williams HONP-112 Week 3.  Set Theory is a practical implementation of Boolean logic that examines the relationships between groups of objects. 

Similar presentations


Presentation on theme: "Jim Williams HONP-112 Week 3.  Set Theory is a practical implementation of Boolean logic that examines the relationships between groups of objects. "— Presentation transcript:

1 Jim Williams HONP-112 Week 3

2  Set Theory is a practical implementation of Boolean logic that examines the relationships between groups of objects.  Set theory has numerous real-life applications in computer systems design, as well as database searching (we will learn more about databases later, but will touch on search concepts today)

3  A set consists of individual elements.  A set is denoted by curly brackets and elements are separated by commas: ◦ {A,E,I,O,U}  A set that has no elements is called the empty set, AKA the null set. ◦ {}

4  The Universal Set (or “Universe”) contains all possible values of whatever type of objects we are studying.  Sets can be infinite (i.e. {all real numbers}), or finite (i.e. {all letters of the alphabet}).  We will only be studying finite (AKA "discrete") sets.  We will use U to denote the universal set. Do not confuse this with the UNION symbol (later).

5  Lets assume we have 2 sets A and B.  B is a subset of A if and only if all the elements in B are also in A.  Every set is a subset of the Universal Set.  Example: {1,2,6} is a subset of {1,2,3,4,5,6}

6 SET B SET A A Venn Diagram can be used to graphically illustrate the relationship between sets. UNIVERSE

7 SET B SET A SET A UNION SET B contains all the elements that are either in A or B. The shaded areas illustrate the union. UNIVERSE SET A SET B

8 SET B SET A SET A INTERSECT SET B contains only the elements that are in A and also in B. The shaded area illustrates the intersection. UNIVERSE

9 SET B SET A SET A COMPLIMENT contains only the elements that are not in a given set. The shaded areas illustrate the compliment of A. UNIVERSE

10  Union: ⋃ ◦ Example: A ⋃ B  Intersection: ⋂ ◦ Example: A ⋂ B  Compliment: ' ◦ Example: A'

11  Define Universal Set = All U.S. Coins  U={penny, nickel, dime, quarter, half-dollar, dollar}  Set A = {penny, nickel}  Set B = {nickel, dime, dollar}

12  U={penny, nickel, dime, quarter, half-dollar, dollar}  Set A = {penny, nickel}  Set B = {nickel, dime, dollar}  A ⋃ B = {penny, nickel, dime, dollar}  IMPORTANT: Notice that the set elements never repeat within a single set of any kind (see there is only one “nickel” element in the result set!) Do not forget this!

13  U={penny, nickel, dime, quarter, half-dollar, dollar}  Set A = {penny, nickel}  Set B = {nickel, dime, dollar}  A ⋂ B = {nickel}

14  U={penny, nickel, dime, quarter, half-dollar, dollar}  Set A = {penny, nickel}  Set B = {nickel, dime, dollar}  A' = {dime, quarter, half-dollar, dollar}

15  U={penny, nickel, dime, quarter, half-dollar, dollar}  Set A = {all denominations over 10 cents.}  Set B = {all coins not silver in color}  What is A ⋃ B? A ⋂ B?  Try some more examples.

16  The UNION set operator functions in a similar manner to the Boolean OR logical operator.  The INTERSECTION set operator functions in a similar manner to the Boolean AND logical operator.  The COMPLIMENT set operator functions in a similar manner to the Boolean NOT logical operator.

17  Given Set A, Set B  The UNION applies a boolean OR to each element of each set.  A result of True (1) for any of these cases qualifies the element to be included in the result set.  Let’s Look at an example…

18  The OR is applied to each element in set A and the corresponding element in set B  Results with 1 are included in the result set.  A ⋃ B = {penny, nickel, dime, dollar} PennyNickelDimeQuarterHalf D. Dollar Set A110000 Set B011001 Result Set 111001 Set A = {penny, nickel} Set B = {nickel, dime, dollar}

19  Given Set A, Set B  The INTERSECT applies a boolean AND to each element of each set.  A result of True (1) for any of these cases qualifies the element to be included in the result set.  Let’s Look at an example…

20  The AND is applied to each element in set A and the corresponding element in set B  Results with 1 are included in the result set.  A ⋂ B = {nickel} PennyNickelDimeQuarterHalf D. Dollar Set A110000 Set B011001 Result Set 010000 Set A = {penny, nickel} Set B = {nickel, dime, dollar}

21  Given Set A  The COMPLIMENT applies a boolean NOT to each element of the set.  But, remember, that we also have to consider the entire universal set.  This is because a NOT is a unary operator. In this context, it only operates on the elements of a single set. But there are elements in the universal set that are still NOT in A.  (This type of compliment is the “absolute compliment” - which is the only type we are concerned with here).  Let’s look at an example…

22  The NOT is applied to each element in the set we are taking the compliment of. Remember we are still doing this in relation to the universal set!  Results with 1 are included in the result set.  A' = {dime, quarter, half-dollar, dollar} PennyNickelDimeQuarterHalf D. Dollar Set A110000 Result Set 001111 Set A = {penny, nickel}

23  The COMPLIMENT applies a NAND against each element of the universal set and the corresponding elements of the set we are taking the compliment of. PennyNickelDimeQuarterHalf D. Dollar Universe111111 Set A110000 Result Set 001111 Set A = {penny, nickel}

24  The concept we have illustrated in our previous tables is also used in various other computer circuits, and is called BIT-MASKING.  Given a sequence of bits, and a mask (also made up of some chosen sequence of bits), we can apply an AND mask, an OR mask, etc.  We need not worry about what bit-masking is used for right now – or why certain bit sequences may be chosen as a mask.  But we should know HOW to apply a mask to a bit sequence.

25  The resulting bit sequence results from applying an AND against each bit in the sequence, and the corresponding bit in the mask. Result is 00110000. Seq.00110110 Mask11110000 Result00110000 Given a BIT sequence 00110110, and a MASK of 11110000:

26  The resulting bit sequence results from applying an OR against each bit in the sequence, and the corresponding bit in the mask. Result is 11110110. Seq.00110110 Mask11110000 Result11110110 Given a BIT sequence 00110110, and a MASK of 11110000:

27 The AND mask results in 00110000 The OR mask results in 11110110 So, which type of MASK results in having more 1s in the resulting sequence?

28  We can better understand the relationship between Boolean Logic and Set Theory by using a database example.  We will study databases in more depth later – but just keep the concept in mind.  Boolean searches are done against large databases in many situations (think of some).

29  Databases usually use search operators that correspond with the standard Boolean operators of AND, OR, and NOT.  BUT – in the case of searches, they are applied to whether an item being searched for meets certain criteria.

30  To understand this better, we need to think of search criteria in a different way.  Keep in mind that each search criterion will really be creating a separate SUBSET that meets the criterion.  When we search, we can apply boolean operators to connect criteria together in different ways.  So what we are really doing is creating different subsets and applying set operators to them.

31  The OR search operator combines 2 or more subsets into a single larger subset.  Example: Criterion 1: Customers from the 07463 zipcode. Criterion 2: Customers who have made a purchase within the past month.  (Criterion 1) OR (Criterion 2) will create a single subset containing all customers from 07463, along with all the customers who have made a purchase within the past month, regardless of their zip code.

32  The AND search operator selects the records that 2 or more subsets have in common into a single smaller subset.  Example: Criterion 1: Customers from the 07463 zipcode. Criterion 2: Customers who have made a purchase within the past month.  (Criterion 1) AND (Criterion 2) will create a single subset containing the customers from 07463, who also have made a purchase within the past month.

33  The NOT search operator gives us all the records in a set that do not belong to a particular subset.  Example: Criteria 1: Customers from the 07463 zip code.  NOT (Criteria 1) will create a single subset containing the customers who are NOT from 07463.

34  In your college studies you will frequently need to look up books and articles in the library catalog, based on certain criteria (conditions).  The following slides will illustrate some examples of this and hopefully clarify the relationship between boolean search operators and their corresponding “behind the scenes” set operations.  Remember that in these examples the Universal Set is the entire library collection.

35  Consider this: we want to find all books written by Stephen King within the past 5 years.  What we are really doing: Set A: Books written by Stephen King. Set B: All books written within the past 5 years.  If we want books that meet BOTH criteria, what we are looking for is the INTERSECTION between sets A and B.  A library system may allow us to say something like: Author=Stephen King AND date >= 2007.

36  But what if we wanted any book written by Stephen King, or any book (regardless of author) written within the past 5 years.  What we are really doing: Set A: Books written by Stephen King. Set B: All books written within the past 5 years.  If we want books that meet EITHER criteria, what we am looking for is the UNION of sets A and B.  A library system may allow us to say something like: Author=Stephen King OR date >= 2007.

37  But what if we didn’t care for Stephen King’s writing? So, we wanted to find any book NOT written by him.  What we are really doing: Set A: Books written by Stephen King.  If we want books that are NOT in set A, what we are looking for is the COMPLIMENT of set A.  A library system may allow us to say something like: Author IS NOT Stephen King

38  In real life most library searches are more complex.  Example: Mystery books written in the past 5 years, but not by Stephen King.  Set A: All Mystery Books. Set B: All Books written during the past 5 years. Set C: All Books written by Stephen King.  A library system might let us do something like this: Category=Mystery AND Date >= 2007 AND Author IS NOT Stephen King.  In set theory terms, this means: (A ⋂ B) ⋂ C'

39  Know the three set operators  Know how these are related to the three basic boolean operators.  Use these concepts to solve set theory problems.  Use these concepts to apply a given mask to a given bit sequence.  Understand how these concepts are applied to boolean searching of databases.


Download ppt "Jim Williams HONP-112 Week 3.  Set Theory is a practical implementation of Boolean logic that examines the relationships between groups of objects. "

Similar presentations


Ads by Google