1 / 32

CS2013: Relations and Functions

CS2013: Relations and Functions. Relations and Functions. Some background for CS2013 Necessary for understanding the difference between Deterministic FSAs (DFSAs) and NonDeterministic FSAs (NDFSAs). If what follows is new or puzzling….

kconley
Download Presentation

CS2013: Relations and Functions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS2013: Relations and Functions Kees van Deemter

  2. Relations and Functions • Some background for CS2013 • Necessary for understanding the difference between • Deterministic FSAs (DFSAs) and • NonDeterministic FSAs (NDFSAs) Kees van Deemter

  3. 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

  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 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): 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) 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): x1A and x2A and … and xnA} Kees van Deemter

  7. 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 = {(xStudent,yCAS): x scored y in last years’s CS2013 exam} Kees van Deemter

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

  9. 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

  10. Reflexivity and relatives • A relation R on A is reflexiveiff 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 “notreflexive”, 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 Kees van Deemter

  11. Some examples • Reflexive: =, ‘have same cardinality’,  <=, >=, , , etc. 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? 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) Kees van Deemter

  14. Antisymmetry • Consider the relation xy • Is it symmetrical? • Is it asymmetrical? • Is it reflexive? • Is it irreflexive? Kees van Deemter

  15. Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? • Is it reflexive? • Is it irreflexive? Kees van Deemter

  16. Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? No • Is it reflexive? • Is it irreflexive? Kees van Deemter

  17. Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? No • Is it reflexive? Yes • Is it irreflexive? Kees van Deemter

  18. Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? No • Is it reflexive? Yes • Is it irreflexive? No Kees van Deemter

  19. Antisymmetry • Consider the relation xy • 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 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)} 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. 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” 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 Kees van Deemter

  24. End of aside Kees van Deemter

  25. 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). Kees van Deemter

  26. Functionality Functionality: • A relation R: A×B is functionaliff, 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)). Kees van Deemter

  27. Functionality • R: A×B is functionaliff, 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. 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? 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 iffor 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 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. 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? 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 Kees van Deemter

More Related