sets

16
SETS CSC 172 SPRING 2002 LECTURE 20

Upload: jennifer-wiggins

Post on 31-Dec-2015

13 views

Category:

Documents


0 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: SETS

SETS

CSC 172

SPRING 2002

LECTURE 20

Page 2: SETS

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

Page 3: SETS

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?) mathematicsReal numbers, infinities

Page 4: SETS

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}

Page 5: SETS

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 (-)

Page 6: SETS

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

Page 7: SETS

Algebraic Laws

Observations about pairs of equivalent expressions

Commutative laws of union, intersectionThe order of the operands may be reversed

Associative laws of union, intersectionOperations may be grouped in any order

Similar law for union and difference

S - (T R) (S – T) - R

Page 8: SETS

Algebraic Laws

Distributive lawslike 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)

Page 9: SETS

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

Page 10: SETS

Proving Equivalences

Three approaches

1. Manipulating known equivalences

2. Classifying elements by sets of which they are members

Venn diagrams and truth-tables

3. Proving containment in both directionsUsing definitions of operations

Page 11: SETS

Manipulating Equivlences

Substituting an expression for all occurrences of some variable

Replacing a subexpression by a known equivalent expression

Using transitivity of equivalenceIf E F and F G then E G

Using commutativity of equivalenceIf E F then F E

Page 12: SETS

Example: (S T) S S

S (T R) (S T) (S R) distributive law

S (T ) (S T) (S ) RS (S T) (S ) Annihilation

S (S T) S Identity

S (S T) S Identity

(S T) S S Commutititvity of

Page 13: SETS

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

Page 14: SETS

Example: (S T) S S

S T S T RHS

0 0 0 0

0 1 1 0

1 0 1 1

1 1 1 1

Page 15: SETS

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

Page 16: SETS

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”