Relations. We have seen several types of abstract, mathematical objects, including propositions, predicates, sets, and ordered pairs and tuples.

Similar documents
Definition: A binary relation R from a set A to a set B is a subset R A B. Example:

Section Summary. Relations and Functions Properties of Relations. Combining Relations

Relations. Relations of Sets N-ary Relations Relational Databases Binary Relation Properties Equivalence Relations. Reading (Epp s textbook)

CSC Discrete Math I, Spring Relations

{a, b, c} {a, b} {a, c} {b, c} {a}

Discrete Mathematics. 2. Relations

Relationships between elements of sets occur in many contexts. Every day we deal with

Relations Graphical View

Packet #5: Binary Relations. Applied Discrete Mathematics

Definition: A binary relation R from a set A to a set B is a subset R A B. Example:

Chapter 9: Relations Relations

Notes. Relations. Introduction. Notes. Relations. Notes. Definition. Example. Slides by Christopher M. Bourke Instructor: Berthe Y.

Relations. Relations. Definition. Let A and B be sets.

3. R = = on Z. R, S, A, T.

Reading 11 : Relations and Functions

What are relations? f: A B

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Chapter 1. Sets and Mappings

Automata and Languages

Lecture 7: Relations

Relations. P. Danziger. We may represent a relation by a diagram in which a line is drawn between two elements if they are related.

Foundations of Mathematics

COMP 182 Algorithmic Thinking. Relations. Luay Nakhleh Computer Science Rice University

Week 4-5: Generating Permutations and Combinations

Generating Permutations and Combinations

Math.3336: Discrete Mathematics. Chapter 9 Relations

EQUIVALENCE RELATIONS (NOTES FOR STUDENTS) 1. RELATIONS

CSE 20 DISCRETE MATH. Fall

Chapter 1. Sets and Numbers

CHAPTER 1. Relations. 1. Relations and Their Properties. Discussion

Relations --- Binary Relations. Debdeep Mukhopadhyay IIT Madras

CSE 20 DISCRETE MATH. Winter

Notes on Sets, Relations and Functions

1. To be a grandfather. Objects of our consideration are people; a person a is associated with a person b if a is a grandfather of b.

Equivalence relations

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Rela%ons and Their Proper%es. Slides by A. Bloomfield

Today. Binary relations establish a relationship between elements of two sets

MATH 433 Applied Algebra Lecture 14: Functions. Relations.

Harvard CS121 and CSCI E-121 Lecture 2: Mathematical Preliminaries

Chapter VI. Relations. Assumptions are the termites of relationships. Henry Winkler

Deviations from the Mean

Chapter 1 : The language of mathematics.

0 Sets and Induction. Sets

Lecture Notes: Selected Topics in Discrete Structures. Ulf Nilsson

Notes for Science and Engineering Foundation Discrete Mathematics

Sets and Motivation for Boolean algebra

Orders and Equivalences

Discrete Structures (2IT50)

SEVENTH EDITION and EXPANDED SEVENTH EDITION

REVIEW QUESTIONS. Chapter 1: Foundations: Sets, Logic, and Algorithms

FALL 07 CSE 213: HW4

Definition: Let S and T be sets. A binary relation on SxT is any subset of SxT. A binary relation on S is any subset of SxS.

Dynamic Programming. Shuang Zhao. Microsoft Research Asia September 5, Dynamic Programming. Shuang Zhao. Outline. Introduction.

Discrete Mathematics: Lectures 6 and 7 Sets, Relations, Functions and Counting Instructor: Arijit Bishnu Date: August 4 and 6, 2009

Set Basics. P. Danziger

Today s topics. Binary Relations. Inverse Relations. Complementary Relations. Let R:A,B be any binary relation.

Notation Index. gcd(a, b) (greatest common divisor) NT-16

Lecture Notes 1 Basic Concepts of Mathematics MATH 352

Week 4-5: Binary Relations

Week 4-5: Binary Relations

Math 42, Discrete Mathematics

Herbrand Theorem, Equality, and Compactness

Sets are one of the basic building blocks for the types of objects considered in discrete mathematics.

Foundations of Mathematics MATH 220 FALL 2017 Lecture Notes

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

BOOLEAN ALGEBRA INTRODUCTION SUBSETS

Multiple Choice Questions for Review

9 RELATIONS. 9.1 Reflexive, symmetric and transitive relations. MATH Foundations of Pure Mathematics

14 Equivalence Relations

MITOCW Lec 11 MIT 6.042J Mathematics for Computer Science, Fall 2010

Chapter 2 - Relations

