0% found this document useful (0 votes)
63 views5 pages

Relations and Functions: Cartesian Product

The document defines Cartesian products, relations, functions, and some of their properties. It begins by defining the Cartesian product as the set of all ordered pairs where the first element is from set A and the second is from set B. It provides examples of binary, ternary, and n-ary relations. Functions are defined as assignments where each element of the domain maps to a unique element in the range. The document discusses different types of functions and their inverses. It also covers relations in databases and operations on relations.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views5 pages

Relations and Functions: Cartesian Product

The document defines Cartesian products, relations, functions, and some of their properties. It begins by defining the Cartesian product as the set of all ordered pairs where the first element is from set A and the second is from set B. It provides examples of binary, ternary, and n-ary relations. Functions are defined as assignments where each element of the domain maps to a unique element in the range. The document discusses different types of functions and their inverses. It also covers relations in databases and operations on relations.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CARTESIAN PRODUCT

RELATIONS and FUNCTIONS

Definition
Let A and B be sets. The Cartesian Product is the set of all ordered pairs where the first coordinates are in A and the second coordinates are in B. Notation
AB = { (a,b) aA and bB }

Example A = {1,2 } B = { a, b, c } AB = { (1,a),(1,b),(1,c),(2,a),(2,b),(2,c) } BA = { (a,1),(a,2),(b,1),(b,2),(c,1),(c,2) }

CARTESIAN PRODUCT
Cartesian product of 3 or more sets (n-fold product)
AB C = { (a, b, c) aA, bB and cC }

CARTESIAN PRODUCT
Theorems
1. A (BC)=(AB)(AC) 2. A (BC)=(AB)(AC) 3. A= 4. (AB)(CD)=(AC) (BD) 5. (AB)(CD) (AC) (BD)

Product rule
if |A| = m and |B| = n, then |AB| = m*n if |C| = k, |ABC| = m*n*k

RELATIONS
Definition
A relation on two sets A and B is a subset of AB. A relation is specified by an open sentence such as a is less than b or a + b = 5. Examples
1. Let R be the relation from A = { 1, 2, 3, 4 } to B= { 1,3,5 } which is defined by x is less than y . R = { ( x,y ) x is less than y } = { (1,3), (1,5), (2,3), (2,5), (3,5) , (4,5) } 2. Let R be the relation from E = { 2, 3, 4, 5 } to F = { 3, 6, 7, 10 } which is defined by x|y

RELATIONS
binary relation: relation defined on two sets that are
not necessarily distinct

ternary relation: relation defined on three sets that are


not necessarily distinct n-ary relation: relation on n sets unary relation: relation on one set Example
G = { 55, 89, 75, 65, 88, 80, 90 } Define a unary relation R on G: x is an element of R if x>74. R={ 89, 75, 88, 80, 90 }

RELATIONS
domain of a binary relation
set whose elements are all as such that (a,b) R. ( a is related to b or aRb )

RELATIONS
Properties of relations
reflexive. aRa for all a A (every element is related to itself) irreflexive: ab A, aRb ab (every element is not related to itself) symmetric: ab A, aRb bRa antisymmetric: ab A, (aRb bRa) a = b transitive: if aRb bRc then aRc for all a,b,c A

range of a binary relation


set whose elements are all bs such that (a,b) R.

RELATIONS
Properties of relations: Example
Let R be the relation on the set of natural numbers: x is related to y such that x y Reflexive. every natural number is itself Not Symmetric. if x y, y is not necessarily x Antisymmetric: x y y x x = y Transitive: x y y z x z

EQUIVALENCE RELATION
Definition
A binary relation R on a set S is an equivalence relation if R is reflexive, symmetric and transitive. The set on which an equivalence relation is defined can be partitioned into disjoint sets by equivalence classes. A partition of a set S is a collection of nonempty disjoint subsets whose union equals S. For an equivalence relation on a set S if x S [x] denotes the set of all members of S related to x; [x] is called an equivalence class of x.

EQUIVALENCE RELATION
Examples
R on N defined by xRy if x+y is even
R is reflexive, symmetric and transitive. (verify this) R is an equivalence relation Equivalence classes (partition of N)

PARTIAL ORDER RELATION


Definition
A binary relation on S that is reflexive, transitive and antisymmetric is a partial ordering. S is a partially ordered set (a.k.a. the poset (S, R), where R is the partial order relation). Example
R on N = xRy iff x y

R on N where (x, y) R if x mod 4 = y mod 4


Equivalence classes
[0] = { 0, 4, 8, 12, 16, 20 ...} [1] = { 1, 5, 9, 13, 17, 21....} [2] = { 2, 6, 10, 14, 18, 22...} [3] = { 3, 7, 11, 15, 19, 23...}

[0] = { 0, 2, 4, 6, 8......} [1] = { 1, 3, 5, 7, 9......}

Hasse diagram: depicts the partial ordering of the set on which the relation is defined

PARTIAL ORDER RELATION


Examples
R on (A) : x R y x y where x,y (A) A = { a, b } (A) = { {a}, {b}, {a,b}, } R = { ({a,b}, {a,b}) , ({a}, {a,b}), ({a},{a}), ({b}, {b}), ({b}, {a,b}), (, {a}), ( , {a,b}), (, ) } Reflexive. Every set is a subset of itself. Transitive. A B B C A C Antisymmetric. A B B A B = A

