CS2013: Relations and Functions

Slides:



Advertisements
Similar presentations
Relations - review A binary relation on A is a subset of A×A (set of ordered pairs of elements from A) Example: A = {a,b,c,d,e} R = { (a,a),(a,b),(b,b),(b,c),
Advertisements

Discrete Mathematics Lecture # 16 Inverse of Relations.
In The Name of Allah Discrete Structures Instructor: Dr. Ali Movaghar
Discrete Structures Chapter 5 Relations Nurul Amelina Nasharuddin Multimedia Department.
CSE115/ENGR160 Discrete Mathematics 05/03/11 Ming-Hsuan Yang UC Merced 1.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Relations.
Discussion #26 Chapter 5, Sections /15 Discussion #26 Binary Relations: Operations & Properties.
Discrete Mathematics Lecture#11.
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 #21 - Relations Representing Relations Rosen 6 th ed., Ch. 8.
Module #18: Relations, part I
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
CHAPTER (6) RELATIONS. RELATIONS : - Let A and B be sets. A binary relation from A to B is subset of A* B …
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.
Digraphs and Relations Warm Up. The Divisibility Relation Let “|” be the binary relation on N×N such that a|b (“a divides b”) iff there is an n ∈ N such.
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.
CS 103 Discrete Structures Lecture 19 Relations. Chapter 9.
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.
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
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.
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), (
1 CMSC 250 Discrete Structures CMSC 250 Lecture 41 May 7, 2008.
Section 9.1. Section Summary Relations and Functions Properties of Relations Reflexive Relations Symmetric and Antisymmetric Relations Transitive Relations.
Lecture 7: Relations Dr Andrew Purkiss-Trew Cancer Research UK Mathematics for Computing.
Chapter8 Relations 8.1: Relations and their properties.
Citra Noviyasari, S.Si, MT
Relations and Their Properties
CSE15 Discrete Mathematics 05/03/17
Equivalence Relations
Relations Chapter 9.
Applied Discrete Mathematics Week 10: Relations
Representing Relations
RELATION KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS )
Dr. Ameria Eldosoky Discrete mathematics
Lecture 4.1: Relations Basics
Relations and Their Properties
CSE115/ENGR160 Discrete Mathematics 04/28/11
Relations Rosen 5th ed., ch. 7.
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
Computing Fundamentals 1 Lecture 7 Relations
Discrete Mathematics and its Applications
§7.3 Representing Relations Longin Jan Latecki
Rosen 5th ed., ch. 7 ~32 slides (in progress), ~2 lectures
Relations and Their Properties
CSE15 Discrete Mathematics 04/26/17
Applied Discrete Mathematics Week 5: Boolean Algebra
Introduction to Sets.
Relations and Digraphs
Mathematical Background 1
Mathematical Background 1
Relations and their Properties
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.
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
Mathematical Background
Basics of Relations.
§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.
Lecture # 16 Inverse of Relations
Relations 12/7/2019.
4.4 Properties of Relations
Presentation transcript:

CS2013: Relations and Functions 19/02/2019 Kees van Deemter

Relations and Functions Some background for CS2013 Necessary for understanding the difference between Deterministic FSAs (DFSAs) and NonDeterministic FSAs (NDFSAs) 19/02/2019 Kees van Deemter

If what follows is new or puzzling… … then read K.H.Rosen, Discrete Mathematics and Its Applications, the Chapters on sets, functions, and relations (Chapters 2 and 9 in the 7th edition). Free copies in pdf can be found on the web http://www2.fiit.stuba.sk/~kvasnicka/Mathematics%20for%20Informatics/Rosen_Discrete_Mathematics_and_Its_Applications_7th_Edition.pdf 19/02/2019 Kees van Deemter

Relations and Functions Simple mathematical constructs Based on elementary set theory Can be used to model many things including the set of edges in a given FSA 19/02/2019 Kees van Deemter

Cartesian product The Cartesian product of n sets A1 x A2 x … x An First n=2 (a 2-place relation) A x B = The Cartesian product of A and B = {(x,y): xA and yB}. Example: A= set of all students (e.g., John, Mary), B=set of all CAS marks (e.g., 1-20) 19/02/2019 Kees van Deemter

Student x CAS = {(John,1),(John,2),… (John,20),(Mary,1),…,(Mary,20)} A1 x A2 x … x An = {(x1,x2,…,xn): x1A and x2A and … and xnA} 19/02/2019 Kees van Deemter

Binary Relations E.g., < can be seen as {(n,m) | n < m} Let A, B be sets. A binary relation R from A to B is a subset of A×B. Analogous for n-ary relations 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) Can be used to model real-life facts. E.g., Scored = {(xStudent,yCAS): x scored y in last years’s CS2013 exam} 19/02/2019 Kees van Deemter