CS Discrete Mathematics Dr. D. Manivannan (Mani)

1.A Sets, Relations, Graphs, and Functions 1.A.1 Set a collection of objects(element) Let A be a set and a be an elements in A, then we write a A.

Relations, Functions, Binary Relations (Chapter 1, Sections 1.2, 1.3)

Mathematical Foundations of Logic and Functional Programming

Preliminaries to the Theory of Computation

Mathematical Preliminaries. Sipser pages 1-28

Outline. We will now investigate the structure of this important set.

Relations. Binary Relation. Let A and B be sets. A (binary) relation from A to B is a subset of A B. Notation. Let R A B be a relation from A to B.

Chapter 6. Relations. 6.1 Relations

Sets. We discuss an informal (naive) set theory as needed in Computer Science. It was introduced by G. Cantor in the second half of the nineteenth

D-MATH Algebra I HS18 Prof. Rahul Pandharipande. Solution 1. Arithmetic, Zorn s Lemma.

Exercises for Discrete Maths

Relations MATH Relations. Benjamin V.C. Collins, James A. Swenson MATH 2730

Mathematics for Cryptography

HL Topic. Sets, relations and groups. (Further Mathematics SL Topic 3) Sets Ordered pairs Functions Binary operations Groups Further groups

CS 514, Mathematics for Computer Science Mid-semester Exam, Autumn 2017 Department of Computer Science and Engineering IIT Guwahati

Economics 204 Summer/Fall 2017 Lecture 1 Monday July 17, 2017

Automata Theory for Presburger Arithmetic Logic

5. Partitions and Relations Ch.22 of PJE.

Finite Automata and Regular Languages

Chapter 2 - Basics Structures MATH 213. Chapter 2: Basic Structures. Dr. Eric Bancroft. Fall Dr. Eric Bancroft MATH 213 Fall / 60

Section 0. Sets and Relations

Discrete Structures May 13, (40 points) Define each of the following terms:

Chapter 2 - Basics Structures

Informal Statement Calculus

Advanced Automata Theory 9 Automatic Structures in General

