160 likes | 290 Views
SETS. CSC 172 SPRING 2002 LECTURE 20. Sets. Defined by membership relation Atoms many not have members, but may be members ofa set Sets may also be members of sets Membership is “only once” An element can not be a member of a set more than once
E N D
SETS CSC 172 SPRING 2002 LECTURE 20
Sets Defined by membership relation Atoms many not have members, but may be members ofa set Sets may also be members of sets Membership is “only once” An element can not be a member of a set more than once Mulitsets, or bags, can contain elements more than once Sets underlie most information representation
Use of Sets Sturctured sets represent record structures, tables Relational models are used in data base systems Probability space is a kind of set Set theory underlies much (all?) mathematics Real numbers, infinities
Representing sets Extension – list the elements {1, 2, {3, 4}} set with 3 elements Abstraction – describe the elements {x | 3 <= x <= 10 and x is an integer}
Algebra of Sets Union : S T = set of elements in S or T or both (+) Intersection : S T = set of elements in both (*) Difference: S – T = elements in S, not T (-)
Equality of Sets Two sets are equal if they have exactly the same members Two expression involving sets are equivalent () if they produce the same values regardless of what values we assign to the set-variables in the expressions
Algebraic Laws Observations about pairs of equivalent expressions Commutative laws of union, intersection The order of the operands may be reversed Associative laws of union, intersection Operations may be grouped in any order Similar law for union and difference S - (T R) (S – T) - R
Algebraic Laws Distributive laws like x(y+z) = xy + xz 3 different laws for distribution on sets S (T R) (S T) (S R) S (T R) (S T) (S R) (S T) - R (S - R) (T – R)
Empty Set is the identity for union S = S is the annihilator for intersection S = There is no identity for intersection or annihilator for union because no universal “set containing everything” exists S – S = - S = Idempotence : S S = S and S S = S
Proving Equivalences Three approaches • Manipulating known equivalences • Classifying elements by sets of which they are members Venn diagrams and truth-tables • Proving containment in both directions Using definitions of operations
Manipulating Equivlences Substituting an expression for all occurrences of some variable Replacing a subexpression by a known equivalent expression Using transitivity of equivalence If E F and F G then E G Using commutativity of equivalence If E F then F E
Example: (S T) S S S (T R) (S T) (S R) distributive law S (T ) (S T) (S ) R S (S T) (S ) Annihilation S (S T) S Identity S (S T) S Identity (S T) S S Commutititvity of
Enumerating Cases If there are n sets in an expession, we can divide elements into 2n classes, dependin on whether they are in or out of the set
Equivalence Through Containment S T (S is contained in T) means every element of S is an element of T S = T if and only if (S T) and (T S) We can prove the equivalence of two expression by showing the result of each is contained in the other
Example: (S T) S S • If x S then x (S T) definition of “union” If x (S T) then x (S T) S definition of “intersection” If x (S T) S then x S definition of “intersection”