Discrete Mathematics Relation.

Slides:



Advertisements
Similar presentations
CSE115/ENGR160 Discrete Mathematics 04/26/12 Ming-Hsuan Yang UC Merced 1.
Advertisements

8.3 Representing Relations Connection Matrices Let R be a relation from A = {a 1, a 2,..., a m } to B = {b 1, b 2,..., b n }. Definition: A n m  n connection.
The Engineering Design of Systems: Models and Methods
Basic Properties of Relations
5/16/20151 You Never Escape Your… Relations. 5/16/20152Relations If we want to describe a relationship between elements of two sets A and B, we can use.
CS2210(22C:19) Discrete Structures Relations Spring 2015 Sukumar Ghosh.
Discrete Structures Chapter 5 Relations Nurul Amelina Nasharuddin Multimedia Department.
Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
Discrete Mathematics Lecture#11.
1 Section 7.1 Relations and their properties. 2 Binary relation A binary relation is a set of ordered pairs that expresses a relationship between elements.
Relations Chapter 9.
Chapter 9 1. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing.
Applied Discrete Mathematics Week 10: Equivalence Relations
Foundations of Discrete Mathematics Chapter 3 By Dr. Dalia M. Gil, Ph.D.
Chapter 4 Relations and Digraphs
April 10, 2002Applied Discrete Mathematics Week 10: Relations 1 Counting Relations Example: How many different reflexive relations can be defined on a.
Chapter 9. Chapter Summary Relations and Their Properties Representing Relations Equivalence Relations Partial Orderings.
Lecture 14 Relations CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
An ordered n-tuple is a set of n objects with an order associated with them. If n objects are represented by x 1, x 2,..., x n, then we write the ordered.
Discrete Math for CS Binary Relation: A binary relation between sets A and B is a subset of the Cartesian Product A x B. If A = B we say that the relation.
R. Johnsonbaugh, Discrete Mathematics 5 th edition, 2001 Chapter 2 The Language of Mathematics.
Chapter 9. Section 9.1 Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
Discrete Structures1 You Never Escape Your… Relations.
Chapter 7: Relations Relations(7.1) Relations(7.1) n-any Relations & their Applications (7.2) n-any Relations & their Applications (7.2)
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Relations.
Discrete Mathematics R. Johnsonbaugh
Relations and their Properties
Relations – Page 1CSCI 1900 – Discrete Structures CSCI 1900 Discrete Structures Properties of Relations Reading: Kolman, Section
§ 每周五交作业,作业成绩占总成绩的 10% ; § 平时不定期的进行小测验,占总成绩的 20% ; § 期中考试成绩占总成绩的 20% ;期终考 试成绩占总成绩的 50% § 每周五下午 1 ; 00—3 : 00 ,答疑 § 地点:软件楼 301.
CHAPTER 3 FUZZY RELATION and COMPOSITION. 3.1 Crisp relation Product set Definition (Product set) Let A and B be two non-empty sets, the product.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
Fall 2002CMSC Discrete Structures1 You Never Escape Your… Relations.
Sets and Subsets Set A set is a collection of well-defined objects (elements/members). The elements of the set are said to belong to (or be contained in)
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
Relations. Important Definitions We covered all of these definitions on the board on Monday, November 7 th. Definition 1 Definition 2 Definition 3 Definition.
Lecture on Relations 1Developed by CSE Dept., CIST Bhopal.
Discrete Mathematics Lecture # 15 Types of Relations (contd.)
DISCRETE COMPUTATIONAL STRUCTURES
Relation. Combining Relations Because relations from A to B are subsets of A x B, two relations from A to B can be combined in any way two sets can be.
1 Discrete and Combinatorial Mathematics R. P. Grimaldi, 5 th edition, 2004 Chapter 5 Relations and Functions.
Problem Statement How do we represent relationship between two related elements ?
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
4. Relations and Digraphs Binary Relation Geometric and Algebraic Representation Method Properties Equivalence Relations Operations.
Unit II Discrete Structures Relations and Functions SE (Comp.Engg.)
Representing Relations Using Matrices A relation between finite sets can be represented using a zero-one matrix Suppose R is a relation from A = {a 1,
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Relations.
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
RelationsCSCE 235, Spring Introduction A relation between elements of two sets is a subset of their Cartesian products (set of all ordered pairs.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Chap. 7 Relations: The Second Time Around
Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and B = {a,b} {( 0, a), (
Section 9.3. Section Summary Representing Relations using Matrices Representing Relations using Digraphs.
Discrete Mathematics Lecture # 17 Function. Relations and Functions  A function F from a set X to a set Y is a relation from X to Y that satisfies the.
Lecture 7: Relations Dr Andrew Purkiss-Trew Cancer Research UK Mathematics for Computing.
Binary Relation: A binary relation between sets A and B is a subset of the Cartesian Product A x B. If A = B we say that the relation is a relation on.
Chapter 5 Relations and Operations
Learn about relations and their basic properties
Relations Chapter 9.
Relations and Digraphs
Applied Discrete Mathematics Week 10: Relations
Representing Relations
CSNB 143 Discrete Mathematical Structures
Introduction to Relations and Functions
Discrete Mathematics 7th edition, 2009
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
Agenda Lecture Content: Relations (Relasi)
Presentation transcript:

Discrete Mathematics Relation

Cartesian Product If A1, A2, …, Am are nonempty sets, then the Cartesian Product of these sets is the set of all ordered m-tuples (a1, a2, …, am), where ai  Ai, i = 1, 2, … m. Denoted A1  A2  …  Am = {(a1, a2, …, am) | ai  Ai, i = 1, 2, … m}

Cartesian Product Example If A = {1, 2, 3} and B = {a, b, c}, find A  B A  B = {(1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c)}

Subsets of the Cartesian Product Many of the results of operations on sets produce subsets of the Cartesian Product set Relational database Each column in a database table can be considered a set Each row is an m-tuple of the elements from each column or set No two rows should be alike

Using Matrices to Denote Cartesian Product For Cartesian Product of two sets, you can use a matrix to find the sets. Example: Assume A = {1, 2, 3} and B = {a, b, c}. The table below represents A × B. a b c 1 (1, a) (1, b) (1, c) 2 (2, a) (2, b) (2, c) 3 (3, a) (3, b) (3, c)

Cardinality of Cartesian Product The cardinality of the Cartesian Product equals the product of the cardinality of all of the sets: | A1  A2  …  Am | = | A1 |  | A2 |  …  | Am |

Subsets of the Cartesian Product Many of the results of operations on sets produce subsets of the Cartesian Product set Relational database Each column in a database table can be considered a set Each row is an m-tuple of the elements from each column or set No two rows should be alike

Introduction Given two sets X and B, its Cartesian product XxY is the set of all ordered pairs (x,y) where xX and yY In symbols XxY = {(x, y) | xX and yY} A binary relation R from a set X to a set Y is a subset of the Cartesian product XxY Example: X = {1, 2, 3} and Y = {a, b} R = {(1,a), (1,b), (2,b), (3,a)} is a relation between X and Y

Domain and range Given a relation R from X to Y, The domain of R is the set Dom(R) = { xX | (x, y) R for some yY} The range of R is the set Rng(R) = { yY | (x, y) R for some x X} Example: if X = {1, 2, 3} and Y = {a, b} R = {(1,a), (1,b), (2,b)} Then: Dom(R)= {1, 2}, Rng(R) = (a, b}

Example of a relation Let X = {1, 2, 3} and Y = {a, b, c, d}. Define R = {(1,a), (1,d), (2,a), (2,b), (2,c)} The relation can be pictured by a graph:

Example Paul Giblock R CSCI 2710 Danny Camper R CSCI 2710 A is a set of students and B is a set of courses A relation R may be defined as “register the course” Paul Giblock R CSCI 2710 Danny Camper R CSCI 2710

Relation on a Single Set Example A is the set of all courses A relation R may be defined as the course is a prerequisite CSCI 2150 R CSCI 3400 R = {(CSCI 2150, CSCI 3400), (CSCI 1710, CSCI 2910), (CSCI 2800, CSCI 2910), …}

Matrix of a Relation 1 if (ai, bj)  R 0 if (ai, bj)  R mij = We can represent a relation between two finite sets with a matrix MR = [mij], where 1 if (ai, bj)  R 0 if (ai, bj)  R mij =

Example Using the previous example where A = {1, 2, 3} and B = {a, b, c}. The matrix below represents the relation R = {(1, a), (1, c), (2, c), (3, a), (3, b)}. a b c 1 2 3

Digraph of a Relation Let R be a relation on A We can represent R using a diagram Each element of A is a circle called a vertex If ai is related to aj, then draw an arrow from the vertex ai to the vertex aj In degree means number of arrows coming into a vertex Out degree means number of arrows coming out of a vertex

Representing a Relation The following three representations depict the same relation on A = {1, 2, 3}. R = {(1, 1), (1, 3), (2, 3), (3, 2), (3, 3)} 1 2 3 1

Properties of relations Let R be a relation on a set X i.e. R is a subset of the Cartesian product XxX R is reflexive if (x,x) R for every xX R is symmetric if for all x, y X such that (x,y) R then (y,x) R R is transitive if (x,y) R and (y,z) R imply (x,z) R R is antisymmetric if for all x,yX such that xy, if (x,y) R then (y,x) R

Partial Order Relations Let X be a set and R a relation on X R is a partial order on X if R is reflexive, anti-symmetric and transitive.

Inverse of a relation Given a relation R from X to Y, its inverse R-1 is the relation from Y to X defined by R-1 = { (y,x) | (x,y)  R } Example: if R = {(1,a), (1,d), (2,a), (2,b), (2,c)} then R -1= {(a,1), (d,1), (a,2), (b,2), (c,2)}

Equivalence relations Let X be a set and R a relation on X R is an equivalence relation on X  R is reflexive, symmetric and transitive.

Equivalence classes Let X be a set and let R be an equivalence relation on X. Let a  X. Define [a] ={ xX | xRa }

Matrices of relations Let X, Y be sets and R a relation from X to Y Write the matrix A = (aij) of the relation as follows: Rows of A = elements of X Columns of A = elements of Y Element ai,j = 0 if the element of X in row i and the element of Y in column j are not related Element ai,j = 1 if the element of X in row i and the element of Y in column j are related

The matrix of a relation (1) Example: Let X = {1, 2, 3}, Y = {a, b, c, d} Let R = {(1,a), (1,d), (2,a), (2,b), (2,c)} The matrix A of the relation R is A = a b c d 1 2 3

The matrix of a relation (2) If R is a relation from a set X to itself and A is the matrix of R then A is a square matrix. Example: Let X = {a, b, c, d} and R = {(a,a), (b,b), (c,c), (d,d), b,c), (c,b)}. Then A = a b c d 1

The matrix of a relation on a set X Let A be the square matrix of a relation R from X to itself. Let A2 = the matrix product AA. R is reflexive  All terms aii in the main diagonal of A are 1. R is symmetric  aij = aji for all i and j, i.e. R is a symmetric relation on X if A is a symmetric matrix R is transitive  whenever cij in C = A2 is nonzero then entry aij in A is also nonzero.

Relational databases A binary relation R is a relation among two sets X and Y, already defined as R  X x Y. An n-ary relation R is a relation among n sets X1, X2,…, Xn, i.e. a subset of the Cartesian product, R  X1 x X2 x…x Xn. Thus, R is a set of n-tuples (x1, x2,…, xn) where xk  Xk, 1 < k < n.

Databases A database is a collection of records that are manipulated by a computer. They can be considered as n sets X1 through Xn, each of which contains a list of items with information. Database management systems are programs that help access and manipulate information stored in databases.

Relational database model Columns of an n-ary relation are called attributes An attribute is a key if no two entries have the same value e.g. social security number A query is a request for information from the database

Operators The selection operator chooses n-tuples from a relation by giving conditions on the attributes The projection operator chooses two or more columns and eliminates duplicates The join operator manipulates two relations

Functions A function f from X to Y (in symbols f : X  Y) is a relation from X to Y such that Dom (f) = X and if two pairs (x , y) and (x , y’)  f, then y = y’ E.g. Dom (f) = X = {a, b, c, d}, Range (f) = {1, 3, 5} f (a) = f (b) = 3, f (c) = 5, f (d) = 1.

Domain and Range Domain of f = X Range of f = { y | y = f (x) for some x  X} A function f : X  Y assigns to each x in Dom (f) = X a unique element y in Range (f)  Y. Therefore, no two pairs in f have the same first coordinate.

One-to-one functions A function f : X  Y is one-to-one  for each y  Y there exists at most one x  X with f (x) = y. Alternative definition: f : X  Y is one-to-one  for each pair of distinct elements x1, x2  X there exist two distinct elements y1, y2  Y such that f(x1) = y1 and f(x2) = y2. Examples: 1. The function f (x) = 2x from the set of real numbers to itself is one-to-one 2. The function f : R  R defined by f (x) = x2 is not one-to-one, since for every real number x, f (x) = f (-x).

Onto functions A function f : X  Y is onto  for each y  Y there exists at least one x  X with f (x) = y, i.e. Range (f) = Y. Example: The function f (x) = ex from the set of real numbers to itself is not onto Y = the set of all real numbers. However, if Y is restricted to Range (f) = R +, the set of positive real numbers, then f (x) is onto.

Bijective functions A function f : X Y is Bijective  f is one-to-one and onto Examples: 1. A linear function f (x) = ax + b is a Bijective function from the set of real numbers to itself 2. The function f (x) = x3 is Bijective from the set of real numbers to itself.

Inverse function Given a function y = f (x), the inverse f -1 is the set {(y, x) | y = f (x)}. The inverse f -1 of f is not necessarily a function. Example: if f (x) = x2, then f -1 (4) = 4 = ± 2, not a unique value and therefore f is not a function. However, if f is a Bijective function, it can be shown that f -1 is a function.

Composition of functions Given two functions g : X  Y and f : Y  Z, the composition f ◦ g is defined as follows: f ◦ g (x) = f( g (x)) for every x  X. Example: g (x) = x2 -1, f (x) = 3x + 5. Then f ◦ g (x) = f (g (x)) = f(3x + 5) = (3x + 5)2 - 1 Composition of functions is associative: f ◦ (g ◦h) = (f ◦ g) ◦ h, But, in general, it is not commutative: f ◦ g  g ◦ f.