Chapter Summary. Sets (2.1) Set Operations (2.2) Functions (2.3) Sequences and Summations (2.4) Cardinality of Sets (2.5) Matrices (2.

1.2 Posets and Zorn s Lemma

Transcription:

Relations We have seen several types of abstract, mathematical objects, including propositions, predicates, sets, and ordered pairs and tuples. Relations use ordered tuples to represent relationships among objects. Examples The parent relationship between specified persons can be described as a set of pairs. For instance, if Morris and Ria are the parents of Steve, then the relation would include the pairs, (M orris, Steve) and (Ria, Steve). The less-than relation on the integers consists of all pairs of integers (i,j), where i is less than j, e.g., (3,42) and (42,43). The relation that student number x is named y and majors in z is described by a set of triples, such as (124324443, M ary, CSE). Finally, the (unary) relation that k is an even integer corresponds to a subset of the integers. Relations are closely related to predicates and truth sets.

Binary Relations Let A and B are sets. A binary relation from A to B is a set R A B. In other words, a binary relation R is a set of ordered pairs (x,y) where x A and y B. If (x,y) R then we sometimes write xry. Example Take sets A = {2,6,7} and B = {1,2,5} and let R 1 be a binary relation defined by: i in A is an integer multiple of y in B. Then R 1 = {(2,1),(2,2),(6,1),(6,2),(7,1)}.

Presenting Binary Relations Binary relations have two kinds of compact visual representation, tables and graphs. The following table represents a binary relation of five pairs: R a b c 1 * * 2 * * 3 * Graphs are composed of vertices or nodes connected by edges or arcs. There is an arc from a to b if, and only if, (a,b) R. 1 A 2 B 3 C

The Parent-Of Relation The parent-of relation is a binary relation, described by pairs of names. Example Myrtle Ormonde William Joan Paula Gene Sue R G J W S M O P G[ene] J[oan] * * W[illiam] * * S[ue] M[yrtle] * O[rmonde] * * P[aula] Which representation is better for testing whether the pair (x,y) is in the relation? Which representation is better for capturing the overall structure?

Reflexive Relations A binary relation R on a set A is called reflexive if it contains all pairs (x,x) A A. Thus, if R is reflexive then the set I = {(x,x) x A} is a subset of R. A relation R on A is irreflexive if it contains no pair (x,x), i.e., the sets I and R are disjoint. In the table representation the difference between the two properties can be seen in the main diagonal of the table. R 1 2 3 R 1 2 3 1 *?? 1?? 2? *? 2?? 3?? * 3?? In a graph, the difference is in the (presence or absence of) self-loops. Is the parent-of relation reflexive, irreflexive, or neither? Is the relation reflexive, irreflexive, or neither?

Symmetric Relations A binary relation R on A is called symmetric if for all x,y A, whenever (x,y) R then (y,x) R. A relation R on A is antisymmetric if for all x,y A, if (x,y) R and (y,x) R, then x = y. The table of a symmetric relation is symmetric around the main diagonal, whereas for an antisymmetric relation there are no symmetric entries (except on the diagonal itself): R 1 2 3 R 1 2 3 1? A B 1? * 2 A? C 2 *? 3 B C? 3 *? Is the cousin-of relation symmetric, antisymmetric, or neither? Is the brother-of relation symmetric, antisymmetric, or neither?

Transitive Relations A binary relation R on A is said to be transitive if for all x, y, z in A, if xry and yrz, then xrz. If a graph represents a transitive relation and there is a path from node a to node b, then there is a single arc from a to b. Is the ancestor-of relation transitive or not? Is the friend-of relation transitive or not? The transitive closure of a relation R adds all the arcs to R necessary to make it transitive. 1 2 3 4 5 6 1 2 3 4 5 6 The ancestor relation is the transitive closure of the parent relation.

Special Binary Relations The universal relation U = A A. The empty relation R =. The identity relation I = {(x,x) x A} Which of the main properties - reflexivity, symmetry, transitivity - are satisfied by these relations?

Relational Databases Commercial database systems employ a relational model, meaning that data is stored in the form of tables of tuples, i.e., relations. A Shakespearian Killed relation would include the following entries: Killer Victim Brutus Caesar Hamlet Laertes Hamlet Polonius Laertes Hamlet Brutus Brutus Cassius Caesar Query languages like SQL can be used to extract information from a database. Example. Who killed Caesar? SELECT Killer FROM Killed WHERE victim= Caesar This reads select from relation Killed all tuples where the victim was Caesar, and report only the killer field from each. Example. Who was both a killer and a victim? (SELECT Killer FROM Killed) INTERSECT (SELECT Victim FROM Killed)

A powerful feature of relational databases is that one can combine different relations. For example, suppose there is a died-by relation: Victim Caesar Hamlet Laertes Polonius Brutus Method Daggers Sword Sword Sword Sword We can combine the two tables with a join operation, based on common fields. For example, the join of killed and died-by is: Killer Victim Method Brutus Caesar Daggers Hamlet Laertes Sword Hamlet Polonius Sword Laertes Hamlet Sword Brutus Brutus Sword Cassius Caesar Daggers Example. Which killers used daggers? SELECT Killer FROM Killed, Died-by WHERE Killed.Victim = Died-by.victim AND Method= Daggers

Equivalence Relations An equivalence relation is a binary relation that is reflexive, transitive, and symmetric. For example, the identity relation and the universal relation (on a nonempty set A) are equivalence relations. An equivalence relation defines clusters of elements of A: [x] = {y A : xry}. The sets [x] are called equivalence classes. For example, the relation on N, defined by m n iff m+n is even, is an equivalence that partitions the set of natural numbers into two subsets the sets of even and odd natural numbers, respectively.

Partitions Theorem If R is an equivalence relation on a nonempty set A, then the equivalence classes of R constitute a partition of A. Theorem If Π is a partition of A, then the relation {(x,y) : x and y belong to the same set in Π} is an equivalence relation. In other words, there is a one-to-one correspondence between equivalence relations and partitions. For example, {{a},{b},{c}} and {{a,c},{b}} are partitions of {a,b,c} and hence correspond to equivalence relations; whereas {{a},{b},{b,c}} is not a partition and does not correspond to an equivalence relation.

Congruence Modulo p Define binary relations on the integers, for all integers p greater than 1, as follows: m is congruent to n modulo p, written m n(mod p), if m n is an integer multiple of p. For example, if p = 3, Then 1 is congruent to 4 modulo p, but not congruent to 3. Let R p denote the corresponding set of pairs {(m,n) : m n(mod p)}. Are the relations R p reflexive, symmetric, and transitive?

Modular Arithmetic To visualize the relation R 12, think of grouping integers by counting around a clock. 11 0 1 10 2 9 3 8 4 7 6 5 Note that 23 = 11(mod 12). If you start at 0 and count to 23 you end up at 11. In other words, 11 and 23 have the same remainder when divided by 12. Note that if m = n(mod p) and x = y(mod p) then m+x = n+y(mod p) think about tracing out a path on the clock to prove it.

Equivalence of Strings We define a binary relation on strings as follows: Theorem Proof v w if and only if v = w. The relation is an equivalence relation. Reflexivity. We have w = w, and hence w w, for all strings w. Symmetry. If v w, then by definition v = w. By the symmetry of equality we thus have w = v, and hence w v. Transitivity. Suppose u v and v w. Then u = v and v = w and therefore, by the transitivity of equality, u = w, which implies u w. The equivalence classes for this relation are the sets Σ k of all strings of length k.

Partial Orders A binary relation on a set A is called a partial order if it is reflexive, transitive, and antisymmetric. The symbol (in infix notation) is often used to denote a partial order. We say that two elements x and y are comparable (with respect to a given partial order ) if either x y or y x. A partial order on a set A is said to be total if any two elements in A are comparable. Is the identity relation a partial order? Is the universal relation a partial order?

Partial Orders - Examples Examples of partial orders are the less-than-or-equalto relation, the divisibility relation (on the positive integers), subset relations, and ancestor relations. The following graph represents the divided-by relation on certain integers: 8 10 4 6 9 5 2 3 7 1 The antisymmetry property ensures that the graph of a partial order has no cycles (other than selfloops). If a partial order is extended to a total one we speak of topological sorting. If the set A has n elements, there are n! total orders on A.

Lexicographic Orders The words in a dictionary are arranged in a lexicographic order, which we define next. Let x and y be strings of letters. Then x L y if, and only if, 1. x is a prefix of y, or 2. x and y are equal, or 3. x can be written as uσv and y as uτw, where the letter σ alphabetically precedes the letter τ. The string u is the longest common prefix of x and y. For example, aa L ab and aa L b. The lexicographic order is also called a dictionary order. In this order there are infinite ascending chains, a L aa L aaa L Interestingly, there are also infinite descending chains, b L ab L aab L aaab L

Predecessors and Successors Let be a partial order on a set A. We say that x is a predecessor of y (and y a successor of x) if x y and x y. For example, the integer k + j is a successor of k (with respect to ) if j is positive, and a predecessor of k if j is negative. The natural number 0 has no predecessor in the set of nonnegative integers (with respect to ). We say that x is an immediate predecessor of y (and y an immediate successor of x) if there is no third element z A, such that x is a predecessor of z and z a predecessor of y. The integer k + 1 is an immediate successor of k, whereas k 1 is an immediate predecessor. Note that a rational number has no immediate predecessor or immediate successor (with respect to ).

Hasse Diagrams The Hasse diagram of a partial order on A is a directed graph with set of nodes A and an arrow from a node x to a node y whenever x is an immediate predecessor of y. These diagrams allow for a concise graphical representation of many partial orders as reflexivity and transitivity are implicitly presented. Hasse diagrams are usually drawn with their edges directed upwards (and with arrow heads left off). {a,b,c} {a,b} {a,c} {b,c} {a} {b} {c} {}

Subsets by Inclusion The graphs representing subset relations are also called hypercubes. {1, 2, 3, 4} {1, 2, 3} {1, 3, 4} {2, 3, 4} {1, 2, 4} {1, 2} {2, 3} {1, 3} {3, 4} {2, 4} {1, 4} {1} {2} {3} {4} {} Note the recursive structure of a hypercube: a d- dimensional cube is composed by connecting two (d 1)-dimensional cubes.

Infinite Hasse Diagrams Many partial orders on infinite sets can be represented by Hasse diagrams, e.g., the less-than-orequal-to relation on integers. A partial order is said to be dense if it is the case that whenever x is a predecessor of y, then there is another element z such that x is a predecessor of z and z a predecessor of y. The less-than-or-equal-to relation on the rational numbers is an example of a dense order. Dense orders cannot be represented by Hasse diagrams.

Minima and Maxima Let be a partial order on a set A. We say that x is a minimal element if it has no predecessor in A. In other words, if x is a minimal element and y x, then y = x. We say that x is a maximal element if it has no successor in A. What are the minimal and maximal elements in the divided-by relation shown previously? Does every partial order have a minimal and/or a maximal element? Is it possible for an element to be minimal and maximal at the same time?

Least and Greatest Elements If a minimal element x is a predecessor of every other element of A, then it is called the least element of A. Similarly, a maximal element that is a successor of every other element of A, is called the greatest element. For example, if we consider the subset relation on a power set P(S), then the empty set is the least element, and the set S the greatest element. The integer 0 is the least element of N (with respect to ), but there is no maximal element (and hence no greatest element either). If the set A is finite, there must be a minimal and a maximal element.