Download presentation
Presentation is loading. Please wait.
1
CS2013: Relations and Functions
19/02/2019 Kees van Deemter
2
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
3
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 19/02/2019 Kees van Deemter
4
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
5
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): xA and yB}. 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
6
Student x CAS = {(John,1),(John,2),… (John,20),(Mary,1),…,(Mary,20)}
A1 x A2 x … x An = {(x1,x2,…,xn): x1A and x2A and … and xnA} 19/02/2019 Kees van Deemter
7
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 = {(xStudent,yCAS): x scored y in last years’s CS2013 exam} 19/02/2019 Kees van Deemter
8
Binary Relations Aside: This way of modelling relations using sets suggests some natural questions and operations, e.g., 19/02/2019 Kees van Deemter
9
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
10
Reflexivity and relatives
A relation R on A is reflexive iff aA(aRa). E.g., the relation ≥ :≡ {(a,b) | a≥b} is reflexive. R is irreflexive iff aA(aRa) Note “irreflexive” does NOT mean “not reflexive”, which is just aA(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
11
Some examples Reflexive: =, ‘have same cardinality’,
<=, >=, , , etc. 19/02/2019 Kees van Deemter
12
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
13
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
14
Antisymmetry Consider the relation xy Is it symmetrical?
Is it asymmetrical? Is it reflexive? Is it irreflexive? 19/02/2019 Kees van Deemter
15
Antisymmetry Consider the relation xy Is it symmetrical? No
Is it asymmetrical? Is it reflexive? Is it irreflexive? 19/02/2019 Kees van Deemter
16
Antisymmetry Consider the relation xy Is it symmetrical? No
Is it asymmetrical? No Is it reflexive? Is it irreflexive? 19/02/2019 Kees van Deemter
17
Antisymmetry Consider the relation xy Is it symmetrical? No
Is it asymmetrical? No Is it reflexive? Yes Is it irreflexive? 19/02/2019 Kees van Deemter
18
Antisymmetry Consider the relation xy Is it symmetrical? No
Is it asymmetrical? No Is it reflexive? Yes Is it irreflexive? No 19/02/2019 Kees van Deemter
19
Antisymmetry Consider the relation xy This is called antisymmetry
It is not symmetric. (For instance, 56 but not 65) 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
20
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
21
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
22
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
23
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
24
End of aside 19/02/2019 Kees van Deemter
25
the difference between relations and functions
Totality: A relation R:A×B is total if for every aA, there is at least one bB 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
26
Functionality Functionality:
A relation R: A×B is functional iff, for every aA, there is at most one bB such that (a,b)R. A functional relation R: A×B does not have to be total (there may be aA such that ¬bB (aRb)). 19/02/2019 Kees van Deemter
27
Functionality R: A×B is functional iff, for every aA, there is at most one bB such that (a,b)R. aA: ¬ 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
28
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
29
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 xA1 and yA2, there exists at most one zA3 such that (x,y,z) R. This is easy to generalise to n arguments 19/02/2019 Kees van Deemter
30
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
31
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
32
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.