ICS-252 Discrete Structure II

  ICS-252 Discrete Structure II Lecture 8

  Salah Omer Assistant Professor Department of Computer Science & Assistant Professor, Department of Computer Science & Engineering, University of Hail, KSA.

  Email: [email protected] ICS ‐252       Dr.Salah Omer, Assistant  Professor,  CSSE, University  of  Hail. 

Outlines

  • Properties of relations (522-524) • Properties of relations (522-524)
  • Closures of relations (544->Equivalence relations only (555-557)
  • Partial orderings (566-
  • Hasse diagram • Hasse diagram
  • Lattices
  • ICS

      ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

    Properties of Relations

      There  are several properties that are used to classify relations on a  set.

       

      Reflexive:    A relation R on a set A is called Reflexive if (a,a)

      אR for every element a א A. Consider the following relations on A= {1 2 3 4}: Consider the following relations on A= {1,2,3,4}:

    Example: Example:

      R ={(1,1),(1,2),(2,1),(2,2),(3,4),(4,1),(4,4)},

      1 R ={(1,1),(1,2),(2,1)},

      2 R ={(1,1),(1,2),(1,4),(2,1), (2,2),(3,3),(4,1), (4,4)},

      3 R ={(2,1),(3,1),(3,2),(4,1),(4,2),(4,3)},

      4 R ={(1,1),(1,2), (1,3),(1,4), (2,2),(2,3),(2,4),(3,3),(3,4),(4,4)},

      5 R ={(3,4)}

      6 ICS ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail.  3 Properties of Relations

      Which of those are reflexive? The relations R and R are reflexive because they

    Solution:

      3

      5

      both contain all pairs of form (a,a), namely, (1,1), (2,2), (3,3),(4,4). The other relations are not reflexive because they do not contain all these ordered pairs.

      The relation R on a set A is called symmetric of

    Symmetric:

      (b,a) א R whenever (a,b) א R for all a,b א A. A relation R on a set A such that for all a,b

      א A if (a,b) א R and (b,a) א R, then a=b is called anti-symmetric. Which of the relations form above example are Which of the relations form above example are

    Example: Example:

      symmetric and anti-symmetric?

      ICS ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

    Properties of Relations

      The relations R and R are symmetric, because in

    Solution:

      2

      3 each case (b,a) belongs to relation whenever (a,b) does.

      For R the only thing to check is that both (2,1) and (1,2)

      2

      are in the relation. For R ,it necessary to check that both

      3

      (1 2) and (2 1) belong to the relation and (1 4) (4 1) belong (1,2) and (2,1) belong to the relation, and (1,4) ,(4,1) belong to the relation. R R R and R are all anti-symmetrical

      1, 4 ,

      5

      6 For each of these relations there are no pair of elements

      a,b with a ≠b such that both (a,b) and (b,a) does not belong to relation.

      A relation R on a set A is called transitive if

    Transitive:

      whenever (a b) whenever (a,b) א R and (b,c) א R then (a,c) א R for all a,b,c א R and (b c) א R then (a c) א R for all a b c א A.

      Which of the relations are transitive in the above

    Example:

      example? ICS

      ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail.  5 Properties of Relations

      The relations R , R and R are transitive,

    Solution:

      4

      5

      6

      because in each case it can be verify that if (a,b) and (b,c) belongs to relation, then (a,c) also does. For instance R is

      4

      transitive because (3,2) and (2,1), (4,2) and (2,1),(4,3) and ( , ), ( , ) (3,1), (4,3) and (3,2) are only such set of pairs, and ( , ) y p , (3,1),(4,1) and (4,2) belongs to R Similarly it can be 4. verified for R and R .

      5

      6 Closure of Relations

      Let R be a relation on a set A. R may

    Closure of relations:

      or may not have some property of P (reflexivity, symmetry, or transitivity). If there is a relation S with property P containing R such that S is a subset of every relation with property P containing R, then S is called the closure of R with respect to P with respect to P

      The relation R={(1,1), (1,2), (2,1), (3,2)}

    Reflexive closure:

      on the set A= {1, 2, 3} is not reflexive. We can make it reflexive by adding (2,2) and (3,3) to R. Because these are the only pairs of the form (a,a) that are not in R. This new relation is called reflexive closure . We can write

      a a a A R where Δ = {( , ) | ∈ }

      U Δ

      The relation R={(1,1), (1,2), (2,2), (2,3),

    Symmetric closure:

      (3,1), (3,2)} on the set A= {1, 2, 3} is not symmetric. We can make it symmetric by adding (2,1) and (1,3) to R. ICS 7

      ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail.  Closure of Relations

      Because these are the only pairs of the form (b,a) with

      a b R

      ( , ) ∈ that are not in R. This new relation is called

      symmetric closure of R.

      Mathematically we can write;

      −

      U U = {( , ) | > } {( , ) | > } = {( , ) | ≠ }

      The relation R={(2,1), (3,2), (4,2), (4,3)}

    Transitive closure:

      on the set A= {1, 2, 3, 4} is not Transitive. We can make it transitive by adding (3,1) and (4,1) to R. This new relation is called transitive closure .

      Equivalence Relation

      A relation on a set A is called an

    Equivalence relation:

      equivalence relation if it is reflexive, symmetric and transitive . Two elements a and b that are related by

      equivalence relation are called equivalent. the notation a ~ b is often used to denote that a and b are equivalent elements with respect to a particular equivalence relation. elements with respect to a particular equivalence relation

      Congruence Modulo m: Let m be a positive

    Example:

      integer with m > 1. Show that the relation R={(a,a) | a

      ≡ b (mod m)} is the equivalence relation on set of integers. We know that a

    Solution:

      ≡ b (mod m) if and only if m divided a - b. Also a – a = 0 is divisible by m, because 0 = 0.m. Hence a

      ≡ a (mod m), so congruence modulo m is reflexive. ICS 9

      ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail.  Equivalence Relation

      Now suppose a ≡ b (mod m). Then a - b is divisible by m. So a – b = km, where k is an integer. It follows that b – a = (-k)m, so b

      ≡ a (mod m). Hence congruence modulo m is symmetric. Next suppose that a

      ≡ b (mod m) and b ≡ c (mod m). Then m divides both a-b and b-c. Therefore, there are integers k and s with a - b= km and b – c = sm. Adding these two equations, shows that a - c=(a - b) + (b - c)= (k + s)m, Thus a

      ≡ c (mod m). Congruence modulo is transitive and equivalent.

      Partial Orderings

      A relation R on a set S is called a partial

    Partial Ordering:

      ordering or partial order if it is reflexive , anti-symmetric and transitive . A set S together with a partial ordering R is called a partially ordered set or poset, and is denoted by (S,R). Members of S are called elements of poset.

      Example 1: Show that the “greater than or equal” relation

      ( ≥)is a partial ordering on Z a set of integers.

      Solution: Because a

      ≥ a for every integer a, therefore ≥ is reflexive. If a ≥ b and b ≥ a, then it means a = b. But a>b, then b can not be > a Hence

      ≥ is anti-symmetric. Finally, ≥ is transitive because a ≥ b and b ≥ c imply that a ≥ c. It follows that

      ≥ is a partial ordering on a set of integers and (Z, ≥) is poset.

      Example 3: Show that the inclusion relation

      ك is a partial ordering on the power set of a set S. ICS 11

      ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail.  Partial Orderings

      Solution: As A

      ك A whenever A is a subset of S, ك is reflexive. It is Anti-symmetric because A ك B and B ك A imply that A = B. Finally,

      ك is transitive, because A ك B and B ك C imply that A ك C. Hence ك is a partial ordering on P(S) and (P(S),

      ك) is a poset.

      Example: Let R be the relation on the set of people such that

      xRy if x and y are people and x is older than y. Show that R is not a partial ordering.

      Solution: R is anti-symmetric because if a person x is older

      than a person y, then y is not older than x. That is if xRy, then y℟x is not possible. The relation R is transitive because if a person x is older than person y and y is older then person z, then x is older then z. that is , xRy and yRz, then xRz. However, R is not reflexive, because no person is older than himself or herself. That is, x℟x for all people x. it follows that R is not a partial ordering and poset.

      z Partial Orderings

      A symbol is required when we discuss the ordering relation in an arbitrary posets. The notation a ع b is used to denote (a,b)

      א R in an arbitrary posets (S,R). This notation is used because ' less than or equal to' on a set of real numbers is a most familiar example of a partial ordering and the symbol

      ع is similar to ≤ symbol. ICS

      13 ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

      Hasse Diagrams Constructing a Hasse Diagram: To construct the Hasse

      diagram complete the following steps; 1) Because a partial ordering is reflexive, a loop is present at every vertex. Remove all loops 2) Remove all edges that must be in the partial ordering because of the presence of other edges and transitivity.

      For example, if (a,b) and (b,c) are in the partial ordering then remove (a,c), because it must be present also. 3) Finally remove all arrows on the directed edges, because all edges point upward toward their terminal vertex. g p p

      These steps are well defined, and only a finite number of steps need to be carried out for a finite poset. When all steps have been taken, the resulting diagram contains sufficient information to find the partial th ordering. This diagram is called Hasse diagram, named after the 20 century German mathematician Helmut Hasse.

      Hasse Diagrams Example: Consider the figure 2 (a) at (page DMA-571). Apply all 3 steps to obtain the Hasse diagram as shown in figure 2 (c).

      Greatest element: Greatest element: An element in a poset that is greater than every other An element in a poset that is greater than every other element is called greatest element. That is a greatest element of the poset (S,

      ع) if b ع a for all b א S. The greatest element is unique when it exist.

      Least element: An element in a poset that is less than every other element is called least element. That is a is a least element of the poset (S,

      ع) if a ع b for all b א S. The least element is unique when it exist. ICS

      15 ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail.  4 4 4 4 page DMA-571 2

      3 3 2 3 2 2 3

      1 1 1 1 a c b d

      Hasse Diagrams Example: Determine whether the posets represented in each

      of the Hasse diagram in figure 6 (page DMA-573) have a greatest element and a least element.

      1) The upper bounds of {a,b,c} are e,f,j, and h and its lower bound is a. 2) There are no upper bounds of {j,h}, and its lower bounds are a, b, c,d,e, and f. 3) The upper bounds of {a,c,d,f} are f, h and j and its lower bound is {d, e, b, c, a}.

      subsets {a,b,c}, {j,h}, and {a,c,d,f} in the poset with the Hasse diagram shown in figure 7 (at page 574).

      Example 18: Find the lower and upper bounds of the Example 18: Find the lower and upper bounds of the

      א A, then L is called an Lower bound of A.

      If L is an element of S such that L ع a for all elements a

      א A, then u is called an Upper bound of A.

      If U is an element of S such that a ع u for all elements a

      Hasse Diagrams

      d) The poset with Hasse diagram has least element a and greatest element d. 17 ICS ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

      c) The poset with Hasse diagram has no least element. Its the greatest element is d.

      I

      ) Th i h H di h l l

      b) The poset with Hasse diagram has neither a least or nor greatest element.

      The poset has no greatest element.

      Solution: Solution: a) The least element of the poset with Hasse diagram is a.

    Upper bound:

    Lower bound:

    Solution:

      Hasse Diagrams

      x is called the least upper bound of A

    Least upper bound:

      if a ع x whenever a א A, and x ع z whenever z is an upper bound of A. y is called the greatest lower bound

    Greatest lower bound:

      of A if y is lower bound of A and z ع y whenever z is lower bound of A.

      Find the greatest lower bound and the least

    Example 19:

      upper bounds of {b,d,g}, if they exist in the poset shown in figure 7 (at page 574).

    Solution:

      1) The upper bounds of {b,d,g} are g and h because g < h therefore g is the least upper bound. 2) The lower bounds of {b,d,g} are a and b. Because a<b, therefore b is the greatest lower bound. ICS 19

      ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail.  Lattices

      A poset (partially ordered set) in which every pair

    Lattices:

      of elements has both a least upper bound and a greatest lower bound is called a Lattices. It has many special properties. It is used in many different applications such as models of information flow; and play an important role in models of information flow; and play an important role in Boolean algebra.

      

    In many settings the flow of Lattices model of information flow: information from one person or computer to another is restricted via security clearances. We can use a lattice model to represent different information flow polices. For example, one common information flow policy is the multilevel security policy used in government and military systems. Each piece of information is assigned to a security class, t E h i f i f ti i i d t it l and each security class is represented by a pair (A,C) where A is an authority level and C is a category. People and computer programs are then allowed access to information from specific restricted set of security classes. Lattices

      Determine whether the poset represented by

    Example 21:

      each of the Hasse diagram in figure 8 (at page DMA-575) are lattices.

    Solution:

      a) i) The upper bounds of {b d e} are e and f because e < f , therefore e is the least upper bound. The lower bounds of {b,d,e} are a and b , because a < b , therefore b is the greatest lower bound. ii) The upper bounds of {b,c,e} are e and f , ) { } because e < f , therefore e is the least upper bound. The lower bounds of {b,c,e} are a and b , because a < b , therefore b is the greatest lower bound. 21 Hence it is a Lattice. ICS

      a) i) The upper bounds of {b,d,e} are e and f ,

      ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

    Lattices

      b) It is not a lattice, because the element b and c have no least upper bound. Note that b and c have d, e, and f upper bounds.

      c) i) The upper bounds of {d,g} are g and h , because g < h therefore g is the least upper bound because g < h , therefore g is the least upper bound. The lower bounds of {d,g} are a and d , because a < d , therefore d is the greatest lower bound. ii) The upper bounds of {b,e} are e and h , because e < h , therefore e is the least upper bound. The lower bounds of {b,e} are a and b , because a < b , therefore b is the greatest lower bound.

    Home Work

      For each of these relations on the set {1,2,3,4},

    Question 1:

      decide whether it is reflexive, symmetric, anti-symmetric and transitive. R1= {(2,2), (2,3), (2,4), (3,2), (3,3), (3,4)} R2= {(1,1), (1,2), (2,1), (2,2), (3,3), (4,4)} R3= {(2,4), (4,2)} R4= {(1,2), (2,3), (3,4)} R5= {(1,1), (2,2), (3,3), (4,4)} R6= {(1 3) (1 4) (2 3) (2 4) (3 1) (3 4)} R6= {(1,3), (1,4), (2,3), (2,4), (3,1), (3,4)}

      Determine whether the relation R on the set of all

    Question 2:

      integers is reflexive, symmetric, anti-symmetric and/or transitive. Where (x,y) א R if and only if

      a) x ≠ y b) xy >= 1 c) x ≡ y (mod 7) ICS 23

      ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

    Home Work

      Let R be the relation on the set {0,1,2,3} containing

    Question 3:

      the ordered pairs (0,1),(1,1),(1,2),(2,0),(2,2), and (3,0). Find the a) Reflexive closure of R

      b) Symmetric closure of R if A {1 2 3 4} th if A= {1,2,3,4}, then find the transitive closures of fi d th t iti l f

      Q Question 4: ti

      4

      the following relations; R1= {(1,2), (2,1), (2,3), (3,4), (4,1)} R2= {(2,1), (2,3), (3,1), (3,4), (4,1), (4,3)} R3= {(1,2), (1,3), (1,4), (2,3), (2,4), (3,4)} R4= {(1,1), (1,4), (2,1), (2,3), (3,1), (3,2), (3,4), (4,2)}

      Which of these relations on A= {0,1,2,3} are

    Question 5:

      equivalence relations? R1={(0,0), (1,1), (2,2), (3,3)}

    Home Work

      R2={(0,0), (0,2), (2,0), (2,2), (2,3), (3,2), (3,3)} R3={(0,0), (1,1), (1,2), (2,1), (2,2), (3,3)} R4={(0,0), (1,1), (1,3), (2,2), (2,3), (3,1), (3,2), (3,3)} R5={(0,0), (0,1), (0,2), (1,0), (1,1), (1,2), (2,0), (2,2), (3,3)}

      Draw the Hasse diagram representing the partial

    Question 6:

      odering {(a,b)|a divides b} on {1,2,3,4,6,8,12} as shown in figure 3 (a) at page 572.

      Determine whether the posets with these Hasse

    Question 7:

      diagrams (see at page 580) are lattices. diagrams (see at page 580) are lattices ICS

      25 ‐252       Dr.Salah Omer, Assistant Professor, CSSE, University  of  Hail.