There is no commentSelect some text and then click Comment, or simply add a comment to this page from below to start a discussion.
Revision Guide: Discrete Mathematics (Logic and Relations)
The aim of this note is to review just enough discrete mathematics in order to be able to understand the concepts of
"abstraction as a quotient by an equivalence relation" [1] and
"rewriting to normal form" [2] as a model of computation.
"meaning of a formal languages as a mapping to a semantic domain". [3]
All these notions can be connected, clarified and formalised with the help of a little discrete maths, which we will review now. [4]
For the main part, we only need to understand the concept of reflexive and transitive (and symmetric) closure of a relation. But let us get started with a review of some helpful notation from set theory and logic.
If you are familiar with databases then a (finite) relation is really very much the same as a table in a database. For our purposes, we actually only need binary relations, that is, tables that have two columns (attributes).
Anyway, we don't need to think about databases. The mathematical definition is that a relation[5] on a set is a subset of , in symbols
Notation: By convention, we also write instead of , or also , which in turn may be abbreviated to . When drawing pictures we also write this as
which we abbreviate to
if there is only one relation around anyway.
Remark: Later we will take to be the relation of "one-step computation", or rewriting, as we called it, but for now we make no assumptions on and .
We need to know what it means for a relation to be reflexive, symmetric, and transitive.
Defininition: Assume . The relation is said to be
reflexive iffor all .
symmetric iffor all .
transitive iffor all .
Example:
The -relation on numbers is transitivie but neither reflexive nor symmetric.
The -relation on numbers is reflexive and transitive but not symmetric.
A relation that is symmetric and transitive but not necessarily reflexive is called a partial equivalence relation. The linked article contains some references to applications to the semantics of programming languages.
The relation of modular arithmetic is reflexive, transitive and symmetric.
The relation of "being siblings" is symmetric but not reflexive (hence also not transitive).
Exercise:
Family relationships and social networks: Check parent, ancestor, sibling, having the same parents, friend, following, being a member of the same group, etc for reflexivity, transtivity and symmetry.
Exercise:
Is it true that a relation which is symmetric and transitive is also reflexive?
Is the empty relation symmetric and transitive? Is it reflexive?
Transitive Closure
We have seen examples of transitive closure above.
Ancestor is the transitive closure of parent.
On natural numbers (or integers), "greater than" is the transtive closure of the successor relation. [6]:
More generally, given a relation , two elements are in the transitive closure of if there is a sequence of elements such that
or, shorter,
Remark: can be defined recursively as follows.
if ,
if there is such that and .
Note how this is similar to a recursive definition in, say, Haskell.
Another way of expressing the same idea is as follows.
Definition: Let .
The transitive closure of is the smallest transitive relation containing .
The reflexive and transitive closure of is the smallest reflexive and transitive relation containing .
Remark: If is a relation of "one-step computation" we often write instead of and for the reflexive and transitive closure.
Exercise: Let be an ARS. The relation can be represented by an adjacency matrix defined asDescribe an algorithm that computes the transitive closure of via matrix multiplication.
Equivalence Relations
Equivalence relations and equivalence classes are one of the most important concepts in mathematics and computer science. It was discovered surprisingly late, as far as I know by Dedekind around 1880. [7] For a general introduction see my notes on What is Abstraction?
Definition: An equivalence relation is a relation that is reflexive, transitive and symmetric. The equivalence closure of is the smallest reflexive, symmetric, transitive relation containing .
Remark: We will be interested in the situation where specifies the equational properties of a computational problem and describes a non-determinstic algorithm solving the problem.
Notation and Terminology: If is an equivalence relation it is often written as or or any other symbol that emphasises the analogy with equality. If we write instead of , we write for the equivalence closure
Equivalence relations solve the problem of how to account for the fact that two things can be considered equal and different at the same time.
For example, and are different as expressions, but they are equal as numbers. Now we can just say they are equivalent wrt an appropriate equivalence relation.
Example (fractions): Define if . Show that every fraction is equivalent to its simplified fraction.
Example (modular arithmetic): Let be a natural number. Define if there is an integer such that . Show thatThe relation is often called congruence modulo . Congruence relations are equivalence relations that satisfy additional compatibility properties with operations such as the two above for addition and multiplication.
Example (integers): Define an INTEGER as a pair of natural numbers. Define if . Define zero as and . Show how to define negation on INTEGERs and show that it satisfies the usual equations one would expect from integers.
Quotienting by an Equivalence Relation
The purpose of an equivalence relation is that it makes precise when it is safe to consider two different things equal. In one of the examples above, we defined an equivalence relation such that . It is more common to write . In this section we will see how to give this notation a rigorous mathematical foundation.
If is an equivalence relation on , then partitions into equivalence classes. For , the equivalence class of is denoted by or and defined as
To say that the equivalence classes partition is to say that equivalences classes are disjoint and cover all of . We will come back to this below.
We can now form the set of equivalence classes which is written as and defined as
Remark (Partition): Equivalence relations on are in bijective correspondence with partitions of . A partition of is a set of subsets of that are pairwise disjoint and cover all of .[8] Given an equivalence relation, its equivalence classes form a partition. Conversely, every partition defines the equivalence relation of "being in the same part".
Remark (Equivalence relation/partition of a function): Every function defines an equivalence relation via . In other words, partitions into the subsets of elements that are identified by .
Example: Equality is an equivalence relation. In fact, equality is the smallest equivalence relation. There is also a largest equivalence relation (which is it?).
Notation and Terminology: The set is also called modulo or quotiented by or the quotient of by .
Let us review the examples above.
Example (fractions): The set of non-negative fractions can be implemented as a set of equivalence classes. The set is where is the positive integers and the equivalence relation in question is the one (defined above) which takes care of the fact that, eg, 1/2 = 2/4.
Example (modular arithmetic): On the integers , the relation of congruence modulo is an equivalence relation. The set of equivalence classes is denoted by . The operation of "dividing by " has some properties similar to division on numbers, see eg the Chinese Remainder Theorem which explains some of the terminology just introduced.
Example (integers): The set of integers can be represented as a quotient of by an equivalence reation (defined above).
The following exercise is crucial to understand equivalence classes.
Exercise: Show that every equivalence relation on partitions , that is,
A is the union of its equivalence classes, symbolically,
any two different equivalence classes are disjoint, ie,
Functions
As I said, I assume that the notion of a function is familiar, either form high-school or from a first semester discrete maths course. But we can review some terminology quickly.
To begin at the beginning, a function is often defined to be a relation , which, moreover, is
single-valued, that is, and implies and is
total, that is, for all there is such that .
These two properties together say that for all there is one and only one related and this is the element that is, by convention, written as .
We will also need further properties that functions may have. A function is called
injective, or one-to-one, if implies that ,
surjective, or onto, if for all there is such that ,
bijective, if it is injective and surjective.
If we have a bijection between two sets, then the two sets can be considered equal up to the names of their elements. Intuitively, a bijection is like a dictionary that relates every word in one language to exactly one corresponding word in the other.
We will also need that a function
can be extended to subsets of and . We define
the direct image of under as
the inverse image of under as
Remark (Partition of a function): Every function defines a partition on . The sets are sometimes known as the fibres over .
Isomorphisms
Finally, we bring everything together. First a definition.
Definition (isomorphism): An isomorphism is a function which has an inverse, that is, there is a function such that and .
Exercise: Show that a function is an isomorphism if and only if it is bijective.
The reason we prefer the definition of isomorphism as a map that has an inverse is that it is more abstract and also applies to situations other than sets and functions.
Each of the examples above (fractions, modulo arithmetic, integers) fits into the following picture, where the equivalence and have been defined above, the horizontal arrow is an isomorphism, and are indicated in the table below and is left as an exercise.
fractions
modulo arithmetic
integers
In the case of fractions, is often defined to coincide with . In the other cases the domain has an independent definition and the horizontal ismorphism is not an identity, formally speaking. But we can treat it as an identity as all the structure is preserved and only the data is represented in a different way.
I assume that students had a one semester course on discrete maths. But in many discrete-maths-texts relations only appear in the "second semester" part. For example in the widely used book "Discrete Mathematics and Its Application" by Rosen, relations only start on page 374. Btw, the book could be a good place to review some discrete maths.↩︎
It is common to abbreviate by . If we need to emphasise that is a susbset of as opposed to a subset of for some other , we call a "2-ary" relation or a binary relation.↩︎
More information is available in this article on The Early Development of Set Theory. By the way, Dedekind was also the guy who defined integers and rationals as equivalence classes. You are asked to work on this in this exercise.↩︎
In symbolic notaion, a partition of is a collection of subsets of such that and .↩︎