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

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

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

CSC Discrete Math I, Spring Relations

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

Chapter 9: Relations Relations

What are relations? f: A B

Massachusetts Institute of Technology 6.042J/18.062J, Fall 02: Mathematics for Computer Science Professor Albert Meyer and Dr.

Equivalence relations

Sets and Motivation for Boolean algebra

Discrete Mathematics. 2. Relations

MAD 3105 PRACTICE TEST 2 SOLUTIONS

Relations Graphical View

Math.3336: Discrete Mathematics. Chapter 9 Relations

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

Multiple Choice Questions for Review

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

Section 7.1 Relations and Their Properties. Definition: A binary relation R from a set A to a set B is a subset R A B.

Reading 11 : Relations and Functions

Discrete Mathematics. Chapter 4. Relations and Digraphs Sanguk Noh

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Outline Inverse of a Relation Properties of Relations. Relations. Alice E. Fischer. April, 2018

a + b = b + a and a b = b a. (a + b) + c = a + (b + c) and (a b) c = a (b c). a (b + c) = a b + a c and (a + b) c = a c + b c.

Properties of the Integers

Relations, Functions, and Sequences

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

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

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

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

Automata and Languages

1.4 Equivalence Relations and Partitions

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

Relations --- Binary Relations. Debdeep Mukhopadhyay IIT Madras

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

Discrete Structures: Sample Questions, Exam 2, SOLUTIONS

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

Deviations from the Mean

Ranking Score Vectors of Tournaments

Discrete Structures: Sample Questions, Exam 2, SOLUTIONS

Math 2534 Solution to Test 3A Spring 2010

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

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

RED. Name: Instructor: Pace Nielsen Math 290 Section 1: Winter 2014 Final Exam

Lecture 4.3: Closures and Equivalence Relations

Tree sets. Reinhard Diestel

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

Week 4-5: Generating Permutations and Combinations

Packet #5: Binary Relations. Applied Discrete Mathematics

Worksheet on Relations

14 Equivalence Relations

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.

Generating Permutations and Combinations

EQUIVALENCE RELATIONS (NOTES FOR STUDENTS) 1. RELATIONS

Section 8.4 Closures of Relations

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

GENERALIZED DIFFERENCE POSETS AND ORTHOALGEBRAS. 0. Introduction

Math 42, Discrete Mathematics

Denotational Semantics

Selected Solutions to Even Problems, Part 3

Definition 2.3. We define addition and multiplication of matrices as follows.

Indian Institute of Information Technology Design and Manufacturing, Kancheepuram Chennai , India. Instructor N.Sadagopan Scribe: P.

Sequences and Summations

Tutorial Obtain the principal disjunctive normal form and principal conjunction form of the statement

Lecture Notes 1 Basic Concepts of Mathematics MATH 352

CIS 375 Intro to Discrete Mathematics Exam 3 (Section M004: Blue) 6 December Points Possible

5. Partitions and Relations Ch.22 of PJE.

Equivalence, Order, and Inductive Proof

Nonnegative Matrices I

Diskrete Mathematik Solution 6

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

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

Well-Ordering Principle. Axiom: Every nonempty subset of Z + has a least element. That is, if S Z + and S, then S has a smallest element.

Mathematical Foundations of Logic and Functional Programming

CIS 375 Intro to Discrete Mathematics Exam 3 (Section M001: Green) 6 December Points Possible

Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 7: Procedures for First-Order Theories, Part 1

Discrete Structures, Final Exam

1. A poset P has no chain on five elements and no antichain on five elements. Determine, with proof, the largest possible number of elements in P.

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

Exam 2. Is g one-to-one? Is g onto? Why? Solution: g is not one-to-one, since for c A, g(b) = g(c) = c. g is not onto, since a / g(a).

Chapter 6. Relations. 6.1 Relations

Divisor Problems HAROLD B. REITER.

Writing Assignment 2 Student Sample Questions

Outline for Today. Binary Relations. Equivalence Relations. Partial Orders. Quick Midterm Review

Practice Exam 1 CIS/CSE 607, Spring 2009

2MA105 Algebraic Structures I

Strange Combinatorial Connections. Tom Trotter

Relations, Functions & Binary Operations

CS Discrete Mathematics Dr. D. Manivannan (Mani)

Chapter 1. Sets and Numbers

Is g one-to-one? Is g onto? Why? Solution: g is not one-to-one, since for c A, g(b) = g(c) = c. g is not onto, since a / g(a).

Just the Factors, Ma am HAROLD B. REITER.

Week 4-5: Binary Relations

32 Divisibility Theory in Integral Domains

COT3100 SI Final Exam Review

Relations and Equivalence Relations

Solutions to In Class Problems Week 4, Mon.

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

and e 2 ~ e 2 iff e 1

Discrete Structures: Solutions to Sample Questions, Exam 2

Equivalence Relations and Partitions, Normal Subgroups, Quotient Groups, and Homomorphisms

Transcription:

COMP 182 Algorithmic Thinking Relations Luay Nakhleh Computer Science Rice University

Chapter 9, Section 1-6 Reading Material

