Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 04: SETS AND FUNCTIONS 1.6, 1.7, 1.8 Jarek Rossignac CS1050:

Similar presentations


Presentation on theme: "1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 04: SETS AND FUNCTIONS 1.6, 1.7, 1.8 Jarek Rossignac CS1050:"— Presentation transcript:

1 1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Lecture 04: SETS AND FUNCTIONS 1.6, 1.7, 1.8 Jarek Rossignac CS1050: Understanding and Constructing Proofs Spring 2006

2 2 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Lecture Objectives Sets, specification, notation, construction Power sets, ordered pairs, relations Operations on sets and pointsets Functions and composition

3 3 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is a set? Unordered collection of elements (members) A set contains its members We may define a set by listing its elements S = {a,b,c} S={1,2,3…} or by a property (set builder notation) S = {a: a  Z  (  k  Z a=2k+1) } S = {x : x is a positive integer less than 200 and divisible by 3}

4 4 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What are the important sets of numbers? R = {real numbers} Q = {p/q : p  Z, q  Z, q≠0} Z = {… –1, 0, 1, ….} integers N = {0,1,2….} natural numbers Z + = {1,2,3 ….} positive integers

5 5 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac When are two sets equal? When they have the same elements {a,b,c} = {a,c,b} = {a,b,c,b,b}

6 6 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is a Venn diagram? Graphic depiction of (topological) set relationship Z+Z+Z+Z+ N Z Q R 0

7 7 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What operators/notation are used for sets? Sets in upper case. Elements in lower case. s  Ss is an element of S. s  Ss is not in S |S|number of elements (cardinality) of a finite set S S=TS equals T (equality)  S elements not in S (complement) S  Telements in S and T (intersection) S  Telements in S or T (union) S–T = S  T, elements of S that are not in T (difference) S  T S  T – S  T (symmetric difference) S  TS included in or equal to T (inclusion) S  TS included in (but not equal to) T ( proper inclusion)  empty (i.e. null) set, also denoted {}. Different from {  }

8 8 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What are the subsets of a set S? All sets whose elements are all in S This always includes: The empty set, , since   S The whole set, S, since S  S

9 9 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is the power set of set S? The power set P(S) of set S is the set of all subsets of S. P({a,b}) = { , {a},{b},{a,b}}

10 10 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is the power set of  ? P(  ) = {  } Remember that  is a set, not an element

11 11 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is the power set of {  }? P({  }) = { , {  } } Remember that {  } has one element, which is a set Hence its power set will contain two elements: the empty set  the set itself {  }

12 12 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is an ordered n-tuple? The ordered n-tuple (a,b,c) is the ordered list of elements: a, b, c Two n-tuples are equal, (a,b,c) = (d,e,f), when corresponding elements are equal, (a=d, b=e, c=f).

13 13 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is an ordered pair? An n-tuple of two elements For example, The (x,y) coordinates of a point in the plane The vertices (a,b) of an oriented edge or link in the graph

14 14 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is the Cartesian product of two sets? A  B = {(a,b): a  A, b  B} set of ordered pairs (a,b) such that a is an element of A and b is an element of B {a,b}  {c,d} = {(a,c), (a,d), (b,c), (b,d) } Note that in general, A  B ≠B  A

15 15 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac How to use quantifiers with sets?  s  S means for all s in S  s  S means there exists an element s in S  !s  S means there exists a single element s in S

16 16 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What are unions and intersections of sets? Union: S  T = {u : u  S  u  T} Intersection: S  T = {u : u  S  u  T} S T STSTSTST

17 17 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What are the differences of sets? Complement:  S = {u : u  S}, also denoted !S Implicitly defined in a universal set U as  S = U–S Difference: S–T = S  T = {u : u  S  u  T} Symmetric difference: S  T = (S–T)  (T–S) S T S – T SS S  T

18 18 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Individual exercise Prove that (S  T) – (S  T) = (S–T)  (T–S)

