0% found this document useful (0 votes)
31 views

Foundation of Computer Science

The document discusses relations and sets. It defines binary and n-ary relations as subsets of Cartesian products of sets. It discusses the domain and range of relations, and provides examples of relations including the equal, less than, and greater than relations on sets. It also discusses types of relations like the empty, full, identity, and inverse relations. It defines properties of relations such as being reflexive, symmetric, antisymmetric, transitive, and equivalence relations. It introduces partial orders and total orders on sets. It discusses representing relations using graphs and Hasse diagrams. Finally, it defines terms related to partial orders like maximal/minimal elements, upper/lower bounds, and greatest lower/least upper bounds.

Uploaded by

kartikmega81
Copyright
© © All Rights Reserved
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)
31 views

Foundation of Computer Science

The document discusses relations and sets. It defines binary and n-ary relations as subsets of Cartesian products of sets. It discusses the domain and range of relations, and provides examples of relations including the equal, less than, and greater than relations on sets. It also discusses types of relations like the empty, full, identity, and inverse relations. It defines properties of relations such as being reflexive, symmetric, antisymmetric, transitive, and equivalence relations. It introduces partial orders and total orders on sets. It discusses representing relations using graphs and Hasse diagrams. Finally, it defines terms related to partial orders like maximal/minimal elements, upper/lower bounds, and greatest lower/least upper bounds.

Uploaded by

kartikmega81
Copyright
© © All Rights Reserved
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/ 7

Whenever sets are being discussed, the relationship between the elements of the sets is the next

thing that comes up. ​Relations​ may exist between objects of the same set or between objects of
two or more sets.
Definition and Properties
A binary relation R from set x to y (written as ​xRy​ ​or​ ​R​(​x​,​y​)​) is a subset of the Cartesian product ​x​×​y​.
If the ordered pair of G is reversed, the relation also changes.
Generally an n-ary relation R between sets ​A​1,…, ​and​ ​An is a subset of the n-ary product ​A​1×​⋯​×​An​.
The minimum cardinality of a relation R is Zero and maximum is ​n​2​n2 in this case.
A binary relation R on a single set A is a subset of ​A​×​A​.
For two distinct sets, A and B, having cardinalities ​m​ and ​n​ respectively, the maximum cardinality
of a relation R from A to B is ​mn.​
Domain and Range
If there are two sets A and B, and relation R have order pair (x, y), then −
● The ​domain​ of R is the set ​{​x​|(​x​,​y​)​∈R
​ ​ for some y in B}​{x|(x,y)​∈R
​ for some y in B}
● The ​range​ of R is the set ​{​y​|(​x​,​y​)​∈R
​ ​ for some x in A}​{y|(x,y)​∈R
​ for some x in A}
Examples
Let, ​A​={1,2,9}​A={1,2,9} and ​B​={1,3,7}​B={1,3,7}
● Case 1 − If relation R is 'equal to' then ​R​={(1,1),(3,3)}​R={(1,1),(3,3)}
● Case 2 − If relation R is 'less than' then ​R​={(1,3),(1,7),(2,3),(2,7)}​R={(1,3),(1,7),(2,3),(2,7)}
● Case 3 − If relation R is 'greater than' then ​R​={(2,1),(9,1),(9,3),(9,7)}​R={(2,1),(9,1),(9,3),(9,7)}
Representation of Relations using Graph
A relation can be represented using a directed graph.
The number of vertices in the graph is equal to the number of elements in the set from which the
relation has been defined. For each ordered pair (x, y) in the relation R, there will be a directed
edge from the vertex 'x' to vertex 'y'. If there is an ordered pair (x, x), there will be self- loop on
vertex 'x'.
Suppose, there is a relation ​R​={(1,1),(1,2),(3,2)}​R={(1,1),(1,2),(3,2)} on set ​S​={1,2,3}​S={1,2,3}, it
can be represented by the following graph −

Types of Relations
● The ​Empty Relation​ between sets X and Y, or on E, is the empty set −