When we defined the Sorting Problem, we stated that to sort the list, the elements must be totally order-able. Mathematical induction doesn t apply only to positive integers; it applies to any well-ordered set. What is an order? What is a total order? What is an order that is not total? What is a well-ordered set? To answer this question, we learn about relations and special classes of relations, including orders.

Relations also play an important role beyond the questions on the previous slide. For example, the relational data model for representing databases is based on the concept of a relation.

Binary Relations Let A and B be sets. A binary relation from A to B is a subset of A B. arb denotes (a, b) 2 R a 6 Rb denotes (a, b) /2 R

Binary Relations and Functions If f is a function from A to B, then f is a relation from A to B. The converse is not necessarily true.

Relation on a Set A relation on a set A is a relation from A to A. We have already seen such a relation: E V V.

Properties of Relations A relation R on a set A is called reflexive if (a, a) R for every element a A. A relation R on a set A is called symmetric if (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 antisymmetric. A relation R on a set A is called transitive if whenever (a, b) R and (b, c) R, then (a, c) R, for all a,b,c A.

Properties of Relations R 1 = {(a, b) a divides b} R 2 = {(a, b) a <b} R 3 = {(a, b) a apple b} R 4 = {(a, b) a 7 b} R 5 = {(A, B) A \ B 6= ;}

Combining Relations Relations are sets; therefore, set operations apply to them (e.g., you can take the union of two relations). Furthermore, if R is a relation from A to B and S is a relation from B to C, then the composite of R and S, denoted by S R, is {(a, c) a 2 A, c 2 C, 9b 2 B,((a, b) 2 R ^ (b, c) 2 S)}

Relations Beyond Two Sets One can define a relation on any number of sets. Let A 1,A 2,...,A n be sets.an n-ary relation on these sets is a subset of A 1 A 2 A n. The sets A 1,A 2,...,A n are called the domains of the relation, and n is called its degree. Central to database theory and implementation.

Representing Relations Assume A={a 1,a 2,,a m } and B={b 1,b 2,,b n }. A relation from A to B can be represented with an m n matrix M where: m ij = { 1if(ai,b j ) R, 0if(a i,b j )/ R.

Representing Relations Relations can also be represented using digraphs, but ones that allow self loops. a b d c

Closures of Relations Let R be a relation on set A. Let P be some property of relations (e.g., reflexivity). 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.

Closures of Relations Let R be a relation on set A. Reflexive closure of R: Symmetric closure of R: S = R [{(a, a) :a 2 A} S = R [{(a, b) :(b, a) 2 R}

Transitive Closure Let R be a relation on set A. Recall that R can be represented as a digraph. R n is a relation on set that satisfies: (a,b) R n iff there is a path of length n from a to b in the graph of relation R. The transitive closure of R, denoted by R*, is R = n=1 R n.

Transitive Closure Can you devise an algorithm for computing the transitive closure of a relation? Hint: Think of matrix multiplication!

Equivalence Relations A relation on a set A is called an equivalence relation if it is reflexive, symmetric, and transitive. Two elements a and bthat are related by an equivalence relation are called equivalent. The notation a bis often used to denote that a and bare equivalent elements with respect to a particular equivalence relation. R = {(a, b) a m b}

Equivalence Relations Let R be an equivalence relation on a set A. The set of all elements that are related to an element a of A is called the equivalence class of a. The equivalence class of a with respect to R is denoted by [a] R. When only one relation is under consideration, we can delete the subscript R and write [a] for this equivalence class. [a] R ={s (a, s) R} [ ] Let R be an equivalence relation on a set S. Then the equivalence classes of R form a partition of S. Conversely, given a partition {A i i I} of the set S, there is an equivalence relation R that has the sets A i, i I, as its equivalence classes.

Partial Orders

A relation R on a set S is called a partial ordering or partial order if it is reflexive, antisymmetric, 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 the poset. S 1 = N R 1 = {(a, b) a apple b} S 2 =2 {1,2,3,4,5,6} R 2 = {(A, B) A B} The elements a and b of a poset (S, ) are called comparable if either a b or b a. When a and b are elements of S such that neither a b nor b a, a and b are called incomparable.

Total Order If (S, ) is a poset and every two elements of S are comparable, S is called a totally ordered or linearly ordered set, and is called a total order or a linear order. A totally ordered set is also called a chain. S 1 = N R 1 = {(a, b) a apple b} S 2 =2 {1,2,3,4,5,6} R 2 = {(A, B) A B}

<latexit sha1_base64="nffla+vvvyeeoxpyxay0wmamy8g=">aaacexicbvdlssnafj34rpuvdelmsagfosrf0i1qdooyon1ge8nkom2hth7m3agl9bfc+ctuxcji1p07/8zjm4vtpxdhcm693huphwuuwlj+jkxlldw19cjgcxnre2fx3ntvqiirldvojclz9oligoesarwea8eskcaxrouprzk/9cik4lf4b6oyuqhph7zhkqetewb51qvic5w6aygb7+p78cmjdoahtm2knlmyktyeejhyosmhhhxp/ha6eu0cfgivrkmobcxgpkqcp4kni06iwezokprzr9oq6jvuovloji+10sw9sookau/uvxmpczqabb7uzg5u814m/ud1euiduykp4wryskeleonaeoeshtzlkleqi00ilvzfiumasejbh1juidjzly+szrviwxx75rruu8zjkkbdditkyeznqiauur01eevp6aw9oxfj2xg1pozpaeuskc8cobkyx78hpjvk</latexit> <latexit sha1_base64="nffla+vvvyeeoxpyxay0wmamy8g=">aaacexicbvdlssnafj34rpuvdelmsagfosrf0i1qdooyon1ge8nkom2hth7m3agl9bfc+ctuxcji1p07/8zjm4vtpxdhcm693huphwuuwlj+jkxlldw19cjgcxnre2fx3ntvqiirldvojclz9oligoesarwea8eskcaxrouprzk/9cik4lf4b6oyuqhph7zhkqetewb51qvic5w6aygb7+p78cmjdoahtm2knlmyktyeejhyosmhhhxp/ha6eu0cfgivrkmobcxgpkqcp4kni06iwezokprzr9oq6jvuovloji+10sw9sookau/uvxmpczqabb7uzg5u814m/ud1euiduykp4wryskeleonaeoeshtzlkleqi00ilvzfiumasejbh1juidjzly+szrviwxx75rruu8zjkkbdditkyeznqiauur01eevp6aw9oxfj2xg1pozpaeuskc8cobkyx78hpjvk</latexit> <latexit sha1_base64="nffla+vvvyeeoxpyxay0wmamy8g=">aaacexicbvdlssnafj34rpuvdelmsagfosrf0i1qdooyon1ge8nkom2hth7m3agl9bfc+ctuxcji1p07/8zjm4vtpxdhcm693huphwuuwlj+jkxlldw19cjgcxnre2fx3ntvqiirldvojclz9oligoesarwea8eskcaxrouprzk/9cik4lf4b6oyuqhph7zhkqetewb51qvic5w6aygb7+p78cmjdoahtm2knlmyktyeejhyosmhhhxp/ha6eu0cfgivrkmobcxgpkqcp4kni06iwezokprzr9oq6jvuovloji+10sw9sookau/uvxmpczqabb7uzg5u814m/ud1euiduykp4wryskeleonaeoeshtzlkleqi00ilvzfiumasejbh1juidjzly+szrviwxx75rruu8zjkkbdditkyeznqiauur01eevp6aw9oxfj2xg1pozpaeuskc8cobkyx78hpjvk</latexit> <latexit sha1_base64="nffla+vvvyeeoxpyxay0wmamy8g=">aaacexicbvdlssnafj34rpuvdelmsagfosrf0i1qdooyon1ge8nkom2hth7m3agl9bfc+ctuxcji1p07/8zjm4vtpxdhcm693huphwuuwlj+jkxlldw19cjgcxnre2fx3ntvqiirldvojclz9oligoesarwea8eskcaxrouprzk/9cik4lf4b6oyuqhph7zhkqetewb51qvic5w6aygb7+p78cmjdoahtm2knlmyktyeejhyosmhhhxp/ha6eu0cfgivrkmobcxgpkqcp4kni06iwezokprzr9oq6jvuovloji+10sw9sookau/uvxmpczqabb7uzg5u814m/ud1euiduykp4wryskeleonaeoeshtzlkleqi00ilvzfiumasejbh1juidjzly+szrviwxx75rruu8zjkkbdditkyeznqiauur01eevp6aw9oxfj2xg1pozpaeuskc8cobkyx78hpjvk</latexit> (S, ) is a well-ordered set if it is a poset such that is a total ordering and every nonempty subset of S has a least element. S 1 = N R 1 = {(a, b) a apple b} S 2 = Z + Z + R 2 = {((a 1,b 1 ), (a 2,b 2 )) : (a 1 <a 2 ) _ (a 1 = a 2 ^ b 1 <b 2 )}

THE PRINCIPLE OF WELL-ORDERED INDUCTION Suppose that S is a wellordered set. Then P (x) is true for all x S, if INDUCTIVE STEP: For every y S, if P (x) is true for all x S with x y, then P (y) is true.

Hasse Diagrams Let (S,R) be a finite poset. The Hasse diagram of (S,R) is a digraph g=(v,e) where V=S R={(a,b) arb and c (arc and crb)}

Hasse Diagrams 4 GURE 2 Const 3 ({1, 2, 3, 4}, ) 2 1

Hasse Diagrams {a, b, c} {a,c} {a,b} {b, c} {a} {c} {b} Hasse diagram of (P({a,b,c}), )

Maximal and Minimal Elements Let (S,R) be a poset and a,b S. Element a is maximal if there is no element c S (c a) such that arc. Element b is minimal if there is no element c S (c b) such that crb.

Greatest and Least Elements Let (S,R) be a poset and a,b S. Element a is the greatest element if for every element c S, cra. Element b is the least element if for every element c S, brc. The greatest and least elements are unique when they exist.

What are the maximal, minimal, greatest, and least elements of the posets given by the following four Hasse diagrams? b c d d e d d c c b c a a b a b a (a) (b) (c) (d)

Questions?