# Discrete Mathematics 3. MATRICES, RELATIONS, AND FUNCTIONS Lecture 5 Dr.-Ing. Erwin Sitompul

## Presentation on theme: "Discrete Mathematics 3. MATRICES, RELATIONS, AND FUNCTIONS Lecture 5 Dr.-Ing. Erwin Sitompul"— Presentation transcript:

Discrete Mathematics 3. MATRICES, RELATIONS, AND FUNCTIONS Lecture 5 Dr.-Ing. Erwin Sitompul http://zitompul.wordpress.com

5/2 Erwin SitompulDiscrete Mathematics Prove that for arbitrary sets A and B, the following set equation apply: a)A  (A  B) = A  B b)A  (A  B) = A  B Homework 4

5/3 Erwin SitompulDiscrete Mathematics Solution: a) A  (A  B) = (A  A)  (A  B) Distributive Laws = U  (A  B) Complement Laws  = A  B Identity Laws Solution of Homework 4 b) A  (A  B) = (A  A)  (A  B) Distributive Laws =   (A  B) Complement Laws  = A  B Identity Laws

5/4 Erwin SitompulDiscrete Mathematics Matrices  A matrix is a structure of scalar elements in rows and columns.  The size of a matrix A is described by the number of rows m and the number of columns n, (m,n).  The square matrix is a matrix with the size of n  n.  Example of a matrix, with the size of 3  4, is:

5/5 Erwin SitompulDiscrete Mathematics  The symmetric matrix is a matrix with a ij = a ji for each i and j.  The zero-one (0/1) matrix is a matrix whose elements has the value of either 0 or 1. Matrices

5/6 Erwin SitompulDiscrete Mathematics  A binary relation R between set A and set B is an improper subset of A  B.  Notation: R  (A  B)  a R b is the notation for (a,b)  R, with the meaning “relation R relates a with b.”  a R b is the notation for (a,b)  R, with the meaning “relation R does not relate a with b.”  Set A is denoted as the domain of R. Set B is denoted as the range of R. Relations

5/7 Erwin SitompulDiscrete Mathematics Example: Suppose A = { Amir, Budi, Cora } B = { Discrete Mathematics (DM), Data Structure and Algorithm (DSA), State Philosophy (SP), English III (E3) } A  B = { (Amir,DM), (Amir, DSA), (Amir,SP), (Amir,E3), (Budi,DM), (Budi, DSA), (Budi,SP), (Budi,E3), (Cora,DM), (Cora, DSA), (Cora,SP), (Cora,E3) } Suppose R is a relation that describes the subjects taken by a certain IT students in the May-August semester, that is: R = { (Amir,DM), (Amir, SP), (Budi,DM), (Budi,E3), (Cora,SP) } It can be seen that:  R  (A  B)  A is the domain of R, B is the range of R  (Amir,DM)  R or Amir R DM  (Amir,DSA)  R or Amir R DSA Relations

5/8 Erwin SitompulDiscrete Mathematics Example: Take P = { 2,3,4 } Q = { 2,4,8,9,15 } If the relation R from P to Q is defined as: (p,q)  R if p is the factor of q, then the followings can be obtained: R = { (2,2),(2,4),(2,8),(3,9),(3,15),(4,4),(4,8) }. Relations

5/9 Erwin SitompulDiscrete Mathematics Example: Suppose R is a relation on A = { 2,3,4,8,9 } which is defined by (x,y)  R if x is the prime factor of y, then we can obtain the relation: R = { (2,2),(2,4),(2,8),(3,3),(3,9) }.  The relation on a set is a special kind of relation.  That kind of relation on a set A is a relation of A  A.  The relation on the set A is a subset of A  A. Relations

5/10 Erwin SitompulDiscrete Mathematics 1. Representation using arrow diagrams Representation of Relations

5/11 Erwin SitompulDiscrete Mathematics 2. Representation using tables Representation of Relations

5/12 Erwin SitompulDiscrete Mathematics 3. Representation using matrices  Suppose R is a relation between A = { a 1,a 2, …,a m } and B = { b 1,b 2, …,b n }.  The relation R can be presented by the matrix M = [m ij ] where: Representation of Relations

5/13 Erwin SitompulDiscrete Mathematics a 1 = Amir, a 2 = Budi, a 3 = Cora, and b 1 = DM, b 2 = DSA, b 3 = SP, b 4 = E3 p 1 = 2, p 2 = 3, p 3 = 4, and q 1 = 2, q 2 = 4, q 3 = 8, q 4 = 9, q 5 = 15 a 1 = 2, a 2 = 3, a 3 = 4, a 4 = 8, a 5 = 9 Representation of Relations