● The ​Full Relation​ between sets X and Y is the set −
X​×​Y
● The ​Identity Relation​ on set X is the set −
{(​x​,​x​)|​x​∈​X​}
● The Inverse Relation R' of a relation R is defined as −
R​’={(​b​,​a​)|(​a​,​b​)​∈​R​}
Example​ −
If​ ​R​={(1,2),(2,3)} ​then​ ​R​′={(2,1),(3,2)}
A relation R on set A is called ​Reflexive​ if
​ ​ is related to a (aRa holds)​∀a
∀​a​∈A ​ ​∈A
​ is related to a (aRa holds)
Example​ − The relation
R​={(​a​,​a​),(​b​,​b​)} ​on​ ​set​ ​X​={​a​,​b​}
is reflexive.
● A relation R on set A is called ​Irreflexive​ if
no​ ​a​∈​A​ is related to a (aRa does not hold)
Example​ − The relation
R​={(​a​,​b​),(​b​,​a​)} ​on​ ​set​ ​X​={​a​,​b​}
is irreflexive.
● A relation R on set A is called ​Symmetric​ if
xRy​⟹y​ Rx​,​∀x​ ​∈​A​ ​and​ ​∀y​ ​∈A

Example​ − The relation
R​={(1,2),(2,1),(3,2),(2,3)} ​on​ ​set​ ​A​={1,2,3}
is symmetric.
● A relation R on set A is called ​Anti-Symmetric​ if
xRy​ ​and​ ​yRx​⟹x​ ​=​y​∀x​ ​∈​A​ ​and​ ​∀y​ ​∈​A
Example​ − The relation
R​={(1,2),(3,2)} ​on​ ​set​ ​A​={1,2,3}
is antisymmetric.
● A relation R on set A is called ​Transitive​ if
xRy​ ​and​ ​yRz​⟹x​ Rz​,​∀​x​,​y​,​z∈
​ ​A
Example​ − The relation
R​={(1,2),(2,3),(1,3)} ​on​ ​set​ ​A​={1,2,3}
is transitive.
● A relation is an ​Equivalence Relation​ if it is reflexive, symmetric, and transitive.
Example​ − The relation
R​={(1,1),(2,2),(3,3),(1,2),(2,1),(2,3),(3,2),(1,3),(3,1)} ​on​ ​set​ ​A​={1,2,3}
is an equivalence relation since it is reflexive, symmetric, and transitive.
Partial Order​: A relation ​R on a set ​S is called a ​partial order if it is Reflexive, Antisymmetric and
Transitive
set S together with a partial ordering R is called a ​partially ordered set (​poset, for short) and is
denote (​S​,​R​)
Partial orderings are used to give an order to sets that may not have a natural one
• We use the notation:
– a≤b, when (a,b)​∈​R
– a<b, when (a,b)​∈​R a
​ nd a​≠​b
• The notation ≤ is ​not to be mistaken​ for “less than”
• The notation ≤ is used to denote ​any​ partial ordering

Total Order
• Definition:
– If (S,≤) is a poset and every two elements of S are comparable, S is called a ​totally ordered set​. The relation
≤ is said to be a ​total order/
• Example
– The relation “less than or equal to” over the set of integers (​Z,​ ≤) since for every a,b∈​Z​, it must be the case
that a≤b or b≤a
– What happens if we replace ≤ with <?
• The relation < is not reflexive, and (​Z,​ <) is not a poset

Lexographical Ordering
• Lexigraphic ordering is the same as any dictionary or phone-book ordering:
– We use alphabetic ordering
• Starting with the first character in the string
• Then the next character, if the first was equal, etc.
– If a word is shorter than the other, than we consider that the ‘no character’ of the shorter word to be less
than ‘a’
– Definition​: Let (A​1​,≤​1​) and (A​2​,≤​2​) be two posets. The ​lexicographic ordering​ ≤ on the Cartesian product
A​1​×A​2​ is defined by
– (a​1​,a​2​) < (a’​1​,a’​2​) if (a​1​<​1​a’​1​) or (a​1​=a’​1​ and a​2​<​2 ​a’​2​)
– If we add equality to the lexicographic ordering < on A​1​×A​2​, we obtain a partial ordering
Diagraph
A ​digraph​ is short for directed graph, and it is a diagram composed of points called ​vertices​ (nodes) and arrows
called ​arcs​ going from a vertex to a vertex.
For example the figure below is a digraph with 3 vertices and 4 arcs.

