Lecture 14 Relations CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.

Slides:



Advertisements
Similar presentations
Representing Relations
Advertisements

Chapter 3. Relations Definitions Relations Binary relations Domain Range Vertex Direct edge Loops Reflective Relations Sympatric Relations Anti Symmetric.
Representing Relations Rosen 7.3. Using Matrices For finite sets we can use zero-one matrices. Elements of each set A and B must be listed in some particular.
CSE115/ENGR160 Discrete Mathematics 04/26/12 Ming-Hsuan Yang UC Merced 1.
8.3 Representing Relations Connection Matrices Let R be a relation from A = {a 1, a 2,..., a m } to B = {b 1, b 2,..., b n }. Definition: A n m  n connection.
Representing Relations Using Matrices
5/16/20151 You Never Escape Your… Relations. 5/16/20152Relations If we want to describe a relationship between elements of two sets A and B, we can use.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Relations.
Discrete Mathematics Lecture#11.
Lecture 3 Operations on Sets CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
1 Representing Relations Epp section ??? CS 202 Aaron Bloomfield.
Chapter 9 1. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing.
Applied Discrete Mathematics Week 10: Equivalence Relations
GRAPH Learning Outcomes Students should be able to:
Properties of Relations In many applications to computer science and applied mathematics, we deal with relations on a set A rather than relations from.
Chapter 4 Relations and Digraphs
April 10, 2002Applied Discrete Mathematics Week 10: Relations 1 Counting Relations Example: How many different reflexive relations can be defined on a.
Chapter 9. Chapter Summary Relations and Their Properties Representing Relations Equivalence Relations Partial Orderings.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
Lecture 17 Trees CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Lecture 7 Matrices CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Discrete Math for CS Binary Relation: A binary relation between sets A and B is a subset of the Cartesian Product A x B. If A = B we say that the relation.
Chapter 9. Section 9.1 Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
8.3 Representing Relations Directed Graphs –Vertex –Arc (directed edge) –Initial vertex –Terminal vertex.
Discrete Structures1 You Never Escape Your… Relations.
1 Closures of Relations: Transitive Closure and Partitions Sections 8.4 and 8.5.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Relations.
Discrete Mathematics Relation.
Relations and their Properties
Relations – Page 1CSCI 1900 – Discrete Structures CSCI 1900 Discrete Structures Properties of Relations Reading: Kolman, Section
§ 每周五交作业,作业成绩占总成绩的 10% ; § 平时不定期的进行小测验,占总成绩的 20% ; § 期中考试成绩占总成绩的 20% ;期终考 试成绩占总成绩的 50% § 每周五下午 1 ; 00—3 : 00 ,答疑 § 地点:软件楼 301.
CHAPTER 3 FUZZY RELATION and COMPOSITION. 3.1 Crisp relation Product set Definition (Product set) Let A and B be two non-empty sets, the product.
September1999 CMSC 203 / 0201 Fall 2002 Week #13 – 18/20/22 November 2002 Prof. Marie desJardins.
Fall 2002CMSC Discrete Structures1 You Never Escape Your… Relations.
Relations. Important Definitions We covered all of these definitions on the board on Monday, November 7 th. Definition 1 Definition 2 Definition 3 Definition.
Lecture on Relations 1Developed by CSE Dept., CIST Bhopal.
CS 103 Discrete Structures Lecture 19 Relations. Chapter 9.
Relation. Combining Relations Because relations from A to B are subsets of A x B, two relations from A to B can be combined in any way two sets can be.
Discrete Structures – CNS2300
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
4. Relations and Digraphs Binary Relation Geometric and Algebraic Representation Method Properties Equivalence Relations Operations.
Representing Relations Using Matrices A relation between finite sets can be represented using a zero-one matrix Suppose R is a relation from A = {a 1,
Relations Section 9.1, 9.3—9.5 of Rosen Spring 2012
Graphs Basic properties.
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
RelationsCSCE 235, Spring Introduction A relation between elements of two sets is a subset of their Cartesian products (set of all ordered pairs.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Lecture 19 Minimal Spanning Trees CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
MAT 2720 Discrete Mathematics Section 3.3 Relations
Section 7.3: Representing Relations In this section, we will cover two ways to represent a relation over a finite set other than simply listing the relation.
Section 9.3. Section Summary Representing Relations using Matrices Representing Relations using Digraphs.
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
“It is impossible to define every concept.” For example a “set” can not be defined. But Here are a list of things we shall simply assume about sets. A.
Lecture 7: Relations Dr Andrew Purkiss-Trew Cancer Research UK Mathematics for Computing.
Relations and Their Properties
Citra Noviyasari, S.Si, MT
Chapter 5 Relations and Operations
Learn about relations and their basic properties
Relations Chapter 9.
Relations and Digraphs
Representing Relations
CSNB 143 Discrete Mathematical Structures
Chapter 2 Sets Homework 3 Given U = { 1, 2, 3, 4, 5, 6, 7, 8, 9 } as a set universe and the sets : A = { 1, 2, 3, 4, 5 }, B = { 4, 5, 6, 7 }, C = { 5,
CS2210 Discrete Structures Relations
Combining relations via relational composition
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
Chapter 8 (Part 2): Relations
Agenda Lecture Content: Relations (Relasi)
4.4 Properties of Relations
Presentation transcript:

Lecture 14 Relations CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine

CSCI 1900 Lecture Lecture Introduction Reading –Rosen - Sections 9.1, 9.2, 9.3 Cartesian Product Partitioning Relations Representing Relations as a Matrix Digraph Properties of Relations Equivalence Relations

CSCI 1900 Lecture Cartesian Product for 2 Sets If A and B are nonempty sets, the product set or Cartesian Product, A x B is the set of all ordered pairs (a,b) with a  A and b  B The ordered pair (a,b) is called a 2-tuple Example A={1,2,3} B={r,s} –A x B={ (1, r), (2, r), (3, r), (1, s), (2, s), (3, s) } Example Z x Z, set of all discrete points in the plane Note that (1,r)  (r,1)

CSCI 1900 Lecture Cartesian Product of m Sets If A 1, A 2, …, A m are nonempty sets, then the Cartesian Product of them is the set of all ordered m-tuples (a 1, a 2, …, a m ), where a i  A i, i = 1, 2, … m Denoted A 1  A 2  …  A m = { (a 1, a 2, …, a m ) | a i  A i, i = 1, 2, … m }

CSCI 1900 Lecture Cartesian Product Examples Let A = {1, 2, 3} and B = {a, b, c}, –A  B = {(1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c)} Let A = {1, 2, 3}, B = {a, b, c}, C = {T, F} –A  B  C= {(1,a,T), (1,b,T), (1,c,T), (2,a,T), (2,b,T), (2,c,T), (3,a,T), (3,b,T), (3,c,T), (1,a,F), (1,b,F), (1,c,F), (2,a,F), (2,b,F), (2,c,F), (3,a,F), (3,b,F), (3,c,F)}

CSCI 1900 Lecture Cardinality of Cartesian Product The Cardinality of the Cartesian Product equals the product of the cardinality of all sets involved sets: | A 1  A 2  …  A m | = | A 1 |  | A 2 |  …  | A m |

CSCI 1900 Lecture Partition A Partition P of a nonempty set A, is the set of nonempty subsets such that –Each element in A belongs to one set in P –Sets in P are disjoint Example: Let A={1, 2, 3, 4, 5, 6} –A 1 ={1, 3, 4} A 2 ={2, 6} A 3 = {5} –P = {A 1, A 2, A 3 } is a partition of A

CSCI 1900 Lecture Additional Partition Example Let A={a, b, c, d, e, f, g, h} A 1 ={a, b, c, d} A 2 ={a, c, e, f, g, h} A 3 = {a, c, e, g} A 4 ={b, d} A 5 ={f, h} –Is P = {A 1, A 2 } a partition of A? –Is P = {A 1, A 5 } a partition of A? –Is P = {A 3, A 4, A 5 } a partition of A?

CSCI 1900 Lecture Subsets of the Cartesian Product Many of the results of operations on sets produce subsets of the Cartesian Product set Relational database –Each column in a database table can be considered a set –Each row is an m-tuple of the elements from each column or set –No two rows should be alike Example –Employee ID, Last Name, Department, Salary –Database is a subset of ID x Name x Depart x Salary

CSCI 1900 Lecture Relations A relation, R, is a subset of a Cartesian Product together with a property that defines whether a given m-tuple is a member of the relation or not Terminology: Relation R from A to B –R  A  B –Denoted by “x R y” where x  A and y  B x has a relation with y means: x does not have a relation with y x R y

CSCI 1900 Lecture Relation Example Let –A be the set of all students, and –B be the set of all courses A relation R may be defined because certain courses are required by concentration Burf Snerfle R CSCI 2710 Ginger Ayle R CSCI 2710

CSCI 1900 Lecture Domain and Range Example: A={1, 2, 3, 6} B={1, 3, 4} –Let Q be the relation, a R b if a < b –Q={ (1, 3), (1, 4), (2, 3), (2, 4), (3, 4) } Domain of Q, Dom(Q) ={1, 2, 3} –The set of elements in A that are related to some element in B Range of Q, Ran(Q) ={3, 4} –The set of elements in B that are related to some element of A

CSCI 1900 Lecture Relations Across Same Set Relations may be defined upon a single set Terminology: Relation R on A R  A  A Consider the X-Y Plane you used to plot points

CSCI 1900 Lecture Relation on a Single Set Example A is the set of all courses A relation P may be defined as the course is a prerequisite for Let P be the relation, C1 R C2 –C1 is a prerequisite for C2 P = {(CSCI 2150, CSCI 3400), (CSCI 1710, CSCI 2910), (CSCI 2800, CSCI 2910), …}

CSCI 1900 Lecture Represent A Relation As A Matrix Let: A = { a 1, a 2, a 3, …, a m } with |A| = m B = { b 1, b 2, b 3, …, a n } with |B| = n With Q a relation from A to B Represent Q as an m x n matrix, M Q, with m i j = 1 if (a i, b j )  Q = 0 if (a i, b j )  Q

CSCI 1900 Lecture Matrix Example Let: A = { 1, 2, 3 } B = { r, s } With the relation Q from A to B Q = { (1, r), (2, s), (3, r) } Then 1 0 M =

CSCI 1900 Lecture Digraph of a Relation Let Q be a relation on A We can represent Q pictorially as follows –Each element of A is a circle called a Vertex –If a i is related to a j, then draw an arrow from the vertex a i to the vertex a j –These arrows are called Arcs or Edges The resulting pictorial is called a digraph (directed graph)

CSCI 1900 Lecture Digraph of a Relation (cont) In-Degree of a vertex –Number of arcs pointing into a vertex Out-Degree of a vertex –Number of arcs pointing out from a vertex

CSCI 1900 Lecture Representing a Relation Two representations of the same relation Q on A = {1, 2, 3} Q = { (1, 1), (1, 3), (2, 3), (3, 2), (3, 3) } Node In Degree Out Degree

CSCI 1900 Lecture Paths in a Digraph A walk from one node to the next, following the arrows is a Path –Vertex1, Edge1, Vertex2, Edge2, Vertex3, Edge3, Vertex4 –A vertex may occur multiple times in a path; an edge may occur only once Paths start and end at a vertex The number of edges in the path is its Length –The above example is length 3 A path that starts and ends at the same node is a cycle

CSCI 1900 Lecture Properties of Relations Recall –If Q  A x A, then Q is a relation on A Relations on a set may have three properties –Reflexive –Symmetric –Transitive

CSCI 1900 Lecture Reflexive A relation Q on set A, is reflexive if for all a  A, then (a, a)  Q Example: Let A={1, 2, 3, 4} Q={ (1,1), (1,4), (2,1), (2,2), (2,4), (3,3), (4,3), (4,4) }

CSCI 1900 Lecture Reflexive( cont) A relation Q on set A, is irreflexive if no element relates to itself

CSCI 1900 Lecture Symmetric A relation Q on set A, is symmetric –If (a, b)  Q then (b, a) is also  Q A = {1, 2, 3} Q = { (1, 1), (1, 2), (2, 1), (2, 3), (3, 2) }

CSCI 1900 Lecture Symmetric ( cont) A relation Q on set A, is asymmetric if whenever (a, b)  Q, (b, a)  Q

CSCI 1900 Lecture Transitive A relation Q on set A, is transitive if (a, b)  Q and (b, c)  Q then (a, c)  Q Example: Let A={ 1, 2, 3 } R={ (1, 2), (2, 3), (1, 3) }

CSCI 1900 Lecture Equivalence Relations A relation Q on a set A is an equivalence relation if the relation is –Reflexive –Symmetric –Transitive

CSCI 1900 Lecture Key Concepts Summary Cartesian Product Partitioning Relations Representing Relations as a Matrix Digraph Properties of Relations Equivalence Relations