110 likes | 219 Views
Intro to Maths for CS: 2012/13 Sets (week 1 part). John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK. Mathematical “sets”: Basics.
E N D
Intro to Maths for CS:2012/13Sets (week 1 part) John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK
Mathematical “sets”: Basics • A “set” is an unordered collection of items of any sorts (people, numbers, numerals, shoes, atoms, strings of characters, databases, sets, blades of grass, …) without any duplication of items. • The items are called “elements” or “members”. • S = {34, JAB, 59, UoB}, where “JAB” is a name for me and “UoB” is a name for this university, • means that • S is the set consisting of (exactly) the following four items: • the abstract number 34, me, the abstract number 59, this university.
Basics, contd • {34, JAB, 59, UoB} = {UoB, 59, 34, JAB, JAB, 34} • Order of writing the members doesn’t matter; duplication in the writing doesn’t duplicate the member. • A set can be infinite (e.g., the set of all whole numbers). • A set can contain just one member (e.g. the set whose only element is your favourite pencil). Singleton set. • It’s different from the member itself.. • There’s a set with no members at all: the “empty set”, usually notated as , but can also be written { }. • Somewhat analogous to zero, or a new committee which has no members yet. • There is only one empty set (rather than an empty set of numbers, an empty set of pencils, etc.)
Another Notation • {n | n is an integer, n > 301} = • “The set of n such that n is an integer and n > 301.” • (Actually, this notation is a slight simplification.) • The set is the same as that denoted by, for instance, • {n | n is an integer, n 302}.
Some More Examples • {JAB, “JAB”} has 2 members: me, and a 3-char string. • {3, {4,5}, 4, 6}has 4 members, one of which is a set. • {3, {5,4}, 4, 6} is that same set. • { {4,5} } has 1 member, which is a set. • {4,5} has 2 members, both numbers. • {} has 1 member, which is the empty set. • {{}} is a different singleton set.
Membership Relationship • a A means that ais a member of A. • 5 {4,5} • {5,4} {3, {4,5}, 4, 6} • a A means that a is not a member of A. • 5 {3, {4,5}, 4, 6} • {5}{3, {4,5}, 4, 6} • {4,6} {3, {4,5}, 4, 6} • {3,4,5} {3, {4,5}, 4, 6}
Subsets and Supersets • A Bmeans that A is a “subset” of B (and that B is a “superset” of A). I.e., every member of A is also a member of B. • Carefully distinguish between subset-of and member-of!!! • The symbol means the same as • does NOTmean that there cannot be equality. • Examples: • {4,5} • {5} {4,5,6}, {6,4} {4,5,6,7}, {6,4,7,5} {4,5,6,7} • {n | n is an EVEN whole number} {n | n is a whole number}
Subsets and Supersets • Afor any set A. • A Afor any set A. (Reflexivity) • If A BandBA then A = B. (Antisymmetry) • If A BandBC then AC. (Transitivity)
Some Operations on Sets • Union of sets A and B: • AB = the set of things that are in A or B (or both). • NB: no repetitions created. • Intersection of sets A and B: • A B = the set of things that are in both A and B. • Difference of sets A and B: • A B = the set of things that are in A but not B. • Note: also notated by a backslash instead of a minus sign.
Some Properties of those Operations • Union and intersection are commutative • (“can switch”): • AB = BA • A B = B A • Union and intersection are associative • (“can group differently”): • A (B C) = (AB) C • A (B C) = (A B) C • Because of associativity, we can omit parentheses: • AB C D A B C D
Two Other Properties • Union distributes over intersection: • A(B C) = (AB) (A C) • Intersection distributes over union: • A(B C) = (AB) (A C)