19 19 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac When are two sets disjoint? When their intersection is empty: S  T =  We often have to prove that two or more sets are pairwise disjoint Often it is necessary to test whether two sets are disjoint Components of a car engine do not interfere Objects do not collide in an animation

20 20 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is |S  T| ? The cardinality, |S  T|, is the number of elements of the union, S  T, of the two finite sets S and T. |S  T| = |S| + |T| – |S  T| we need to subtract elements of S  T, since they were counted both in |S| and in |T|.

21 21 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Identities of Boolean operators Identity: A  U=A, A  U=A Idempotence: A  A=A, A  A=A Domination: A  U=U, A  =  Complement: A  A =U, A  A=  Commutativity: A  B=B  A, A  B=B  A, Associativity: A  (B  C)=(A  B)  C, A  (B  C)=(A  B)  C Distributivity: A  (B  C)=(A  B)  (B  C), A  (B  C)=(A  B)  (B  C) !S denotes  S Sand has higher priority than , , and – Complementation: !(!A)=A de Morgan: !(A  B) = !A  !B, !(A  B) = !A  !B Absorption: A  (A  B)=A, A  (A  B)=A

22 22 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Relation between sets and Booleans? Define the propositions A(u)=(u  A) and B(u)=(u  B). Then A  B = { u  U : A(u)  B(u) } A  B = { u  U : A(u)  B(u) } !A = { u  U : ¬ A(u)} Hence, there is a correspondence between  and  (AND, &&)  and  (OR, ||) ! and ¬(AND NOT, &&!)  and F(false) U and T(true) Translate the previous identities into logic

23 23 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Prove !(A  B) = !A  !B using inclusion Hint: To prove that S = T, prove that (S  T)  (T  S) To prove that !(A  B)  !A  !B assume that for some arbitrary x, x  !(A  B) hence ¬(x  A  x  B) hence x  A  x  B hence x  !A  x  !B it follows that x  ( !A  !B) Since our choice of x  !(A  B) was arbitrary,  x  !(A  B) x  ( !A  !B) Hence!(A  B)  !A  !B To prove that !A  !B  !(A  B) … prove that it follows that x  !(A  B)

24 24 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Prove !(A  B) = !A  !B using builder This time we use the set builder notation: !(A  B) = {x: x  A  B} = {x: ¬ (x  A  B)} = {x: ¬ ((x  A)  (x  B))} = {x: ¬ (x  A)  ¬(x  B))} # de Morgan = {x: x  !A  x  !B} = {x: x  (!A  !B)}

25 25 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Prove A  (B  C)=(A  B)  (A  C) using cells Test one element in each cell against both expressions A B C

26 26 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Exercise Provide a concise Boolean expression for the set marked by the green cells A C B

27 27 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Prove !(A  B) = !A  !B using a truth table Test all combinations uAuAuBuBu  !(A  B)u  (!A  !B) ttff tfff ftff fftt

28 28 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac How to represent finite sets? Consider a finite domain U={a,b,c,d….} where |U|<2 20 We can represent any subset of U by listing its elements. But working on such a representation may be expensive. A more efficient representation may be derived if we assume an ordering of the elements. For example the n-tuple (a,b,c,d…) Represent a subset S of U by a classification vector (bit string) V(S) = 0110… which indicates that a  S, b  S, c  S, d  S …

29 29 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac How to perform Boolean operations on sets? Consider 2D arrays A[i][j] and B[i][j] of bits representing digitized versions of 2D sets A and B –(Pixel(i,j)  A)  (A[i][j] ==1)# red if 1, green if 0 –(Pixel(i,j)  B)  (B[i][j] ==1) How to represent and compute A  B?

30 30 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac How to deal with continuous pointsets? Use a constructive model: S=A  (B  C) Provide point/primitive classification methods A.isIn(x,y) returns true if point(x,y)  A For example, if A is rect(lx,ly,hx,hy), then A.isIn(x, y) {return((lx<x)&&(x<hx)&& (ly<y)&&(y<hy));} Provide Boolean classification methods U.isIn(L,R) combines truth values L and R For example, if U is a union operator, then U.isIn(L,R) {return ( L || R );}

