2/18/2019 §7.1 Binary Relations (2nd pass) and §7.2 n-ary Relations Longin Jan Latecki Slides adapted from Kees van Deemter who adopted them from Michael.

Slides:



Advertisements
Similar presentations
Basic Properties of Relations
Advertisements

CSE115/ENGR160 Discrete Mathematics 04/24/12 Ming-Hsuan Yang UC Merced 1.
1 Relations Rosen 5 th ed., ch Relations Relationships between elements of sets occur very often.Relationships between elements of sets occur very.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Relations.
1 Section 7.1 Relations and their properties. 2 Binary relation A binary relation is a set of ordered pairs that expresses a relationship between elements.
Relations Chapter 9.
1 Relations and Their Properties Epp, section ??? CS 202 Aaron Bloomfield.
Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a.
Module #18: Relations, part I
Relations Rosen 5 th ed., ch. 7. Binary Relations Let A, B be any sets. A binary relation R from A to B, written (with signature) R:A×B, or R:A,B, is.
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.
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.
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
1 Relations and Their Properties Rosen, section 7.1 CS/APMA 202 Aaron Bloomfield.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 8 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.
Discrete Mathematics Lecture # 15 Types of Relations (contd.)
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
RelationsCSCE 235, Spring Introduction A relation between elements of two sets is a subset of their Cartesian products (set of all ordered pairs.
2012 년 봄학기 강원대학교 컴퓨터과학전공 문양세 이산수학 (Discrete Mathematics) n- 항 관계 (n-ary Relations)
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 B = {a,b} {( 0, a), (
Section 9.1. Section Summary Relations and Functions Properties of Relations Reflexive Relations Symmetric and Antisymmetric Relations Transitive Relations.
Chapter8 Relations 8.1: Relations and their properties.
15.1 CompSci 102© Michael Frank Today’s topics RelationsRelations –Kinds of relations –n-ary relations –Representations of relations Reading: Sections.
Relations Chapter 9 Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill.
Chapter 5 Relations and Operations
Relations and Their Properties
Relations Chapter 9.
Relations and Digraphs
Applied Discrete Mathematics Week 10: Relations
RELATION KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS )
Dr. Ameria Eldosoky Discrete mathematics
Relations and Their Properties
Relations Rosen 5th ed., ch. 7.
CSE 504 Discrete Structures & Foundations of Computer Science
Relations: Operations & Properties
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 9 Relations Slides are adopted from.
Applied Discrete Mathematics Week 9: Equivalence Relations
CMSC Discrete Structures
Discrete Mathematics and its Applications
§7.3 Representing Relations Longin Jan Latecki
CS2210 Discrete Structures Relations
Rosen 5th ed., ch. 7 ~32 slides (in progress), ~2 lectures
Relations and Their Properties
8.1 Relations and Their Properties
CSE15 Discrete Mathematics 04/26/17
Discrete Mathematics and its Applications
Introduction to Sets.
Applied Discrete Mathematics Week 6: Relations/Digraphs
Mathematical Background 1
Mathematical Background 1
Relations and their Properties
CS2013: Relations and Functions
Discrete Mathematics and its Applications
2/25/2019 §7.1 Binary Relations (2nd pass) and §7.2 n-ary Relations Longin Jan Latecki Slides adapted from Kees van Deemter who adopted them from Michael.
Lecture 4.1: Relations Basics
Discrete Mathematics and its Applications
Properties of Relations
Mathematical Background
Equivalence Relations
Discrete Mathematics and its Applications
Discrete Mathematics and its Applications
Discrete Mathematics and its Applications
§7.3 Representing Relations Longin Jan Latecki
7/30/2019 §7.1 Binary Relations (2nd pass) and §7.2 n-ary Relations Longin Jan Latecki Slides adapted from Kees van Deemter who adopted them from Michael.
Discrete Mathematics and its Applications
Discrete Mathematics and its Applications
Lecture # 16 Inverse of Relations
Relations 12/7/2019.
Presentation transcript:

2/18/2019 §7.1 Binary Relations (2nd pass) and §7.2 n-ary Relations Longin Jan Latecki Slides adapted from Kees van Deemter who adopted them from Michael P. Frank’s Course Based on the Text Discrete Mathematics & Its Applications (5th Edition) by Kenneth H. Rosen A word about organization: Since different courses have different lengths of lecture periods, and different instructors go at different paces, rather than dividing the material up into fixed-length lectures, we will divide it up into “modules” which correspond to major topic areas and will generally take 1-3 lectures to cover. Within modules, we have smaller “topics”. Within topics are individual slides. The instructor can bring several modules to each lecture with him, to make sure he has enough material to fill the lecture, or in case he wants to preview or review slides from upcoming or recent past lectures. 2/18/2019

§7.1 Binary Relations (2nd pass) Let A, B be any sets. A binary relation R from A to B is a subset of A×B. E.g., < can be seen as {(n,m) | n < m} (a,b)R means that a is related to b (by R) Also written as aRb; also R(a,b) E.g., a<b and < (a,b) both mean (a,b) < A binary relation R corresponds to a characteristic function PR:A×B→{T,F} 2/18/2019

Complementary Relations Let R:A,B be any binary relation. Then, R:A×B, the complement of R, is the binary relation defined by R:≡{(a,b)A×B | (a,b)R}=(A×B) − R Note this is just R if the universe of discourse is U = A×B; thus the name complement. Note the complement of R is R. Example: < = {(a,b) | (a,b)<} = {(a,b) | ¬a<b} = ≥ 2/18/2019

Inverse Relations Any binary relation R:A×B has an inverse relation R−1:B×A, defined by R−1 :≡ {(b,a) | (a,b)R}. E.g., <−1 = {(b,a) | a<b} = {(b,a) | b>a} = >. E.g., if R:People x Foods is defined by a R b  a eats b, then: b R−1 a  b is eaten by a. (Passive voice.) 2/18/2019

Relations on a Set A (binary) relation from a set A to itself is called a relation on the set A. E.g., the “<” relation from earlier was defined as a relation on the set N of natural numbers. 2/18/2019

Reflexivity and relatives A relation R on A is reflexive iff aA(aRa). E.g., the relation ≥ :≡ {(a,b) | a≥b} is reflexive. R is irreflexive iff aA(aRa) Note “irreflexive” does NOT mean “not reflexive”, which is just aA(aRa). 2/18/2019

Reflexivity and relatives Theorem: A relation R is irreflexive iff its complementary relation R is reflexive. Example: < is irreflexive; ≥ is reflexive. Proof: trivial 2/18/2019

Involving numbers, propositions or sets? Can you think of Reflexive relations Irreflexive relations Involving numbers, propositions or sets? 2/18/2019

Some examples Reflexive: Irreflexive: =, `have same cardinality’,  <=, >=, , , etc. Irreflexive: <, >, `have different cardinality’,  2/18/2019

Symmetry & relatives A binary relation R on A is symmetric iff a,b((a,b)R ↔ (b,a)R). E.g., = (equality) is symmetric. < is not. “is married to” is symmetric, “likes” is not. A binary relation R is asymmetric if a,b((a,b)R → (b,a)R). Examples: < is asymmetric, “likes” is not. 2/18/2019

Some direct consequences Theorems: R is symmetric iff R = R−1, R is asymmetric iff RR−1 is empty. 2/18/2019

Symmetry & relatives 1. R is symmetric iff R = R−1 Suppose R is symmetric. Then (x,y)  R  (y,x)  R  (x,y)  R−1  Suppose R = R−1 Then (x,y)  R  (x,y)  R−1  (y,x)  R 2/18/2019

Symmetry & relatives 2. R is asymmetric iff RR−1 is empty. (Straightforward application of the definitions of asymmetry and R−1) 2/18/2019

Antisymmetry Consider the relation xy This is called antisymmetry: It is not symmetric. (For instance, 56 but not 65) It is not asymmetric. (For instance, 5 5) You might say it’s nearly symmetric, since the only symmetries occur when x=y This is called antisymmetry: 2/18/2019

Antisymmetry A binary relation R on A is antisymmetric iff a,b((a,b)R  (b,a)R a=b). Examples: , ,  2/18/2019

Transitivity A relation R is transitive iff (for all a,b,c) ((a,b)R  (b,c)R) → (a,c)R. Example: “is an ancestor of” is transitive. 2/18/2019

Composite Relations Let R:A×B, and S:B×C. Then the composite SR of R and S is defined as: SR = {(a,c) | b: aRb  bSc} Function composition is an example: writing fT for the function-version of the relation T, we have SR(a,c) iff b: aRb  bSc iff fR(a)=b and fS(b)=c iff fSfR(a)=c 2/18/2019

Composite Relations The nth power Rn of a relation R on a set A can be defined recursively by: R0 :≡ IA ; Rn+1 :≡ RnR for all n≥0. E.g., R1 =R; R2 = RR; R3= RRR e d a c b 2/18/2019

Composite Relations R2= RR = (a, c) (e, c) (b, d) (d, d) (c, c) e e d 2/18/2019

§7.2: n-ary Relations An n-ary relation R on sets A1,…,An, is a subset R  A1× … × An. The sets Ai are called the domains of R. The degree of R is n. R is functional in the domain Ai if it contains at most one n-tuple (…, ai ,…) for any value ai within domain Ai. 2/18/2019

§7.2: n-ary Relations An n-ary relation R on sets A1,…,An, is a subset R  A1× … × An. This is a straightforward generalisation of a binary relation. For example: 3-ary relations: a is between b and c; a gave b to c 2/18/2019

Relational Databases A relational database is essentially just a set of relations. A domain Ai is a primary key for the database if the relation R is functional in Ai. A composite key for the database is a set of domains {Ai, Aj, …} such that R contains at most 1 n-tuple (…,ai,…,aj,…) for each composite value (ai, aj,…)Ai×Aj×… 2/18/2019

Selection Operators Let A be any n-ary domain A=A1×…×An, and let C:A→{T,F} be any condition (predicate) on elements (n-tuples) of A. Then, the selection operator sC is the operator that maps any (n-ary) relation R on A to the n-ary relation consisting of all n-tuples from R that satisfy C. That is, sC(R) = {aR | C(a) = T} 2/18/2019

Selection Operator Example Suppose we have a domain A = StudentName × Standing × SocSecNos Suppose we define a condition Upperlevel on A: UpperLevel(name,standing,ssn) :≡ [(standing = junior)  (standing = senior)] Then, sUpperLevel is the selection operator that takes any relation R on A (database of students) and produces a relation consisting of just the upper-level students (juniors and seniors). 2/18/2019

Projection Operators Let A = A1×…×An be any n-ary domain, and let {ik}=(i1,…,im) be a sequence of indices all falling in the range 1 to n, That is, 1 ≤ ik ≤ n for all 1 ≤ k ≤ m. Then the projection operator on n-tuples is defined by: 2/18/2019

Projection Example Suppose we have a ternary (3-ary) domain Cars=Model×Year×Color. (note n=3). Consider the index sequence {ik}= 1,3. (m=2) Then the projection P maps each tuple (a1,a2,a3) = (model,year,color) to its image: This operator can be usefully applied to a whole relation RCars (a database of cars) to obtain a list of the model/color combinations available. {ik} 2/18/2019

Join Operator Puts two relations together to form a combined relation. If the tuple (A,B) appears in R1, and the tuple (B,C) appears in R2, then the tuple (A,B,C) appears in the join J(R1,R2). A, B, and C can also be sequences of elements. 2/18/2019

Join Example Suppose R1 is a teaching assignment table, relating Lecturers to Courses. Suppose R2 is a room assignment table relating Courses to Rooms,Times. Then J(R1,R2) is like your class schedule, listing (lecturer,course,room,time). (For precise definition, see Rosen, p.486) 2/18/2019