12+Slides--Relations

12+Slides--Relations - CS103 HO#12 Slides--Relations...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS103 HO#12 Slides--Relations 4/11/11 1 A sequence is a list of objects in some order. Order matters (1, 2, 3) (2, 1, 3) Repetition matters (1, 2, 1) (1, 2) Can be finite or infinite (1, 2) (1, 2, 3, ...) A k-tuple is a finite sequence of k elements (a 1 , a 2 ,..., a k ) An ordered pair is a 2-tuple (a, b) (4, 2) (Bob, CS103) In set theory, we can define the ordered pair (a, b) like this: (a, b) = {{a}, {a, b}} but we will use an intuitive understanding of the concept. Definitions The Cartesian product or cross product of two sets A and B, written A B, is the set of ordered pairs A B = {(a, b) | (a A) (b B)} Definitions A = {red, yellow, green} B = {rose, lily} A B = {(red, rose), (yellow, rose), (green, rose), (red, lily), (yellow, lily), (green, lily)} (red, lily) (red, rose) red (green, lily) (green, rose) green (yellow, lily) (yellow, rose) yellow lily rose The Cartesian product or cross product of two sets A and B, written A B, is the set of ordered pairs A B = {(a, b) | (a A) (b B)} Definitions A = {red, yellow, green} B = {rose, lily} A B = {(red, rose), (yellow, rose), (green, rose), (red, lily), (yellow, lily), (green, lily)} We can have a Cartesian product of more than two sets A 1 A 2 ... A n = { (a 1 , a 2 , ... a n ) | a i A i } or of a set with itself A = {1, 2, 3} A A = {(1,1), (1, 2), (1, 3), (2, 1) (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)} We refer to A A as A 2 , and A A ... A as A k k times A relation on the sets A 1 , A 2 , ... A n is a subset of A 1 A 2 ... A n . We are often interested in relations on two sets, which we call binary relations . The relation picks out the pairs of elements that are of interest or that have some special property. If A = {Bob, Jay, Julie} and B = {178, 180, 184, 187, 191}, there are 15 ordered pairs in A B. If R is the "Has Office" relation, then R = {(Bob, 178), (Jay, 191), (Julie, 184)} Definitions 178 180 184 187 191 Bob x . . . . Jay . . . . x Julie . . x . . BobR178 JayR191 JulieR184 kid age a 4 b 8 c 4 d 7 e 8 f 4 If S is the relation Same Age , then S includes (a, c), (c, a), (a, f), (f, a), (c, f), (f,c), (b, e), (e, b) and also (a, a), (b, b), (c, c) (d, d) (e, e), (f, f) If R is the relation Older Than , then R includes (b, a), (b, c), (b, d), (b, f), (e, a), (e, c), (e, d), (e, f), (d, a), (d, c), (d, f) A binary relation on set A is a set of ordered pairs from A...
View Full Document

This note was uploaded on 06/01/2011 for the course EE 103 taught by Professor Plummer during the Spring '11 term at Stanford.

Page1 / 6

12+Slides--Relations - CS103 HO#12 Slides--Relations...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online