390 likes | 672 Views
Discrete Mathematics. 3. MATRICES, RELATIONS, AND FUNCTIONS. Lecture 5. Dr.-Ing. Erwin Sitompul. http://zitompul.wordpress.com. Homework 4. 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.
E N D
Discrete Mathematics 3. MATRICES, RELATIONS, AND FUNCTIONS Lecture5 Dr.-Ing. Erwin Sitompul http://zitompul.wordpress.com
Homework 4 Prove that for arbitrary sets A and B, the following set equation apply: a) A(A B) = AB b) A (A B) = A B
Solution of Homework 4 Solution: a) A(A B) = (AA) (AB) Distributive Laws = U (AB)Complement Laws = AB Identity Laws b) A(A B) = (AA) (AB) Distributive Laws = (AB)Complement Laws = AB Identity Laws
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 nn. • Example of a matrix, with the size of 34, is:
Matrices • The symmetric matrix is a matrix with aij = aji for each i and j. • The zero-one (0/1) matrix is a matrix whose elements has the value of either 0 or 1.
Relations • A binary relation R between set A and set B is an improper subset of A B. • Notation: R (AB) • 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 • Example: • Suppose A = { Amir, Budi, Cora } B = { Discrete Mathematics (DM), Data Structure and Algorithm (DSA), State Philosophy (SP), English III (E3) } • AB = { (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 (AB) • A is the domain of R, B is the range of R • (Amir,DM) R or Amir R DM • (Amir,DSA) R or Amir RDSA
Relations 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 • The relation on a set is a special kind of relation. • That kind of relation on a set A is a relation of AA. • The relation on the set A is a subset of AA. 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) }.
Representation of Relations 1. Representation using arrow diagrams
Representation of Relations 2. Representation using tables
Representation of Relations 3. Representation using matrices • Suppose R is a relation between A = {a1,a2, …,am} and B = {b1,b2, …,bn}. • The relation R can be presented by the matrix M = [mij] where:
Representation of Relations a1 = Amir, a2 = Budi, a3 = Cora, and b1 = DM, b2 = DSA, b3 = SP, b4 = E3 p1 = 2, p2 = 3, p3 = 4, and q1 = 2, q2 = 4, q3 = 8, q4 = 9, q5 = 15 a1 = 2, a2 = 3, a3 = 4, a4 = 8, a5 = 9
Representation of Relations 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 bterminal 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 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:
Binary Relations • The relations on one set is also called binary relation. • A binary relation may have one or more of the following properties: • Reflexive • Transitive • Symmetric • Anti-symmetric
Binary Relations 1. Reflexive • Relation Ron set Ais reflexiveif (a,a) R for each aA. • Relation R on set A is not reflexive if there exists aA 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 notreflexive because (3,3) R.
Binary Relations 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? Sis notreflexive, because although (2,2) is a member of S, there exist (a,a) S for aN, such as (1,1), (3,3), .... Tis notreflexive because there is even no single pair (a,a) Tthat can fulfill the relation.
Binary Relations • If a relation is reflexive, then the main diagonal of the matrix representing it will have the value 1, or mii = 1, for i = 1, 2, …, n. • The digraph of a reflexive relation is characterized by the loop on each vertex.
Binary Relations 2. Transitive • Relation R on set Ais transitiveif (a,b) R and (b,c) R, then (a,c) R for all a, b, cA.
Binary Relations 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 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? Sis nottransitive, 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) } nottransitive because (3,7) R.
Binary Relations 3. Symmetric and Anti-symmetric • 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. Symmetric relation Anti-symmetric relation
Binary Relations 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 notsymmetric, 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 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 notsymmetric, 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 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 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 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) Rand 3 = 3.
Binary Relations 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? Sissymmetric, because take (3,1) and (1,3) are members of S. Sisnot 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.
Inverse of Relations 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 Example: SupposeP = { 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 If M is a matrix representing a relation R, then the matrix representing R–1, say N, is the transpose of matrix M. N = MT, means that the rows of M becomes the columns of N
Homework 5 No.1: 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.2: Represent the relation R, S, and T using matrices and digraphs.