5/14 Erwin SitompulDiscrete Mathematics 4. Representation using directed graph (digraph)  Relation on one single set can be represented graphically by using a directed graph or digraph.  Digraphs are not defined to represent a relation from one set to another set.  Each member of the set is marked as a vertex (node), and each relation is denoted as an arc (bow).  If (a,b)  R, then an arc should be drawn from vertex a to vertex b. Vertex a is called initial vertex while vertex b terminal vertex.  The pair of relation (a,a) is denoted with an arch from vertex a to vertex a itself. This kind of arc is called a loop. Representation of Relations

5/15 Erwin SitompulDiscrete Mathematics Example: Suppose R = { (a,a),(a,b),(b,a),(b,c),(b,d),(c,a),(c,d),(d,b) } is a relation on a set { a,b,c,d }, then R can be represented by the following digraph: Representation of Relations

5/16 Erwin SitompulDiscrete Mathematics Binary Relations  The relations on one set is also called binary relation.  A binary relation may have one or more of the following properties: 1.Reflexive 2.Transitive 3.Symmetric 4.Anti-symmetric

5/17 Erwin SitompulDiscrete Mathematics 1. Reflexive  Relation R on set A is reflexive if (a,a)  R for each a  A.  Relation R on set A is not reflexive if there exists a  A such that (a,a)  R. Example: Suppose set A = { 1,2,3,4 }, and a relation R is defined on A, then: (a)R = { (1,1),(1,3),(2,1),(2,2),(3,3),(4,2),(4,3),(4,4) } is reflexive because there exist members of the relation with the form (a,a) for each possible a, namely (1,1), (2,2), (3,3), and (4,4). (b) R = { (1,1),(2,2),(2,3),(4,2),(4,3),(4,4) } is not reflexive because (3,3)  R. Binary Relations

5/18 Erwin SitompulDiscrete Mathematics Example: Given a relation “divide without remainder” for a set of positive integers, is the relation reflexive or not? Each positive integer can divide itself without remainder  (a,a)  R for each a  A  the relation is reflexive Example: Given two relations on a set of positive integers N: S : x + y = 4,T : 3x + y = 10 Are S and T reflexive or not? S is not reflexive, because although (2,2) is a member of S, there exist (a,a)  S for a  N, such as (1,1), (3,3),.... T is not reflexive because there is even no single pair (a,a)  T that can fulfill the relation. Binary Relations

5/19 Erwin SitompulDiscrete Mathematics  If a relation is reflexive, then the main diagonal of the matrix representing it will have the value 1, or m ii = 1, for i = 1, 2, …, n.  The digraph of a reflexive relation is characterized by the loop on each vertex. Binary Relations

5/20 Erwin SitompulDiscrete Mathematics 2. Transitive  Relation R on set A is transitive if (a,b)  R and (b,c)  R, then (a,c)  R for all a, b, c  A. Binary Relations

5/21 Erwin SitompulDiscrete Mathematics Example: Suppose A = { 1, 2, 3, 4 }, and a relation R is defined on set A, then: (a)R = { (2,1),(3,1),(3,2),(4,1),(4,2),(4,3) } is transitive. (b)R = { (1,1),(2,3),(2,4),(4,2) } is not transitive because (2,4) and (4,2)  R, but (2,2)  R, also (4,2) and (2,3)  R, but (4,3)  R. (c)R = { (1,2), (3,4) } is transitive because there is no violation against the rule { (a,b)  R and (b,c)  R }  (a,c)  R. Relation with only one member such as R = { (4,5) } is always transitive. Binary Relations

5/22 Erwin SitompulDiscrete Mathematics Example: Is the relation “divide without remainder” on a set of positive integers transitive or not? It is transitive. Suppose that a divides b without remainder and b divides c without remainder, then certainly a divides c without remainder. { a R b  b R c }  a R c Example: Given two relations on a set of positive integers N: S : x + y = 4,T : 3x + y = 10 Are S and T transitive or not? S is not transitive, because i.e., (3,1) and (1,3) are members of S, but (3,3) and (1,1) are not members of S. T = { (1,7),(2,4),(3,1) }  not transitive because (3,7)  R. Binary Relations

5/23 Erwin SitompulDiscrete Mathematics  Relation R on set A is symmetric if (a,b)  R, then (b,a)  R for all a,b  A.  Relation R on set A is not symmetric if there exists (a,b)  R such that (b,a)  R.  Relation R on set A such that if (a,b)  R and (b,a)  R then a = b for a,b  A, is called anti-symmetric.  Relation R on set A is not anti- symmetric if there exist different a and b such that (a,b)  R and (b,a)  R. 3. Symmetric and Anti-symmetric Symmetric relation Anti-symmetric relation Binary Relations