Hass Diagram
• Like relations and functions, partial orders have a convenient graphical representation: Hasse Diagrams
– Consider the ​digraph​ representation of a partial order
– Because we are dealing with a partial order, we know that the relation must be reflexive and transitive
– Thus, we can simplify the graph as follows
• Remove all self loops
• Remove all transitive edges
• Remove directions on edges assuming that they are oriented upwards
– The resulting diagram is far simpler

Diagraph Hass Diagram


• Of course, you need not always start with the complete relation in the partial order and then trim everything.
• Rather, you can build a Hasse Diagram directly from the partial order
• Example: Draw the Hasse Diagram for the following partial ordering: {(a,b) | a|b } on the set {1, 2, 3, 4, 5, 6, 10, 12,
15, 20, 30, 60} (these are the divisors of 60 which form the basis of the ancient Babylonian base-60 numeral system)

Hass Diagram

We will define the following terms:


• A maximal/minimal element in a poset (S, ≤)
• An element a in a poset (S, ≤) is called ​maximal​ if it is not less than any other element in S. That is:
¬(∃b∈S (a<b))
• If there is one ​unique​ maximal element a, we call it the ​maximum​ element (or the ​greatest​ element)
• The maximum (greatest)/minimum (least) element of a poset (S, ≤)
• An element a in a poset (S, ≤) is called ​minimal​ if it is not greater than any other element in S. That is:
¬(∃b∈S (b<a))
• If there is one ​unique​ minimal element a, we call it the ​minimum​ element (or the ​least​ element)
• An upper/lower bound element of a subset A of a poset (S, ≤)
• Let (S,≤) be a poset and let A⊆S. If u is an element of S such that a < u for all a∈A then u is an ​upper
bound of A
• An element x that is an upper bound on a subset A and is less than all other upper bounds on A is called the
least upper bound on A​. We abbreviate it as lub.
• The greatest lower/least upper bound element of a subset A of a poset (S, ≤)
• Let (S,≤) be a poset and let A⊆S. If l is an element of S such that l < a for all a∈A then l is an ​lower bound
of A
• An element x that is a lower bound on a subset A and is greater than all other lower bounds on A is called
the ​greatest lower bound on A​. We abbreviate it glb.
Example

• Minimal: {a,b}
• Maximal: {c,d}
• There are no unique minimal or maximal elements, thus no minimum or maximum

Example

Give lower/upper bounds & glb/lub of the sets:​ {d,e,f}, {a,c} and {b,d}
● {d,e,f},
o Lower bounds: ​∅​, thus no glb
o Upper bounds: ​∅​, thus no lub
● {a,c}
o Lower bounds: ​∅​, thus no glb
o Upper bounds: {h}, lub: h
● {b,d}
o Lower bounds: {b}, glb: b
o Upper bounds: {d,g}, lub: d because d<g
Example

• Minimal & Minimum element: a


• Maximal elements: b,d,i,j
• Lower bounds: {a,c}, thus glb is c
• Upper bounds: {e,f,g,h,i,j}, thus lub is e
• Lower bounds: {a}, thus glb is c
• Upper bounds: ∅, thus lub DNE
Lattice
• A special structure arises when ​every​ pair of elements in a poset has an lub and a glb
• Definition​: A ​lattice​ is a partially ordered set in which ​every​ pair of elements has both
– a least upper bound and
– a greatest lower bound
• Is the example in figure just above a lattice?
• No, because the pair {b,c} does not have a least upper bound
Example

• This is lattice, because for any pair, there is an lub & a glb
• To show that a partial order is not a lattice, it suffices to find a pair that does not have an lub or a glb (i.e., a
counter-example)
• For a pair not to have an lub/glb, the elements of the pair must first be ​incomparable
• You can then view the upper/lower bounds on a pair as a sub-Hasse diagram: If there is no minimum element in this
sub-diagram, then it is not a lattice

You might also like