PARTIAL ORDER RELATION


Examples
R on S = { 1, 2, 3, 6, 12, 18 } where xRy if x | y
R = { (1,2), (1,1), (1,3), (1,6), (1,12), (1,18), (2,6), (2,12), (2,18), (3,6), (3,12), (3,18), (6,12), (6,18), (18,18),(12,12), (2,2), (3,3), (6,6) }

R on (A) : x R y x y where x, y (A)


A = { a, b, c } (A)={ {a,b,c}, {a,b}, {a,c}, {b,c}, {a}, {b}, {c}, }

R on S = {x |x is a divisor of 12} where xRy if x | y


S = { 1, 2, 3, 4, 6, 12 }

R on { 1, 3, 6, 18 } where xRy if x | y

PARTIAL ORDER RELATION


{a, b} 12 6 {a} {b} 2 3 18

RELATIONS AND DATABASES


Consider the following sets:
A = { Galaxy, IPad, Nokia, PlayBook } B = { iOS, Android, Windows, BB OS, Bada } C = { Samsung, Apple, Nokia, RIM } R on A, B, C is defined by
{(a, b, c) | a is a device using b as its platform and is manufactured by c} A B C = { (Galaxy, Android, Samsung), Galaxy Android Samsung (IPad, iOS, Apple), iPad iOS Apple (Lumia, Windows, Nokia), Lumia Windows Nokia RIM (PlayBook, BB OS, RIM) } PlayBook BB OS

RELATIONS AND DATABASES


Relational database
Database composed of relations; relations are logically implemented as tables
STUDENT (idnum, name, course, year) CLASS (code, room, schedule, subjid) SUBJECT (subjid, desc, units) STUDCLASS (idnum, code, grade)

FUNCTIONS
Definition
A function/mapping, f: A B, is an assignment of an element of set B to every element of another set A. The element of B mapped to an element of A is unique. When a vertical line intersects at a single point in a graph on the x-y plane, the graph represents a function. For a function f: A B
A is the domain, B is the range

Relational operations
Database operations used to update or query information to or from a relational database (implemented in relational databases via SQL)

FUNCTIONS
Examples
f(x) = 4x + 5 f(x) = sin x f(x) = x2 Let A = { 1, 2, 3, 4 }

FUNCTIONS
A 1 f B a b c d A 1 2 3 4 B a b c d f(1) = a f(1) = b

B = { a, b, c, d }
f(4) = d

2 3 4

f: A B = { (1, a), (2, c), (3, d), (4,d) } f(1) = a f(2) = c f(3) = d

Not a function!

FUNCTIONS
Kinds of functions
one-to-one (injective) functions
every element of B is mapped to a unique element of A (a horizontal line intersects at a single point in the graph A f B A 1 2 3 4 f B a b c d 1 2 3 4 a b c d e

FUNCTIONS
Kinds of functions
onto (surjective) functions
every element of B must be mapped to an element of A A 1 2 3 4 f B a b c d A 1 2 3 4 f B a b c d

FUNCTIONS
Kinds of functions
Bijective function
function that is 1-1 and onto (implies a one to one correspondence between pairs) A 1 2 3 4 f B a b c d NOT one-to-one, NOT onto d is mapped to 2 elements f(3) = d = f(4) b is not mapped to any element

FUNCTIONS
Examples
f(x) = 4x + 5 one-to-one f(x) = sin x NOT one-to-one f(x) = x2 NOT one-to-one function that maps the set of countries in the world to the set of capital cities: 1-1 and onto

FUNCTIONS
Inverse of a function f: A B
f -1 : B A Examples
Given f(x) = 4x + 5, f -1(y) = (y-5 )/4 Given f(x) = 2x, then f -1(y) = log 2 y Given A = { 1, 2, 3, 4 } B = { a, b, c, d } and f = { (1, a), (2, c), (3, b), (4, d) } f -1 = { (a, 1), (b, 3), (c, 2), (d, 4) } f -1 (a) = 1, f -1 (b) = 3, f -1 (c) = 2, f -1 (d) = 4

FUNCTIONS
A function f is invertible if its inverse f -1 is also a function
f -1 is also a function if an only if f is one-to-one Examples
the previous examples are invertible (the functions defined are one-to-one)

Examples of functions that are not invertible


f(x) = x2 NOT one-to-one Given A = { 1, 2, 3, 4 } B = { a, b, c, d } and f = { (1, a), (2, a), (3, d), (4, c) } f -1 = { (a, 1), (a, 2), (d, 3), (c, 4) } f -1 (a) = 1, f -1 (a) = 2

FUNCTIONS
Composite functions
fg (x) = f (g(x)) gf (x) = g (f(x)) Example: Let f(x) = x2

g(x) = x + 3

fg (2) = f (2+3) = f(5) = 52 = 25 gf (2) = g (2)2 = g (4) = 4+3 = 7 fg (x) = f (x+3) = (x+3)2 = x2 + 6x + 9 gf (x) = g (x)2 = x2 + 3

You might also like