31 31 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is Constructive Solid Geometry? A CSG model is a binary tree representing a 3D shape –Leaves represent solid primitives (blocks, spheres, bunnies…) –Nodes represent Boolean operators ( , , –)

32 32 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is a relation from set A to set B? It is a subset of A  B Think of it as links from elements of A to elements of B A relation assigns to each set of A zero or more elements of B A B

33 33 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is a function from A to B A relation assigning exactly one element of B to each element of A. Note that it may assign the same element b  B to two different elements of A. We write it f : A  B (here  is not an implication)  a  A  b  B b=f(a) A is the domain of f A B

34 34 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is the image of S by f? b  B is the image of all elements a  A for which b=f(a) The image f(S) of a subset S of A is the set of the images of elements of S. A B S

35 35 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is the range of a function? The image of A. (The set of images of elements of A). A B

36 36 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac When is a function injective? f is injective (“one-to-one”) when f(x)=f(y)  x=y A B A B Not injective Injective

37 37 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac When is a function surjective? f is surjective (“onto”) when  b  B  a  A f(a)=b A B A B Not surjective Surjective

38 38 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac When is a function bijective? f is bijective when it is both injective and surjective –(“one-to-one” and “onto”) –one-to-one correspondence  b  B  !a  A f(a)=b A B A B Not bijective Bijective

39 39 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is the inverse of a function? The inverse is only defined for bijective functions The inverse f –1 of f maps each b  B to a  A where b=f(a) f –1 (b)=a  b=f(a) A B f A B f –1

40 40 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is the composition of two functions? Let f : A  B and g : B  C The composition f  g : A  C of f and g is defined as f  g(a) = f(g(a))

41 41 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Application to computer graphics Translation Rotation Composition Do rotations and translations commute? T(2,1) R(30) T(2,1)R(30) T(2,1)  R(30)

42 42 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What is the graph of a function? Set of ordered pairs { (a,b) : a  A, b  B, b=f(a) } Sometimes we can plot it –Here f maps points (x,y) on the plane into height f(x,y) = x 2 +2y 4 –1

43 43 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac What are floor and ceiling? The floor  x  of x is the larges integer not exceeding to x The ceiling  x  is the smallest integer ≥ x Properties: x–1<  x  ≤ x ≤  x  < x+1  –x  =–  x ,  –x  = –  x   x+n  =  x  +n,  x+n  =  x  +n Compute  –0.5  and  –0.5  How many bytes (8-bit strings) do you need to encode 100 bits? Prove or disprove  x+y  =  x  +  y 

44 44 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Quick test Let A and B be two sets What is the symmetric difference of A and B? When are A and B disjoint? How would you prove that A=B? What is the cardinality of A  B? What is Constructive Solid Geometry Let f be a function from A to B What property does f have? What is the image of a subset S of A by f? When is f injective? When is the inverse of f defined? What is the floor of –3.2?

45 45 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Assigned Reading Sections 1.6, 1.7, 1.8

46 46 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Assigned Exercises (for quiz) 1.6 p 85 –18 1.7 p 95: –11, 15, 16, 21, 27, 28, 29, 30, 31, 32,33 1.8 p 109-110 –28, 32, 35.b), 38, 40

47 47 Georgia Tech, IIC, GVU, 2006 MAGIC Lab http://www.gvu.gatech.edu/~jarekJarek Rossignac Assigned Project P1 is due Tu Jan 24 (on your PPP) Email TA only if –you did not submit P0. –you plan to have a late submission. –you changed your PPP url.


Download ppt "1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 04: SETS AND FUNCTIONS 1.6, 1.7, 1.8 Jarek Rossignac CS1050:"

Similar presentations


Ads by Google