5/24 Erwin SitompulDiscrete Mathematics Example: Suppose A = { 1,2,3,4 }, and relation R is defined on set A, then: (a)R = { (1,1),(1,2),(2,1),(2,2),(2,4),(4,2),(4,4) } is symmetric, because if (a,b)  R then (b,a)  R also. Here, (1,2) and (2,1)  R, as well as (2,4) and (4,2)  R. is not anti-symmetric, because i.e., (1,2)  R and (2,1)  R while 1  2. (b)R = { (1,1),(2,3),(2,4),(4,2) } is not symmetric, because (2,3)  R, but (3,2)  R. is not anti-symmetric, because there exists (2,4)  R and (4,2)  R while 2  4. Binary Relations

5/25 Erwin SitompulDiscrete Mathematics Example: Suppose A = { 1,2,3,4 }, and relation R is defined on set A, then: (c)R = { (1,1),(2,2),(3,3) } is symmetric and anti-symmetric, because (1,1)  R and 1 = 1, (2,2)  R and 2 = 2, and (3,3)  R and 3 = 3. (d)R = { (1,1),(1,2),(2,2),(2,3) } is not symmetric, because (2,3)  R, but (3,2)  R. is anti-symmetric, because (1,1)  R and 1 = 1 and, (2,2)  R and 2 = 2. Binary Relations

5/26 Erwin SitompulDiscrete Mathematics Example: Suppose A = { 1,2,3,4 }, and relation R is defined on set A, then: (e)R = { (1,1),(2,4),(3,3),(4,2) } is symmetric. is not anti-symmetric, because there exist (2,4) and (4,2) as member of R while2  4. (f)R = { (1,2),(2,3),(1,3) } is not symmetric. is anti-symmetric, because there is no different a and b such that (a,b)  R and (b,a)  R (which will violate the anti-symmetric rule). Binary Relations

5/27 Erwin SitompulDiscrete Mathematics Relation R = { (1,1),(2,2),(2,3),(3,2),(4,2),(4,4)} is not symmetric and not anti-symmetric. R is not symmetric, because (4,2)  R but (2,4)  R. R is not anti-symmetric, because (2,3)  R and (3,2)  R but 2  3. Binary Relations

5/28 Erwin SitompulDiscrete Mathematics Example: Is the relation “divide without remainder” on a set of positive integers symmetric? Is it anti-symmetric? It is not symmetric, because if a divides b without remainder, then b cannot divide a without remainder, unless if a = b. For example, 2 divides 4 without remainder, but 4 cannot divide 2 without remainder. Therefore, (2,4)  R but (4,2)  R. It is anti-symmetric, because if a divides b without remainder, and b divides a without remainder, then the case is only true for a = b. For example, 3 divides 3 without remainder, then (3,3)  R and 3 = 3. Binary Relations

5/29 Erwin SitompulDiscrete Mathematics Example: Given two relations on a set of positive integers N: S : x + y = 4,T : 3x + y = 10 Are S and T symmetric? Are they anti-symmetric? S is symmetric, because take (3,1) and (1,3) are members of S. S is not anti-symmetric, because although there exists (2,2)  R, but there exist also { (3,1),(1,3) }  R while 3  1. T = { (1,7),(2,4),(3,1) }  not symmetric. T = { (1,7),(2,4),(3,1) }  anti-symmetric. Binary Relations

5/30 Erwin SitompulDiscrete Mathematics If R is a relation from set A to set B, then the inverse of relation R, denoted with R –1, is the relation from set B to set A defined by: R –1 = { (b,a) | (a,b)  R }. Inverse of Relations

5/31 Erwin SitompulDiscrete Mathematics Example: Suppose P = { 2,3,4 } Q = { 2,4,8,9,15 }. If the relation R from P to Q is defined by: (p,q)  R if p divides q without remainder, then the members of the relation can be obtained as: R = { (2,2),(2,4),(2,8),(3,9),(3,15),(4,4),(4,8) }. R –1, the inverse of R, is a relation from Q to P with: (q,p)  R –1 if q is a multiplication of p. It can be obtained that: R –1 = { (2,2),(4,2),(8,2),(9,3),(15,3),(4,4),(8,4) }. Inverse of Relations

5/32 Erwin SitompulDiscrete Mathematics If M is a matrix representing a relation R, then the matrix representing R –1, say N, is the transpose of matrix M. N = M T, means that the rows of M becomes the columns of N Inverse of Relations

5/33 Erwin SitompulDiscrete Mathematics Homework 5 For each of the following relations on set A = { 1,2,3,4 }, check each of them whether they are reflexive, transitive, symmetric, and/or anti-symmetric: (a)R = { (2,2),(2,3),(2,4),(3,2),(3,3),(3,4) } (b) S = { (1,1),(1,2),(2,1),(2,2),(3,3),(4,4) } (c) T = { (1,2),(2,3),(3,4) } No.1: No.2: Represent the relation R, S, and T using matrices and digraphs.

Similar presentations