VIEWS: 16 PAGES: 14 POSTED ON: 3/6/2012 Public Domain
WEB NOTES BY Y. SIVA PATVATHI ASST. PROFESSOR IT DEPARTMENT SUBJECT:MFCS Course Introduction: This course introduces students to become reasonably good at problem solving and algorithm development. Students also enhance their ability to think logically and mathematically. Objectives: The objective of this course is to present the foundations of many basic computer related concepts and provide a coherent development to the students for the courses like Fundamentals of Computer Organization, RDBMS, Data Structures, Analysis of Algorithms, Artificial Intelligence, Computer Graphics and others. Basic Properties of Binary Relations on a Set Reflexivity, Symmetry, Transitivity Reflexive relations o Definition o Graph representation o Matrix representation o Reflexive and irreflexive relations Symmetric relations o Definition o Graph representation o Matrix representation o Symmetric and anti-symmetric relations Transitive relations o Definition o Graph representation Learning goals Exam-like problems Basic properties: Let R be a binary relation on a set A. 1. R is reflexive, iff for all x A, (x,x) R, i.e. xRx is true. 2. R is symmetric, iff for all x, y A, if (x, y) R, then (y, x) R i.e xRy yRx is true 3. R is transitive iff for all x, y, z A, if (x, y) R and (y,z) R , then (x, z) R i.e. (xRy yRz) xRz is true A. Reflexive relations 1. Definition Let R be a binary relation on a set A. R is reflexive, iff for all x A, (x,x) R, i.e. xRx is true. Examples: a. Equality is a reflexive relation for any object x, x = x is true. b. "less then" is not a reflexive relation. It is irreflexive. for any number x, x < x is not true c. " less then or equal to" is a reflexive relation for any number x, x x is true d. A = {1,2,3,4}, R = {(1,1), (1,2), (2,2), (2,3), (3,3), (3,4), (4,4)} e. A = {1,2,3,4}, R = {(1,2), (2,3), (3,4), (4,1)} - not reflexive (it is irreflexive) f. A = {1,2,3,4}, R = {(1,1), (1,2), (3,4), (4,4)} - not reflexive (it is neither reflexive nor irreflexive) 2. Graph representation of reflexive relations Rule: if xRx is true, there is a loop on node x. Example: A:= {1,2,3} R = "less then or equal to" R = {(1,1),(1,2),(1,3),(2,2),(2,3),(3,3)} 3. Matrix representation of reflexive relations The relation R in the above example would be represented thus: 1 2 3 1 1 0 0 2 0 1 0 3 0 0 1 There are 1's on the diagonal 4. Reflexive and irreflexive relations Compare the three examples below: 1. A = {1,2,3,4}, R1 = {(1,1), (1,2), (2,2), (2,3), (3,3), (3,4), (4,4)} 2. A = {1,2,3,4}, R2 = {(1,2), (2,3), (3,4), (4,1)} 3. A = {1,2,3,4}, R3= {(1,1), (1,2), (3,4), (4,4)} R1 is a reflexive relation. R2 ? R3 ? Definition: Let R be a binary relation on a set A. R is irreflexive iff for all x A, (x,x) R Definition: Let R be a binary relation on a set A. R is neither reflexive, nor irreflexive iff there is x A, such that (x, x) R, and there is y A such that (y, y) R Thus R2 is irreflexive, while R3 is neither reflexive nor irreflexive. Summary reflexive: for all x: xRx irreflexive: for no x: xRx neither: for some x: xRx is true, for some y: yRy is false Symmetric relations Definition R is symmetric, iff for all x, y A, if (x, y) R, then (y, x) R, i.e xRy yRx is true This means: if two elements x and y are in relation R, then y and x are also in R, i.e. if xRy is true, yRx is also true. Examples: . equality is a symmetric relation: if a = b then b = a a. "less than" is not a symmetric relation, it is anti-symmetric. b. "sister" on the set of females is symmetric. c. "sister" on the set of all human beings is not symmetric. (It is neither symmetric nor anti-symmetric) d. "friends" is symmetric: friend(a,b) friend(b,a) e. A = {1,2,3,4}, R1 = {(1,1), (1,2), (2,1), (2,3), (3,2), (4,4)} The relation is symmetric. f. A = {1,2,3,4}, R2 = {(1,1), (1,2), (2,3), (4,4)} - not symmetric (it is anti-symmetric) g. A = {1,2,3,4}, R3 = {(1,1), (1,2), (2,1) , (2,3), (4,4)} - not symmetric (it is neither symmetric nor anti-symmetric) Graph representation of symmetric relations Rule: if R is a symmetric relation, all links are bi-directional. Example: friend(x,y), x,y {Ann, Tim, Paul, Jane, Jim} Matrix representation of symmetric relations Ann Tim Paul Jane Jim Ann 0 1 0 0 0 Tim 1 0 1 0 0 Paul 0 1 0 0 0 Jane 0 0 0 0 1 Jim 0 0 0 1 0 The matrix is symmetric. Symmetric and anti-symmetric relations Compare the relations: 0. A = {1,2,3,4}, R1 = {(1,1), (1,2), (2,1), (2,3), (3,2), (4,4)} 1. A = {1,2,3,4}, R2 = {(1,1), (1,2), (2,3), (4,4)} 2. A = {1,2,3,4}, R3 = {(1,1), (1,2), (2,1) , (2,3), (4,4)} Definition: Let R be a binary relation on a set A. R is anti-symmetric if for all x, y A, x y, (x, y) R (y, x) R. i.e. for all pairs (x,y) in R, x y, the pair (y,x) is not in R. Definition: R is neither symmetric nor anti-symmetric iff it is not symmetric and not anti-symmetric. Summary symmetric: xRy yRx for all x and y anti-symmetric: xRy and yRx x = y neither: for some x and y both xRy and yRx are true, for others xRy is true, yRx is not true. Transitive relations Definition Let R be a binary relation on a set A. R is transitive iff for all x, y, z A, if (x, y) R and (y,z) R , then (x, z) R i.e. (xRy yRz) xRz is true Examples: . Equality is a transitive relation: a = b, b = c, hence a = c a. "less than" is a transitive relation: a < b, b < c, hence a < c b. mother(x,y) is not a transitive relation c. sister(x,y) is a transitive relation d. brother (x,y) is a transitive relation e. A = {1,2,3,4} R = {(1,1), (1,2), (1,3), (2,3), (4,3)} - transitive f. A = {1,2,3,4} R = {(1,1), (1,2), (1,3), (2,3), (3,4)} - not transitive Graph representation of transitive relations Rule: if there is a link from a to b, and a link from b to c, then there must be a link from a to c. Example: A = {1,2,3,4} R = {(1,2), (1,3), (1,4),(2,3),(2,4),(3,4)} This is the relation "less than" Learning Goals Given a relation be able to determine its properties: a. is the relation reflexive, irreflexive, or neither reflexive nor irreflexive b. is the relation symmetric, anti-symmetric, or neither symmetric nor anti-symmetric c. is the relation transitive or not. Exam-like problems 1. For each of the following relations determine whether it is reflexive, irreflexive, neither symmetric, anti-symmetric, neither transitive, not transitive All relations are on the set of humans R1 = {(x,y) | x is a child of y} R2 = {(x,y) | x is a descendent of y} R3 = {(x,y) | x is a spouse of y} R4 = {(x,y) | x is a wife of y} R5 = {(x,y) | x and y have same parents} R6 = {(x,y) | x and y have same parent} R7 = {(x,y) | x is younger than y } 2. Name (or specify) a relations that is: transitive symmetric reflexive irreflexive anti-symmetric 3. Let N be the set of natural numbers. A binary relation R is defined on N in the following way: R = {(x,y) | y = x or y = x+1} Determine the properties of R: reflexive, irreflexive or neither, symmetric, anti-symmetric or neither, transitive or not transitive. 4. Let N be the set of natural numbers, and let A = N x N. A binary relation R is defined on A as follows: (x1, x2) R (y1, y2) if and only if x1 = y1 i.e. R = {((x1, x2), (y1, y2)) | x1 = y1} Determine the properties of R: reflexive, irreflexive or neither, symmetric, anti-symmetric or neither, transitive or not transitive. 5. Let A be the set of all English statements. A binary relation R is defined on A as follows: R = {(p,q) | p q is true} Determine the properties of R: reflexive, irreflexive or neither, symmetric, anti-symmetric or neither, transitive or not transitive. 6. Let R be a binary relation with the following properties: reflexive, symmetric and transitive. -1 What would be the properties of R ? 7. Let R be a binary relation with the following properties: -1 irreflexive, anti-symmetric and not transitive. What would be the properties of R ? 8. Let A be the set of all lines on the plane. A binary relation R is defined on A as follows: R = {(a,b)| a is perpendicular to b} Determine the properties of R: reflexive, irreflexive or neither, symmetric, anti-symmetric or neither, transitive or nor transitive. Hasse diagram In order theory, a branch of mathematics, a Hasse diagram ( /ˈ hæsə/; German: /ˈ hasə/) is a type of mathematical diagram used to represent a finite partially ordered set, in the form of a drawing of its transitive reduction. Concretely, for a partially ordered set (S, ≤) one represents each element of S as a vertex in the plane and draws a line segment or curve that goes upward from x to y whenever y covers x (that is, whenever x < y and there is no z such that x < z < y). These curves may cross each other but must not touch any vertices other than their endpoints. Such a diagram, with labeled vertices, uniquely determines its partial order. Hasse diagrams are named after Helmut Hasse (1898–1979); according to Birkhoff (1948), they are so-called because of the effective use Hasse made of them. However, Hasse was not the first to use these diagrams; they appear, e.g., in Vogt (1895). Although Hasse diagrams were originally devised as a technique for making drawings of partially ordered sets by hand, they have more recently been created automatically using graph drawing techniques.[1] The phrase "Hasse diagram" may also refer to the transitive reduction as an abstract directed acyclic graph, independently of any drawing of that graph, but this usage is eschewed here. Examples The power set of { x, y, z } partially ordered by inclusion, has the Hasse diagram: The set A = { 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60 } of all divisors of 60, partially ordered by divisibility, has the Hasse diagram: The set of all 15 partitions of the set { 1, 2, 3, 4 }, partially ordered by refinement (i.e. a finer partition is "less than" a coarser partition), has the Hasse diagram: Functions Definitions on Functions: A function, denote it by f, from a set A to a set B is a relation from A to B that satisfies 1. for each element a in A, there is an element b in B such that <a, b> is in the relation, and 2. if <a, b> and <a, c> are in the relation, then b = c . The set A in the above definition is called the domain of the function and B its codomain. Thus, f is a function if it covers the domain (maps every element of the domain) and it is single valued. Inverse Functions Definition: Let f and g be two functions. If f(g(x)) = x and g(f(x)) = x, then g is the inverse of f and f is the inverse of g. In mathematics, an inverse function is a function that undoes another function: If an input x into the function ƒ produces an output y, then putting y into the inverse function g produces the output x, and vice versa. i.e., ƒ(x)=y, and g(y)=x. More directly, g(ƒ(x))=x, meaning g(x) composed with ƒ(x) leaves x unchanged. A function ƒ that has an inverse is called invertible; the inverse function is then uniquely determined by ƒ and is denoted by ƒ−1 Recursive Functions: What's a Recursive Function? Technically, a recursive function is a function that makes a call to itself. To prevent infinite recursion, you need an if-else statement (of some sort) where one branch makes a recursive call, and the other branch does not. The branch without a recursive call is usually the base case (base cases do not make recursive calls to the function). Composition Functions: function composition is the application of one function to the results of another. For instance, the functions f: X → Y and g: Y → Z can be composed by computing the output of g when it has an argument of f(x) instead of x. Intuitively, if z is a function g of y and y is a function f of x, then z is a function of x. Thus one obtains a composite function g ∘ f: X → Z defined by (g ∘ f)(x) = g(f(x)) for all x in X. The notation g ∘ f is read as "g circle f", or "g composed with f", "g after f", "g following f", or just "g of f". The composition of functions is always associative. That is, if f, g, and h are three functions with suitably chosen domains and codomains, then f ∘ (g ∘ h) = (f ∘ g) ∘ h, where the parentheses serve to indicate that composition is to be performed first for the parenthesized functions. Since there is no distinction between the choices of placement of parentheses, they may be safely left off.