Binary Relations Aside: This way of modelling relations using sets suggests some natural questions and operations, e.g., 19/02/2019 Kees van Deemter

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} = > 19/02/2019 Kees van Deemter

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). E.g., if Adore={(j,m),(b,m),(m,b)(j,j)} then this relation is neither reflexive nor irreflexive 19/02/2019 Kees van Deemter

Some examples Reflexive: =, ‘have same cardinality’,  <=, >=, , , etc. 19/02/2019 Kees van Deemter

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, “Adores” is not. Let R={(j,m),(b,m),(j,j)}. Is R (a)symmetric? 19/02/2019 Kees van Deemter

Symmetry & relatives Let R={(j,m),(b,m),(j,j)}. R is not symmetric (because it does not contain (m,b) and because it does not contain (m,j)). R is not asymmetric, due to (j,j) 19/02/2019 Kees van Deemter

Antisymmetry Consider the relation xy Is it symmetrical? Is it asymmetrical? Is it reflexive? Is it irreflexive? 19/02/2019 Kees van Deemter

Antisymmetry Consider the relation xy Is it symmetrical? No Is it asymmetrical? Is it reflexive? Is it irreflexive? 19/02/2019 Kees van Deemter

Antisymmetry Consider the relation xy Is it symmetrical? No Is it asymmetrical? No Is it reflexive? Is it irreflexive? 19/02/2019 Kees van Deemter

Antisymmetry Consider the relation xy Is it symmetrical? No Is it asymmetrical? No Is it reflexive? Yes Is it irreflexive? 19/02/2019 Kees van Deemter

Antisymmetry Consider the relation xy Is it symmetrical? No Is it asymmetrical? No Is it reflexive? Yes Is it irreflexive? No 19/02/2019 Kees van Deemter

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) The pattern: the only times when (a,b)  and (b,a)  are when a=b This is called antisymmetry 19/02/2019 Kees van Deemter

Antisymmetry A binary relation R on A is antisymmetric iff a,b((a,b)R  (b,a)R) a=b). Examples: , ,  Another example: the earlier-defined relation Adore={(j,m),(b,m),(j,j)} 19/02/2019 Kees van Deemter

Transitivity & relatives A relation R is transitive iff (for all a,b,c) ((a,b)R  (b,c)R) → (a,c)R. A relation is nontransitive iff it is not transitive. A relation R is intransitive iff (for all a,b,c) ((a,b)R  (b,c)R) → (a,c)R. 19/02/2019 Kees van Deemter

Transitivity & relatives What about these examples: “x is an ancestor of y” “x likes y” “x is located within 1 mile of y” “x +1 =y” “x beat y in the tournament” 19/02/2019 Kees van Deemter

Transitivity & relatives What about these examples: “is an ancestor of” is transitive. “likes” is neither trans nor intrans. “is located within 1 mile of” is neither trans nor intrans “x +1 =y” is intransitive “x beat y in the tournament” is neither trans nor intrans 19/02/2019 Kees van Deemter

End of aside 19/02/2019 Kees van Deemter

the difference between relations and functions Totality: A relation R:A×B is total if for every aA, there is at least one bB such that (a,b)R. N.B., it does not follow that R−1 is total It does not follow that R is functional (see over). 19/02/2019 Kees van Deemter

Functionality Functionality: A relation R: A×B is functional iff, for every aA, there is at most one bB such that (a,b)R. A functional relation R: A×B does not have to be total (there may be aA such that ¬bB (aRb)). 19/02/2019 Kees van Deemter

Functionality R: A×B is functional iff, for every aA, there is at most one bB such that (a,b)R. aA: ¬ b1,b2 B (b1≠b2  aRb1  aRb2). If R is a functional and total relation, then R can be seen as a function R: A→B Hence one can write R(a)=b as well as aRb, R(a,b), and (a,b) R. Each of these mean the same. 19/02/2019 Kees van Deemter

Examples Consider the relation Scored again: A relation between Student and CAS Is it a total relation? Is it a functional relation? 19/02/2019 Kees van Deemter

Functionality for 3-place relations Consider a 3-place relation R R is a subset of A1 x A2 x A3, (for some A1, A2, A3) R is functional in its first two arguments if for all xA1 and yA2, there exists at most one zA3 such that (x,y,z)  R. This is easy to generalise to n arguments 19/02/2019 Kees van Deemter

Examples Suppose you model addition of natural numbers as a 3-place relation (0,0,0),(0,1,1), (1,0,1), (1,1,2),… This relation is functional in its first two arguments. 19/02/2019 Kees van Deemter

Examples Let Scored’ be a subset of Student x CAS x PASS, namely {(student,casmark,yes/no): student scored casmark and passed yes/no} Is the relation Scored’ functional in its first two arguments? 19/02/2019 Kees van Deemter

Examples Let Scored’ be a subset of Student x CAS x PASS, namely {(student,casmark,yes/no): student scored casmark and passed yes/no} Is the relation Scored’ functional in its first two arguments? Yes: given (a student and) a CAS mark, you cannot have both pass-yes and pass-no 19/02/2019 Kees van Deemter