Computing Fundamentals 1 Lecture 6 A Theory of Sets Lecturer: Patrick Browne Room K308 Based on Chapter 11. A Logical approach.

Slides:



Advertisements
Similar presentations
Set Operations. When sets are equal A equals B iff for all x, x is in A iff x is in B or … and this is what we do to prove sets equal.
Advertisements

Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Instructor: Hayk Melikya
(CSC 102) Discrete Structures Lecture 14.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
The Engineering Design of Systems: Models and Methods
Denoting the beginning
Formal Specification Sets Based on chapter 2 of Formal Specification Using Z David Lightfoot.
Sets Definition of a Set: NAME = {list of elements or description of elements} i.e. B = {1,2,3} or C = {x  Z + | -4 < x < 4} Axiom of Extension: A set.
CS 454 Theory of Computation Sonoma State University, Fall 2011 Instructor: B. (Ravi) Ravikumar Office: 116 I Darwin Hall Original slides by Vahid and.
Discrete Structures Chapter 3 Set Theory Nurul Amelina Nasharuddin Multimedia Department.
EE1J2 – Discrete Maths Lecture 7
Computing Fundamentals 1 Lecture 1 Lecturer: Patrick Browne Room K308 Based on Chapter 1. A Logical approach to Discrete.
Sets 1.
1 Predicates and quantifiers Chapter 8 Formal Specification using Z.
CSE115/ENGR160 Discrete Mathematics 02/10/11 Ming-Hsuan Yang UC Merced 1.
Sets 1.
Sets. Copyright © Peter Cappello Definition Visualize a dictionary as a directed graph. Nodes represent words If word w is defined in terms of word.
1 Set Theory. Notation S={a, b, c} refers to the set whose elements are a, b and c. a  S means “a is an element of set S”. d  S means “d is not an element.
Sets.
Set theory Sets: Powerful tool in computer science to solve real world problems. A set is a collection of distinct objects called elements. Traditionally,
Course Outline Book: Discrete Mathematics by K. P. Bogart Topics:
Chapter 3 – Set Theory  .
Michaelmas Term 2004 Discrete Mathematics CSC 141 Discrete Mathematics Dr. Corina Sas and Ms. Nelly Bencomo
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
Copyright © 2014 Curt Hill Sets Introduction to Set Theory.
DISCRETE COMPUTATIONAL STRUCTURES
CS201: Data Structures and Discrete Mathematics I
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
CompSci 102 Discrete Math for Computer Science
Copyright © Cengage Learning. All rights reserved.
Section 2.1. Section Summary Definition of sets Describing Sets Roster Method Set-Builder Notation Some Important Sets in Mathematics Empty Set and Universal.
Naïve Set Theory. Basic Definitions Naïve set theory is the non-axiomatic treatment of set theory. In the axiomatic treatment, which we will only allude.
ELEMENTARY SET THEORY.
Chapter SETS DEFINITION OF SET METHODS FOR SPECIFYING SET SUBSETS VENN DIAGRAM SET IDENTITIES SET OPERATIONS.
Mathematical Preliminaries
Sets Goal: Introduce the basic terminology of set theory.
Sets and Subsets Set A set is a collection of well-defined objects (elements/members). The elements of the set are said to belong to (or be contained in)
2.1 Sets 2.2 Set Operations –Set Operations –Venn Diagrams –Set Identities –Union and Intersection of Indexed Collections 2.3 Functions 2.4 Sequences and.
CS 285- Discrete Mathematics Lecture 4. Section 1.3 Predicate logic Predicate logic is an extension of propositional logic that permits concisely reasoning.
Chapter 2 With Question/Answer Animations. Section 2.1.
Rosen 1.6, 1.7. Basic Definitions Set - Collection of objects, usually denoted by capital letter Member, element - Object in a set, usually denoted by.
(CSC 102) Lecture 13 Discrete Structures. Previous Lectures Summary  Direct Proof  Indirect Proof  Proof by Contradiction  Proof by Contra positive.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
Discrete Mathematics Set.
Set Theory Concepts Set – A collection of “elements” (objects, members) denoted by upper case letters A, B, etc. elements are lower case brackets are used.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Set Operations Section 2.2.
Notions & Notations (2) - 1ICOM 4075 (Spring 2010) UPRM Department of Electrical and Computer Engineering University of Puerto Rico at Mayagüez Spring.
Fr: Discrete Mathematics by Washburn, Marlowe, and Ryan.
Section 2.1. Sets A set is an unordered collection of objects. the students in this class the chairs in this room The objects in a set are called the.
The Basic Concepts of Set Theory. Chapter 1 Set Operations and Cartesian Products.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Introduction to Set Theory (§1.6) A set is a new type of structure, representing an unordered collection (group, plurality) of zero or more distinct (different)
DISCRETE COMPUTATIONAL STRUCTURES CSE 2353 Fall 2010 Most slides modified from Discrete Mathematical Structures: Theory and Applications by D.S. Malik.
Section 6.1 Set and Set Operations. Set: A set is a collection of objects/elements. Ex. A = {w, a, r, d} Sets are often named with capital letters. Order.
Sets, Permutations, and Combinations. Lecture 4-1: Sets Sets: Powerful tool in computer science to solve real world problems. A set is a collection of.
Sets.
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Set, Combinatorics, Probability & Number Theory
Sets Section 2.1.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
CS100: Discrete structures
Set Operations Section 2.2.
Session – 2 SETS & Operations of SETS
Lecture Sets 2.2 Set Operations.
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
ICOM 5016 – Introduction to Database Systems
Presentation transcript:

