Functions and Relations (CSCI 2824, Spring 2015)In this section, we learn the notion of relations, functions and well-definedness. This is part of Sect 4.1 of the book. FunctionsWe have already encountered functions many times and we often use functions when we program. Let us formalize what functions are in mathematical terms: Functions
A function from a set to a set is associates (or maps) every element of the set to some element of the set . We express the fact that a function maps to as . Example -1Consider and . Consider function . The function above can be represented explicitly by the mapping or implicitly by the rule/formula . Example-2Functions can map many elements of to the same element of . But the rule is that each element of can only be mapped to one element of . Which of the following are functions? Example-3: Power Set SignatureWhile discussing power sets, we mentioned a correspondence between power-sets of a set and binary strings. We can indeed write it as a function. Let us take to be and . We write the function by using the mapping from every element of the power set and every element of . The table below shows the elements of the power set and the corresponding value of .
Example-4: Mathematical functionsYou may have seen many examples of functions from your mathematics classes, thus far.
Non-Examples of Functions.It remains to clarify what is not a function. In general, a mapping from set to set can fail to be a function for either of the two reasons below:
If either case occurs then, the mapping fails to be a function. Consider the two mappings shown below. The mapping on the left fails to be a function because it does not map the elements from the domain, while the mapping on the right fails to be a function since is mapped to multiple elements. Mathematical non-functionsStrictly speaking, many functions that we saw in calculus are not quite functions.
RelationsFormally, a relation between sets and is defined as a subset of , i.e, . Example-1Let us take and . Consider the relation by Like functions, we may view the relation as a mapping. However, unlike functions, it is possible that
The relation is visualized below: Functions are a special case of relations, wherein
Example-2Here is another example of a relation over numbers: defined as Write down some examples of elements of . Example-3Consider sets and write the function defined by as a relation . Counting RelationsIf is a set with elements and with elements then how many relations can exist between and ? How many functions? Answer in class. Domains/Co-DomainsLet be a function . We say that is the domain of and is the co-domain. Similarly, let be a relation. We say that is the domain of the relation and is the co-domain. Relations On a SetA relation from set A to itself is called a relation on A . We can represent relations from a set to itself by a special diagram called a graph. E.g., Let . Consider a relation . The relation has the tuples . The graph looks as follows: The rule is we have nodes or vertices for each element in the set . If , we draw an arrow from to . Graphs are very useful as visualizations of relations. We will spend 2-3 weeks at the end of this course talking about properties of graphs. |