CS2013: Relations and Functions
320 likes | 345 Views
Learn about binary relations, symmetry, reflexivity, transitivity, and more in CS2013 from Kees van Deemter. This foundational knowledge is essential for grasping the difference between DFSAs and NDFSAs.
CS2013: Relations and Functions
E N D
Presentation Transcript
CS2013: Relations and Functions Kees van Deemter
Relations and Functions • Some background for CS2013 • Necessary for understanding the difference between • Deterministic FSAs (DFSAs) and • NonDeterministic FSAs (NDFSAs) Kees van Deemter
If what follows is new or puzzling… • … then read K.H.Rosen, Discrete Mathematics and Its Applications, theChapters 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 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 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): xA and yB}. Example: A= set of all students (e.g., John, Mary), B=set of all CAS marks (e.g., 1-20) 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): x1A and x2A and … and xnA} Kees van Deemter
Binary Relations • Let A, B be sets. A binary relationR 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 thata is related to b (by R) • Also written asaRb; alsoR(a,b) • Can be used to model real-life facts. E.g., Scored = {(xStudent,yCAS): x scored y in last years’s CS2013 exam} Kees van Deemter
Binary Relations Aside:This way of modelling relations using sets suggests some natural questions and operations, e.g., Kees van Deemter
Inverse Relations Any binary relation R:A×B has an inverse relation R−1:B×A, defined byR−1 :≡ {(b,a) | (a,b)R}. E.g., <−1 = {(b,a) | a<b} = {(b,a) | b>a} = > Kees van Deemter
Reflexivity and relatives • A relation R on A is reflexiveiff aA(aRa). • E.g., the relation ≥ :≡ {(a,b) | a≥b} is reflexive. • R is irreflexive iff aA(aRa) • Note “irreflexive” does NOT mean “notreflexive”, 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 Kees van Deemter
Some examples • Reflexive: =, ‘have same cardinality’, <=, >=, , , etc. 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? 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) Kees van Deemter
Antisymmetry • Consider the relation xy • Is it symmetrical? • Is it asymmetrical? • Is it reflexive? • Is it irreflexive? Kees van Deemter
Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? • Is it reflexive? • Is it irreflexive? Kees van Deemter
Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? No • Is it reflexive? • Is it irreflexive? Kees van Deemter
Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? No • Is it reflexive? Yes • Is it irreflexive? Kees van Deemter
Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? No • Is it reflexive? Yes • Is it irreflexive? No Kees van Deemter
Antisymmetry • Consider the relation xy • 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 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)} 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. 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” 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 Kees van Deemter
End of aside Kees van Deemter
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). Kees van Deemter
Functionality Functionality: • A relation R: A×B is functionaliff, 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)). Kees van Deemter
Functionality • R: A×B is functionaliff, 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. 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? 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 iffor all xA1 and yA2, there exists at most one zA3 such that (x,y,z) R. • This is easy to generalise to n arguments 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. 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? 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 Kees van Deemter