Computing Fundamentals 1 Lecture 6 A Theory of Sets Lecturer: Patrick Browne Room K308 Based on Chapter 11. A Logical approach to Discrete Math By David Gries and Fred B. Schneider

Set theory can be defined as an extension of predicate calculus. A set is a collection of distinct elements (e.g. set of integers, set of students). The operations on sets (e.g. union) correspond in a natural way to the logical connectives of logic (e.g. or). Sets

Two methods of describing sets; set enumeration and set comprehension. Set comprehension is defined in terms testing membership in sets. This membership test is the basis for the definition of equality of sets. Sets

Enumerations list elements: –Constants {1,2,3}, –Variables {a,b} Comprehension state properties: –{x:  | 0  x < 5 : 2  x} Represents: –{0,2,4,6,8} The general form of comprehension (11.1) is: –{x:t | R : E} Sets

Recall from Lecture 1 a state is a list of variables with associated values. The evaluation of: {x:t | R:E} in a state yields the set of values from evaluating E[x := v] in the state for each value v in t such that R[x:=v] holds in that state. Notation similar to quantification Sets

A theory of sets concerns sets constructed from some collection of elements. There is a theory of sets of integers, a theory of sets of characters, a theory of sets of sets of integers. The collection of elements is called the domain of discourse or universe of values and is denoted by U. The DOD can be thought of as the type of every set variable in the theory (e.g. DOD is set(  ), then v:set(  )). Universe

When several set theories are being used at the same time, there is a different universe for each. The name U is then overloaded similar to 1 being considered as a real or an integer. Universe

For expression e and a set valued expression S e  S is an expression whose value is the value of the statement “ e is a member of S ”. We can write “ e is not a member of S ” as:  (e  S) or (e  S) The symbol  is treated as conjunctional operator and has the same precedence as equality (=). Set Membership & Equality

(11.3) Axiom, set membership. For expression F:t and set {x|R : E:t} for type t : provided  occurs(‘x’,’F’) F  {x | R : E}  (  x | R : F= E) Example y  {x | x>1 : 3x)}  (  x | x>1 : y=3x) (11.4) Axiom,extensionality S=T  (  x| x  S  x  T) An extensional definition depends only on the content of the set. In contrast, an intentional 1 definition describes how the set was defined or constructed. Set Membership & Equality Recall that F and E are expressions. For example F=z+y-3 is OK but F=x+y+3 is not. In the second case the x in F clashes with the quantified x.

