Relations

We recently talked about functions as mechanisms for mapping elements of one set to elements of another set. Sometimes, there are relationships that you want to express about two sets that don't fit the definition of function. For example, you could have a function mapping people to first names:

f: PEOPLE --> POSITIVE_INTEGERS
and it makes sense to talk about f(p) as a function that takes a person and returns their age (in years, as we often do). For children, it might be important to change the second set to POSITIVE_INTEGERS+HALF_INTEGERS. But there are other kinds of mappings that we want to express, for instance, we might want to express the idea of "friendship" as a function mapping people to people, at it would be nice to have a way to express that "Jan" has friends "Amy", "John", and "Lisa" with a notation something like:
f(Jan) = Amy
f(Jan) = John
f(Jan) = Lisa

As it is written, this is not a function (because f(Jan) is not unique). We could fix this by making friendship a mapping between people and sets

f: PEOPLE --> Powerset(PEOPLE)
which would be unique, but then anytime you want to know about one friend, you would have to look at the whole set of friends of a person.

The handle this we use the concept of "Relations", a generalization of a function to allow multiple outputs and "inputs" that have no output. A relation R is a subset of the cartesian product of a collection of sets. That's it. There are no other restrictions on what can be or not be in R. Can have many different kinds of relations: Sibling, Parent, Classmate, Facebook buddy, etc...

With this introduction, let's go back to the problem at the end of the last class, where we had 6 folks in a room, and we look at their set of friends. (see why there are always cliques? Strangely (!), this is in your book on the chapter on pigeonhold principles.

Theorem Any group of 6 people will have 3 friends or 3 non-friends. Proof Choose 1 person, call her Alice. There are 5 others. At least 3 of them must be friends of Alice, or 3 of them must be non-friends of Alice. Consider those 3... Other Ramsey Bounds

  1. R(4,4) = 18
  2. 41 <= R(5,5) <= 50

The friendship relationship we used in the last problem is an exampl of the concept of "Relations", a generalization of a function to allow "inputs" to have multiple outputs and "inputs" that have no output. A relation R is a subset of the cartesian product of a collection of sets. That's it. There are no other restrictions on what can be or not be in R.

Very quickly, why is it so hard to compute R(5,5)? how many possible relations are there?

Representations of a relation. A Relation is just a set, so you can define it the same way as you define sets, as a list, as a rule: R = { (a,b) | "some logical formula of a,b" }, as a union/intersection of other sets, and so on.

  1. There is also a corrolary to the bit string representation of a set, which is to make an array with rows corresponding to elements of one set and columns corresponding to elements of the other.
  2. Bipartite graph

If we represent a function as a relation, what constraints does that relation have?

Many common relations are of a set to itself. If A is a set, a relation R is a subset of A x A. Then the matrix representation of R is a square, and the graph representation is a "digraph" (with edges and loops). Any subset of AxA is a relation, but there are some "special" kinds of relations.

  1. Reflexive. forall x in A, (x,x) is in R
  2. Symmetric. forall x and y in A, (x,y) is in R --> (y,x) is in R
  3. Transitive. forall x, y, z in A, ((x,y) is in R and (y,Z) is in R)) --> (x,z) is in R
  4. Anti-Reflexive. forall x in A, (x,x) is in R
  5. Anti-Symmetric. forall x in A, (x,x) is in R
For each of the following sets, let's see if they fit the following:

A = PEOPLE, R(a,b) = a is a parent of b
A = PEOPLE, R(a,b) = a is an ancestor of b
A = POSITIVE INTEGERS, R(a,b) = a | b.
A = POSITIVE INTEGERS, R(a,b) = a MOD 4 ==  b mod 4.
A = POSITIVE INTEGERS, R(a,b) = a MOD 4 == b mod 5.

What do these properties look like in the matrix representation?

What do these properties look like in the graph representation?

How many relations are there of each type?

Let R be any symmetric relation on set A. Define Rn.