(11.7) Theorem: x  {x| R }  R For any expression y y  {x | R}  R[x:=y] Theorem (11.7) formalizes the connection between sets and predicates; a predicate is a representation for the set of argument- values for which the predicate is true. 2  {x | x>1}  2>1 Sets versus Predicates Substitution Range Free x Bound x Free x Substitution x:=2

(11.8) The principle of comprehension: To each predicate R there corresponds a set comprehension {x|R}, which contains the objects t that satisfy R ; R is called the characteristic predicate of the set. Sets versus Predicates

(11.8) means we can define a set using comprehension and by its characteristic predicate. For example the set comprehension: S = { x | x=3  x=5} And the characteristic predicate: x  S  x=3  x=5 (for all x) Are equivalent. Sets versus Predicates

Theorem (11.10) {x|Q}={x|R} is valid iff Q  R is valid. The above says that if we show that the characteristic predicates of two sets are equivalent can say that the sets are equal. DeMorgan’s Laws for logic can be applied to sets. Sets versus Predicates

Sets examples

Operations on Sets

Three methods for proving set equality: (a) Use Leibniz directly (substitution of equals) (b) Use axiom of Extensionality (11.4) and prove v  S  v  T for an arbitrary value of v. (using element by element) (c) Prove Q  R and conclude {x|Q}={x|R} (using characteristic predicates) Operations on Sets

Let S,T,U,V have type set(t) for some type t. This convention allows us to shorten a definition For example, set cardinality (  S:set(t) | #S =(  x| x  S:1)) If we remove quantifier we lose the type: #S =(  x| x  S : 1) Operations on Sets

The cardinality of Sets denoted by n or #

The cardinality of Sets ( n, # )

The general 3 set problem

Draw a Venn Diagram for the following:

Operations on Sets

Example: EU set The remaining slides contain mainly examples; Let the set EU be the set of all countries in the European Union (old). EU = the set of all countries in the European Union. It could be declared as an enumeration: EU={A,B,DK,F,SF,D,GB,GR,IRL,I,L,NL,P,E,S} The variable homeland can refer to one element in the set EU homeland  EU benelux={B,NL,L}

The Empty Set and Singleton It is possible to have a set with no values, it is called the empty set and denoted as: 0 or { } A set that contains only one element is called a singleton set. For example: {IRL} Note the difference between the set {IRL} and element IRL. Sets are not ordered. There are no duplicates, each element is unique.

Subset or Set inclusion S X X (universal set) S: P X (  is power set) T: P X S z T T The following statements are true: { B,NL} z {B,NL,L} 0 z {B,NL,L} {B,NL,L} z {B,NL,L}

S is a subset of T if every element if of S is an element of T. (11.13) axiom, subset: S  T  (  x | x  S : x  T) (11.14) axiom, proper subset: S  T  S  T  S  T Subset & Superset

(11.15) axiom, superset: T S  S  T (11.16) axiom, proper superset: T  S  S  T The axioms and theorems for set operations are given in the course text and the course web site, only a few are covered in these slides. Subset & Superset

Set Operators Set Equivalence Two values of the same type can be tested to see if they are the same by using the equals sign, as in: x = y Two sets are equal if they contain exactly the same elements. For example the two sets below are equal: {B,NL,L} = {NL, B, L}

Set Operators Set Non-Equivalence Two values of the same type can be tested to see if they are not the same by using the not-equals sign . Two sets are not equal if they do not contain exactly the same elements {B,NL}  {B,NL,L}

Set Operators The membership operator is written: e NL e {B, NL, L} it is true; the Netherlands is a Benelux country General case below: X S.x.x S: P X x:X x e S

Set Operators The non-membership operator is written: IRL  {B, NL, L}; Ireland is not a Benelux country X S.x.x S: P X x:X x  S General case

Set Operators The validity of membership test. The value to be tested for membership must be an element of the underlying type of the set. For example: USA  {B, NL, L} USA  {B, NL, L} is illegal in this context, since USA is not an element of the type EU.

Set Operators Size Cardinality: The number of values in a set is called its size, or cardinality, and is signified with the has sign: #{B,NL,L} = 3 #{IRL} = 1 #IRL illegal, IRL is not a set #  = 0

Set Operators Powersets: The powerset of a set is written PS It is the set of all subsets of S. For example the powerset of the Benelux countries is: P{B,NL,L} ={ , {B},{NL},{L}, {B,NL},{B,L},{NL,L}, {B,NL,L}}

Set Operators:Powersets When a variable is to be declared to have a type that is a set of elements, the type is the powerset of the type of the elements: benelux: PEU This can be read as ‘the variable benelux is a subset of the set of countries EU’ or ‘the variable benelux is a set of EU countries’ (not the set)

Set Operators:Powersets The size of the powerset of a set is equal to two raised to the power of the size of the set. #(PS) = 2 #s #{B,NL,L} = 3 #(P{B,NL,L}) = 8

The complement of S (S) is the set of elements that are not in S but are in the universe. (11.17) axiom, complement: v  S c  v  U  v  S Complement S U

Set Operators: Union The union of two sets is the set containing all the elements that are in either the first set or the second set or both. S T X U = [X] S: P X T: P X T U S T U S = S U T S U 0 = S

Set Operators: Intersection The intersection of two sets is the set containing all the elements that are in the first set and in the second set. S T X U = [X] S: P X T: P X T I S T I S = S I T S I 0 = 0

Set Operators: Difference The difference of two sets is the set containing all the elements that are in the first set and are not in the second set. The shaded area is the difference of S and T. S X [X] S: P X T: P X S \ T S \ T T \ S S \ 0 = S 0 \ S = 0 T

Set Operators: Distributed Union The distributed union of a set of sets is the set containing just those elements that occur in at least one of the component sets. S X [X] S: P X R: P X T: P X { R,S,T} T R {{2,4},{3,1,2},{2,3,4}} = {1,2,3,4}

Set Operators: Distributed Intersection The distributed intersection of a set of sets is the set containing just those elements that occur in all of the component sets. S X [X] S: P X R: P X T: P X { R,S,T} T R

Disjoint Sets Sets that are disjoint have no elements in common; their intersection is the empty set. For disjoint sets T and S the following expression is true: T I S = 0.

More than 2 Disjoint Sets For more that two sets the notation become clumsy, since every pair must have an empty intersection. For example for sets A, B and C to be disjoint the following must be true: A I B = 0 and B I C = 0 and C I A = 0

Partition A sequence of sets is said to partition another larger set if the sets are disjoint and their distributed union is the entire larger set if the sets are disjoint. For example: if disjoint  (  {A,B,C} = T) then partition T For example: may partition Employee.

Relating sets and Boolean Expressions The definition of the set operations reveals a connection between the set operators and the propositional operators. For example, in the definition of , as the phrase “ x  ” of the LHS is distributed inward to the operands S and T of the RHS,  becomes . x  (S  T)  x  S  x  T

Relating sets and Boolean Expressions The properties of propositional operators are reflected as similar properties of set operators, e.g. absorption laws: S  (S  T)  S (type S,T:Boolean) S  (S  T) = S (type S,T:set(t)) The zero laws for props. & sets. S  false  false ( type S:Boolean) S  0 = 0 (type S:set(t))

Set expression E s Propositional expression E p In E s replace symbolswith the symbols giving E p 0false   ScSc  U true

Set Comprehension Example Express: The set of positive integers that are less than 5 Solution {x:  | 0  x  4:x} or {x:  | 0  x <5:x} Or {0,1,2,3,4}