DiscMaths Summary
DiscMaths Summary
Summary
This document contains most of the definitions, identities and theorems introduced in the course. It
is intended to be a helpful reference for study and revision – however, it is important that you get
a good intuitive understanding for the topics, rather than just memorise everything. Intuition will
come with time and practice; until then, you can use this sheet, remembering not to rely on it too
much because you won’t have it in the exam!
This table exemplifies an important concept in logic and many other fields of mathematics: duality.
Most of the properties below come in two ‘flavours’, corresponding to dual operations such as
conjunction and disjunction, or universal and existential quantification. Remember that duality is
different from negation: ‘there do not exist negative primes’ (¬∃x. P(x)) is definitely not the same as
‘all primes are negative’ (∀x. P(x)), but it is the same as ‘all primes are not negative’ (∀x. ¬P(x)).
The precise connection between dual operators and negation is given by the de Morgan laws.
In this table, P ∼
= Q means that the logical statement P is equivalent to Q – that is, P ⇐⇒ Q holds.
Identity P ∧> ∼
= P P ∨⊥ ∼
= P
Annihilation P ∧⊥ ∼
= ⊥ P ∨> ∼
= >
Idempotence P∧P ∼
= P P∨P ∼
= P
Commutativity P ∧Q ∼
= Q∧P P ∨Q ∼
= Q∨P
Associativity (P ∧ Q) ∧ R ∼
= P ∧ (Q ∧ R) (P ∨ Q) ∨ R ∼
= P ∨ (Q ∨ R)
Distributivity (P ∨ Q) ∧ R ∼
= (P ∧ R) ∨ (Q ∧ R) (P ∧ Q) ∨ R ∼
= (P ∨ R) ∧ (Q ∨ R)
Absorption P ∧ (P ∨ Q) ∼
= P P ∨ (P ∧ Q) ∼
= P
Complement P ∧ ¬P ∼
= ⊥ P ∨ ¬P ∼
= >
de Morgan ¬(P ∧ Q) ∼
= ¬P ∨ ¬Q ¬(P ∨ Q) ∼
= ¬P ∧ ¬Q
Material implication P =⇒ Q ∼
= ¬P ∨ Q ¬(P =⇒ Q) ∼
= P ∧ ¬Q
Contrapositive P =⇒ Q ∼
= ¬Q =⇒ ¬P
Compound assumption (P ∧ Q) ⇒ R ∼
= P ⇒ (Q ⇒ R) (P ∨ Q) ⇒ R ∼
= (P ⇒ Q) ∧ (Q ⇒ R)
Compound goal P ⇒ (Q ∧ R) ∼
= (P ⇒ Q) ∧ (P ⇒ R) P ⇒ (Q ∨ R) ∼
= (P ⇒ Q) ∨ (P ⇒ R)
Bi-implication (P ⇔ Q) ∼
= (P ⇒ Q) ∧ (Q ⇒ P) = (¬P) ⇔ Q
¬(P ⇔ Q) ∼
Proof patterns
The standard proof techniques used in logic – you can use them systematically to prove most of the
logical propositions you encounter.
Proposition: P
Negation: ¬P
Implication: P =⇒ Q
• To assume
– Modus ponens: Assume P =⇒ Q. If P is also an assumption, we can assume Q.
• To prove
– Deduction: Assume P and prove Q.
– Proof by contrapositive: Prove ¬Q =⇒ ¬P .
Conjunction: P ∧ Q
• To assume:
– Direct proof : Assume P and Q independently.
– Partial assumption: Assume P and prove that Q implies the conclusion. Alternatively,
assume Q and prove that P implies the conclusion.
• To prove: Prove P and Q independently.
Disjunction: P ∨ Q
• To assume
– Proof by cases: In the first case, assume P is true and prove the conclusion. In the second
case, assume Q is true and prove the conclusion
– Disjunctive syllogism: Assume P ∨ Q. If ¬P is also an assumption, we can assume Q.
Similarly, if ¬Q is also an assumption, we can assume P .
• To prove
– Direct proof : Prove P or Q independently.
– Proof by cases: Find a way to split the proof in two cases, proving, in each case, either P
or Q.
D I S C R E T E M AT H E M AT I C S SUMMARY
Bi-implication: P ⇐⇒ Q
Multiple equivalence: P1 ⇐⇒ P2 ⇐⇒ · · · ⇐⇒ Pn
• To assume: Assume ∀x. P(x). If we also have a value a in our assumptions, we can instantiate
the the universal quantification to deduce P(a).
• To prove: Assume x is an arbitrary value and prove P(x). Ensure that x is a new variable name,
i.e. it isn’t already used somewhere in the proof.
• To assume: Assume there is a witness a for which P(a) holds, where a is a new variable name.
• To prove: Find a value a for which we can prove that P(a) holds.
• To assume: Assume there is a witness a for which P(a) holds; in addition, assume that this a is
unique, i.e. if there is any other b for which P(b) holds, a must equal b.
• To prove: Prove existence and uniqueness: find a value a for which P(a) holds, and establish
that any other b for which P(b) holds must equal a.
Induction
Proof by induction is a powerful, general proof technique for proving properties about elements of
possibly infinite sets. Depending on how the set is defined, the induction principle can be presented in
different ways, but the basic principle is always the same: prove the property for some base elements
of the set, then prove it for the general elements, having assumed it for the ‘smaller’ elements (this
can be made more formal with the notion of a well-founded relation). Below are the three most
common induction principles used in computer science.
Structural induction
We can use structural induction to prove properties about recursively defined structures that can
be represented as trees: lists, binary trees, expressions, etc. These are usually defined with some
recursive grammar (e.g. BNF notation) or an algebraic data type.
D I S C R E T E M AT H E M AT I C S SUMMARY
To prove a property P(t) for every tree t of some grammar or ADT, it is enough to:
Rule induction
We can use rule induction to prove properties about subsets inductively defined by a collection of
axioms and rules:
h1 h2 ··· hn
a c
To prove a property P(e) for every element e of an inductively defined set, it is enough to:
h1 · · · h i
[∀a. P(a)] ∧ ∀ . P(h1 ) ∧ · · · ∧ P(hn ) ⇒ P(c) =⇒ ∀e. P(e)
c
Mathematical induction
1. prove P(0);
2. for every k ∈ N, assuming P(k), prove P(k + 1).
It is worth noting that mathematical induction is just a special case of structural induction on the
data type type nat = zero | succ of nat, or rule induction on the set inductively defined by:
n
zero succ(n)
Induction hypotheses may be strengthened by assuming the property for every element ‘smaller’
than the general case, not just the immediate predecessor. In addition, we can explicitly specify the
base case if the property only holds for elements above a certain size. Specialised to mathematical
induction, we get the following strong induction principle:
To prove a property P(n) for n ∈ N with ` ≤ n for some basis ` ∈ N, it is enough to:
1. prove P(`);
2. for every k ∈ N, assuming P(m) for all ` ≤ m ≤ k, prove P(k + 1).
D I S C R E T E M AT H E M AT I C S SUMMARY
Algebraic structures
Abstract algebra focuses on the analysis of algebraic structures. An algebraic structure consists of
an underlying set (carrier) with a collection of operators and distinguished elements which obey a
collection of laws. An algebraic structure can be built on top of another one by adding new operations,
elements or laws, thereby constructing a hierarchy of algebraic structures. Some examples that appear
in the course:
Monoid A set A with a binary operator •: A × A → A (monoidal multiplication) and element " ∈ A
(unit or neutral element) that obey the following laws:
Commutative monoid A monoid (A, •, ") with the additional law of commutativity for the multiplica-
tion •: ∀a, b ∈ A. a • b = b • a. For example, (N, +, 0) and (N, ·, 1) are commutative monoids.
Group A monoid (A, •, ") with an additional unary operation (·)−1 : A → A such that for any a ∈ A,
a−1 is the inverse element of a obeying the laws:
a • a−1 = " = a−1 • a
Commutative (or abelian) group A group (A, •, ", (·)−1 ) where the binary operation is commutative.
For example, (Z, +, 0, −) and (Q, ×, 1, 1/(·)) are commutative groups.
Semiring A set A with an additive commutative monoidal structure (A, ⊕, 0) and a multiplicative
monoidal structure (A, ⊗, 1) where ⊗ distributes over ⊕ on both sides:
∀a, b, c ∈ A. a ⊗ (b ⊕ c) = (a ⊗ b) ⊕ (a ⊗ c) (b ⊕ c) ⊗ a = (b ⊗ a) ⊕ (c ⊗ a)
and the additive unit serves as an annihilator for the multiplicative identity:
∀a ∈ A. a ⊗ 0 = 0 = 0 ⊗ a
If the multiplicative operation is commutative, we have a commutative semiring. Examples are
(N, +, 0, ×, 1) and (B, ∨, ⊥, ∧, >).
D I S C R E T E M AT H E M AT I C S SUMMARY
Ring A semiring whose additive commutative monoid is a commutative group. That is, we have an
additive inverse for every element of A. Again, we have a commutative ring if the multiplicative
operation is commutative. An example is (Z, +, 0, −, ×, 1).
Field A commutative ring which has multiplicative inverse for every non-0 element of A. That is, a
field (A, ⊕, 0, , ⊗, 1, (·)−1 ) is a structure where (A, ⊕, 0, ) is an abelian (additive) group and
(A \ {0}, ⊗, 1, (·)−1 ) is an abelian (multiplicative) group. Examples are (Q, +, 0, −, ×, 1, (·)−1 )
or (R, +, 0, −, ×, 1, (·)−1 ). Fields are sets for which addition, multiplication, subtraction and
division are defined, so a field resembles (and generalises) rational or real numbers – many
operations and theorems defined for real numbers can be interpreted more abstractly for fields,
and therefore applied to any particular instance of a field (such as polynomials or integers
modulo a prime number).
Category An algebraic characterisation of structures that have an ‘source’ and ‘target’. Instead of a
single carrier set, a category is defined on a collection of sets (or, more generally, objects) and a
collection of arrows or morphisms between the objects. A typical example is the category Set of
all sets and all functions between them: the set of morphisms between two sets A and B is the
set A ⇒ B . A category also requires an operation of composition of f : A → B and g : B → C to
get g ◦ f : A → C , and an identity morphism idA : A → A for every object A, satisfying:
From the similarity of the laws, we can see that categories are a generalisation of monoids:
indeed, a one-object category (where there is no distinction between the source and target) is a
monoid (cf. Corollary 110, stating that (Rel(A), ◦, idA) is a monoid for any set A). Any time you are
asked to prove that some relational structure (partial functions, surjections, etc.) has a unital
identity and an associative composition operation, you prove that it is a category. The field of
category theory builds some very complex results from this simple idea, establishing surprising
formal connections between seemingly disparate mathematical concepts and deriving powerful,
abstract results that can be applied to a range of mathematical domains.
Order theory
A branch of mathematics which investigates the notion of ordering and comparison using homogen-
eous binary relations. Like with algebraic structures, we start with a carrier set P and some binary
relation v ∈ Rel(P) satisfying some laws.
• Reflexivity: ∀a ∈ P. a v a
• Transitivity: ∀a, b, c ∈ P. (a v b ∧ b v c) =⇒ a v c
Partial order A partially ordered set or poset is a preorder (P, v) which further satisfies antisymmetry:
∀a, b ∈ P. (a v b ∧ b v a) =⇒ a = b.
Total order A totally ordered set is a poset (P, v) which further satisfies totality (or linearity):
∀a, b ∈ P. a v b ∨ b v a.
D I S C R E T E M AT H E M AT I C S SUMMARY
Strict order A strict order (P, À) can be constructed from any partial order (P, v) by defining À as
a À b ¬ a v b ∧ a 6= b.
The the following definitions are concerned with special constructions within a fixed poset (P, v).
Least and greatest element An element ⊥ ∈ P is the least (or bottom) element of the poset P if it is
below every element in P : ∀a ∈ P. ⊥ v a. An element > ∈ P is the greatest (or top) element if
it is above every element in P : ∀a ∈ P. a v >. Top and bottom elements are unique, if they
exist.
Minimal and maximal element An element m ∈ P is minimal if it has no elements below it:
∀a ∈ P. a v m =⇒ a = m. An element n ∈ P is maximal if it has no elements above it:
∀a ∈ P. n v a =⇒ n = a. If a preorder has no least element, it may still have several minimal
elements which are lower than any other non-minimal element but not related to each other
(and similarly for maximal elements).
Lower and upper bound Given a subset S ⊆ P , an element l ∈ P is a lower bound for S if it is below
every element of S : ∀a ∈ S. l v a. An element u ∈ P is an upper bound for S if it is above every
element of S : ∀a ∈ S. a v u. Bounds do have to exist for every subset, and if they do, they
might not be unique.
Least upper bounds and greatest lower bound Given a subset S ⊆ P , the least upper bound (also
W
called join or supremum), denoted S , is the least element of the set of upper bounds of S ;
that is, the element uniquely determined (if it exists) by the properties:
W
• An upper bound: ∀a ∈ S. a v S
• Below any upper bound: ∀u ∈ P. (∀a ∈ S. a v u) =⇒ S v u
W
V
Dually, the greatest lower bound (also called meet or infimum), denoted S , is the greatest
element of the set of lower bounds of S :
V
• A lower bound: ∀a ∈ S. Sva
• Above any lower bound: ∀l ∈ P. (∀a ∈ S. l v a) =⇒ l v S .
V
These conditions can be equivalently presented with single bi-implications which follow from
W W
combining a v S and S v u via transitivity (and similarly for meets):
_ ^
∀u ∈ P. S v u ⇐⇒ (∀a ∈ S. a v u) ∀l ∈ P. l v S ⇐⇒ (∀a ∈ S. l v a)
Binary joins and meets Meets and joins of two-element sets S = { a, b } are often written as binary
W V
operators: a ∨ b ¬ S and a ∧ b ¬ S . Given a, b ∈ P , the join a ∨ b has the properties:
ava∨b bva∨b ∀u ∈ P. (a v u and b v u) =⇒ a ∨ b v u
and the meet a ∧ b has the properties:
∀u ∈ P. a ∨ b v u ⇐⇒ (a v u and b v u) ∀l ∈ P. l v a ∧ b ⇐⇒ (l v a and l v b)
D I S C R E T E M AT H E M AT I C S SUMMARY
Join- and meet-semilattice A poset (P, v) is a join-semilattice if every pair of elements has a join
(and, by induction, this implies that every finite subset of P has a join). This lets us treat joins as
an abstract algebraic operator ∨: P × P → P whose laws follow from the structure of subsets
in P : they contain unique elements and are unordered, and nested sets can be collapsed into a
single set. The corresponding laws are:
• Idempotence: ∀a ∈ P. a ∨ a = a
• Commutativity: ∀a, b ∈ P. a ∨ b = b ∨ a
• Associativity: ∀a, b, c ∈ P. a ∨ (b ∨ c) = (a ∨ b) ∨ c .
Lattice A poset (P, v) is a lattice if it is both a join- and a meet-semilattice, and in addition, the
following absorption laws hold: ∀a, b ∈ P. a ∧ (a ∨ b) = a and a ∨ (a ∧ b) = a.
Bounded lattice A lattice (P, ∨, ∧) is bounded if it has both a least and greatest element ⊥ and >
which are the units for join and meet, respectively: ∀a ∈ P. a ∨ ⊥ = a = a ∧ >.
Distributive lattice A lattice (P, ∨, ∧) is distributive if meets distribute over joins (and vice versa):
∀a, b, c ∈ P. a ∧ (b ∨ c) = (a ∧ b) ∨ (a ∧ c). Any distributive lattice is a semiring under join
and meet.
Complemented lattice A bounded lattice (P, ∨, ∧, ⊥, >) is complemented if every element a ∈ P has
a complement aû satisfying the complement laws a ∨ aû = > and a ∧ aû = ⊥.
Boolean algebra A Boolean algebra (P, ∨, ∧, >, ⊥, (·) ) is a bounded distributive lattice. Complements
û
in distributive lattices are always unique. We can interpret the classic de Morgan laws in any
Boolean algebra: ∀a, b ∈ P. (a ∧ b)û = aû ∨ bû and (a ∨ b)û = aû ∧ bû .
The prototypical example of a Boolean algebra (which gives it its name and syntax) is the structure
associated with Boolean propositional logic: (B, ∧, ∨, ⊥, >, ¬). Explicitly: B is the set of truth values
{ >, ⊥ } with the order ⊥ v > (and reflexivity); ∧ and ∨ is Boolean conjunction and disjunction,
respectively; ⊥ (false) and > (true) are the least and greatest elements for the order; ¬ is Boolean neg-
ation. The associated Boolean algebra laws (idempotence, associativity, commutativity, distributivity,
annihilation, complement) and the derived identities are exactly the ones shown in Section 1.1. The
rules associated with implication follow from all these laws if we define P =⇒ Q as ¬P ∨ Q (which is
= P =⇒ ⊥ follows from P =⇒ ⊥ = ¬P ∨ ⊥ = ¬P , where we
one of the identities): for example, ¬P ∼
used the unit law for joins and bottom elements. In addition, it is also the case that P v Q if and only
if P =⇒ Q (since the only ordering that doesn’t hold is > v ⊥, which corresponds to the only false
line in the truth table for =⇒), so =⇒ acts as a so-called internalisation of the ordering relation.
D I S C R E T E M AT H E M AT I C S SUMMARY
Number theory
Definitions
Divisibility For all integers d and n, d divides n if:
d | n ⇐⇒ ∃k ∈ Z. n = k · d
Congruence For all m ∈ Z+ and a, b ∈ Z, a and b are congruent modulo m if:
a ≡ b (mod m) ⇐⇒ m | (a − b)
Quotient and remainder The unique pair of natural numbers quo(m, n) and rem(m, n) associated
to a given m ∈ N and n ∈ Z+ by the Division Theorem, with the defining properties:
k +m l ¬ [k + l]m ∧ k ·m l ¬ [k · l]m
Common divisors Given an n ∈ N, the set of its divisors is defined as
D(n) ¬ { d ∈ N | (d | n) }
The set of common divisors of n, m ∈ N is the set
s·m+ t ·n= r
Theorems
Fermat’s Little Theorem For all naturals i and primes p,
∃!q, r ∈ N. r < n ∧ m = q · n + r
The latter condition is known as the universal property of GCDs: a property which uniquely
characterises the greatest common divisor of two numbers without explicitly defining it.
Linear combinations and GCDs For all m, n ∈ Z+ , gcd(m, n) is the least positive linear combination
of m and n. That is:
It follows that m and n are coprime if and only if there is a way to express 1 as their linear
combination: (∃k, l ∈ Z. k · m + l · n = 1) ⇐⇒ gcd(m, n) = 1
The divisibility lattice The structure (N, lcm, gcd, 1, 0), is a bounded lattice, where:
∀d ∈ N. (d | m ∧ d | n) ⇐⇒ d | gcd(m, n)
D I S C R E T E M AT H E M AT I C S SUMMARY
Set theory
Foundations
Definitions
Subset A ⊆ B ⇐⇒ ∀x. x ∈ A =⇒ x ∈ B
Proper subset A ⊂ B ⇐⇒ A ⊆ B ∧ A 6= B
Empty set ∀x. x 6∈ ;
Finite set [n] ¬ { 0, . . . , n − 1 }
Cardinality The size #A or | A| associated with a set A. If it is a natural number, the set is finite.
In general, the numbers used to describe the cardinality of (finite or infinite) sets are called
cardinal numbers.
Universe The ‘domain of discourse’ in set theory often denoted as U – the collection of elements
that we are concerned with, the superset of all the sets that we are investigating. When we
say ‘A is a set’, we usually mean it is a subset of the universe U . We need this subtlety to
avoid set-theoretic paradoxes such as Russell’s paradox. However, we often leave the universe
implicit: writing x for an element implicitly assumes that x ∈ U .
Set comprehension A notation for defining a set by specifying the property that its elements must
satisfy. Abstractly, we write
A ¬ { x ∈ B | P(x) }
to state that A consists of elements (of B ) for which P(x) holds. Thus, saying that x ∈ A is
equivalent to saying that x ∈ B and furthermore P(x) holds.
Powerset P (A) ¬ { X ⊆ U | X ⊆ A}
Intersection A∩ B ¬ { x ∈ U | x ∈ A∧ x ∈ B }
Union A∪ B ¬ { x ∈ U | x ∈ A∨ x ∈ B }
Complement Aû ¬ { x ∈ U | x 6∈ A}
Set difference A \ B ¬ { x ∈ A | x 6∈ B }
Big union For all families of sets F ⊆ P (U )
[
F ¬ { x ∈ U | ∃A ∈ F . x ∈ A}
Big intersection For all families of sets F ⊆ P (U )
\
F ¬ { x ∈ U | ∀A ∈ F . x ∈ A}
Ordered pair (a, b) ¬ { a, { a, b } }
Cartesian product A × B ¬ { (a, b) | a ∈ A ∧ b ∈ B }
D I S C R E T E M AT H E M AT I C S SUMMARY
Finitary product
n
Y
Ai ¬ A1 × · · · × An
i=1
n
Qn
Set exponent A ¬ i=1 A
Tagging { ` } × A ¬ { (`, a) | a ∈ A}
Disjoint union A ] B ¬ ({ 1 } × A) ∪ ({ 2 } × B)
Finitary disjoint union
n
]
Ai ¬ A1 ] · · · ] An
i=1
Un
Set multiplication n · A ¬ i=1
A
Theorems
Algebraic and order-theoretic properties Let A be a carrier set. A can also taken to be the universe
U so these apply to ‘arbitrary sets’ as well.
• (P (A), ⊆) forms a partial order under subset inclusion.
• (P (A), ∪, ∩, ;, A, (·)û ) forms a Boolean algebra. This means that all the algebraic laws in
the first part of the table in Section 1.1 apply to set theory when we replace the join of logic
S
(disjunction) with the join of set theory (union), etc. The big union F and intersection
F are the generalised joins and meets of the subset F ⊆ P (A). The characteristic
T
properties of big unions and intersections follow directly from the definitions of joins
and meets: for all families of sets F , we have
[ \
∀U. F ⊆ U ⇐⇒ (∀X ∈ F . X ⊆ U) ∀L. L ⊆ F ⇐⇒ (∀X ∈ F . L ⊆ X )
• (P (A), ], ×, ;, [1]) forms a commutative semiring up to isomorphism: for example, A×[1]
is not equal to A (as one consists of tuples (a, 0) while the other is simply elements a),
but there is a bijective correspondence between them.
Binary relation A relation R between sets A and B (denoted R: A → B ) is a subset R ⊆ A × B . The set
of all relations between A and B is denoted Rel(A, B). An element (a, b) ∈ R is usually written
a R b (as an operator) or R(a, b) (as a predicate). A relation R ∈ Rel(A) on a set A is R: A → A.
Identity relation and relational composition The identity relation idA is { (a, a) | a ∈ A}, so
idA(a, a0 ) ⇐⇒ a = a0 .
Relational composition Composition of relations R: A → B and S : B → C is a new relation
S ◦ R: A → C defined as { (a, c) | ∃b ∈ B. a R b ∧ b S c }.
D I S C R E T E M AT H E M AT I C S SUMMARY
R◦n ¬ R ◦ · · · ◦ R
| {z }
n times
◦∗
The iterated composition R : A → A is then
[ [
R◦∗ ¬ { R◦n : A → A | n ∈ N } = R◦n
n∈N
Closure Given a relation R ∈ Rel(A) and property P (such as reflexivity), the closure of R under
property P is a relation R
b P ∈ Rel(A) which is the smallest superset of R which satisfies P :
1. R ⊆ R
bP
2. R
b P satisfies P
3. For any other T ∈ Rel(A) which is a superset of R and satisfies P , R
bP ⊆ T .
More generally, we call an arbitrary set A closed under some operation if applying the
operation to elements of A yields an element of A. The closure of a set under an operation
is the smallest superset of A which is closed under the operation. For instance, natural
numbers are closed under addition but not under subtraction; the closure of natural
numbers under subtraction is the set of integers.
Matrices For positive integers m and n, an (m × n)-matrix M over a semiring (S, ⊕, 1, ⊗, 0) is given
by entries Mi, j ∈ S for all 0 ≤ i < m and 0 ≤ j < n. The set of all (m × n)-matrices is denoted
Mat(m, n). An (n×n)-matrix is called a square matrix of order n, and the set of all such matrices
is denoted SqMat(n).
(Zm,n )i, j ¬ 0
Matrix addition The addition of two (m × n)-matrices M and L is the matrix M + L with entries
(M + L)i, j ¬ Mi, j ⊕ L i, j
Matrix from relation For a relation R: [m] → [n] we have a (m × n)-matrix mat(R) over the com-
mutative semiring of Booleans given by
mat(R)i, j ¬ (i, j) ∈ R
Relation from matrix For an (m × n)-matrix M over the semiring of Booleans we have a relation
D I S C R E T E M AT H E M AT I C S SUMMARY
Path For a directed graph (A, R) and s, t ∈ A, a path of length n ∈ N in R with source s and target
t is a tuple (a0 , . . . , an ) ∈ An+1 such that a0 = s, an = t and ai R ai+1 for all 0 ≤ i < n.
Adjacency matrix The adjacency matrix of a finite directed graph ([n], R) for n ∈ Z+ is the
(n × n)-matrix mat(R). There is an edge between nodes labelled i and j iff (i, j) ∈ mat(R).
Theorems
M · (L + L 0 ) = (M · L) + (M · L 0 ) (M + M 0 ) · L = (M · L) + (M 0 · L)
Relations and matrices The functions rel and mat are bijective inverses: for every matrix M over the
semiring of Booleans, mat(rel(M )) = M and for every relation R, rel(mat(R)) = R.
More generally, this shows that the categories Rel and Mat are isomorphic, and the inverse
transformations rel: Mat → Rel and mat: Rel → Mat are structure-preserving mappings of
categories (called functors), which means that they map composition and identities in one
category into composition and identities in the other:
rel(M · L) = rel(M ) ◦ rel(L) mat(S ◦ R) = mat(R) · mat(S)
rel(I n ) = id[n] mat id[n] = I n
Paths and adjacency matrices Given a finite directed graph ([n], R) with adjacency matrix M , the
adjacency matrix M ∗ = mat(R◦∗ ) can be computed as Mn by repeated matrix addition and
D I S C R E T E M AT H E M AT I C S SUMMARY
multiplication:
M0 = I n Mk+1 = I n + (M · Mk )
The graph has a path of length k between nodes i and j if and only if (Mk )i, j holds. Thus, a
node j is inaccessible from i iff (M ∗ )i, j does not hold.
Closures Given a relation R: A → A and a property P (such as reflexivity), the closure of R under P
bP = FR,P where the family FR,P ⊆ P (A × A) is defined as:
T
can be defined as R
FR,P ¬ { Q : A → A | R ⊆ Q ∧ Q satisfies P }
Intuitively, every relation of the family FR,P satisfies the first two conditions in the definition of
a closure above (so it is the set of upper bounds for the closure R
b P ), and the smallest such
relation is the least element of this family of sets, i.e. the meet defined to be the intersection.
Functions
Definitions
Total function A total function (or just function or map) f : A → B ∈ Fun(A, B) is a total func-
tional relation, or a total partial function. The totality and functionality (existence and unique-
ness of mapping, respectively) combines into the unique existence of mapping for functions:
∀a ∈ A. ∃!b ∈ B. f (a) = b. A partial function f : A * B is total if its domain of definition
coincides with its source: D f = A.
Surjection A surjective function or surjection f : A B covers its whole codomain, i.e. maps every
a ∈ A to at least one b ∈ B : ∀b ∈ B. ∃a ∈ A. f (a) = b.
Injection An injective function or injection f : A B embeds the domain into the codomain, i.e.
maps every a ∈ A to at most one b ∈ B : ∀a1 , a2 ∈ A. ( f (a1 ) = f (a2 )) =⇒ a1 = a2 .
Bijection A bijective function or bijection is a function that is both an injection and a surjection, i.e.
maps every a ∈ A to exactly one b ∈ B : ∀b ∈ B. ∃!a ∈ A. f (a) = b. Equivalently, a function
f : A → B is a bijection if there exists a necessarily unique function f −1 : B → A that is both:
• a retraction (left inverse) for f : g ◦ f = idA
• a section (right inverse) for f : f ◦ g = idB
D I S C R E T E M AT H E M AT I C S SUMMARY
Totality
Relation Total relation
Surjectivity
Partial function Function Surjection
Exists dom.
Injection Bijection
Exists cod.
Theorems
Algebraic properties Sets and partial functions, functions, injections, surjections and bijections
between them all form categories, i.e. they all have respective neutral identity maps and are
closed under associative composition.
Cardinality Let A, B be finite sets.
(
0 if #A 6= #B
#PFun(A, B) = (#B + 1)#A #Fun(A, B) = #B #A #Bij(A, B) =
n! if #A = #B = n
Sections and retractions Every injection between sets is a section, and every surjection is a retraction.
The latter statement is equivalent to the axiom of choice, also stated as the Cartesian product
of a non-empty collection of sets is non-empty.
Characteristic function Given a set A and subset S ⊆ A, the characteristic function χS : A → B (where
= [2] is the set of Boolean truth values) associated with S is defined as: χS (a) = a ∈ S .
B∼
Equivalence relation A relation E ∈ Rel(A) is an equivalence relation if it is:
1. reflexive: ∀x ∈ A. x E x
2. symmetric: ∀x, y ∈ A. x E y ⇐⇒ y E x
3. transitive: ∀x, y, z ∈ A. x E y ∧ y E z =⇒ x E z
P =A
S
1. Covering:
2. Pairwise disjointness: ∀B1 , B2 ∈ P. B1 6= B2 =⇒ B1 ∩ B2 = ;
Equivalence class Given a set A and equivalence relation E ∈ EqRel(A), the equivalence class of an
element a ∈ A is the set of elements it is related to by E :
[a] E ¬ { x ∈ A | x E a }
Quotient set Given a set A and equivalence relation E ∈ EqRel(A), the quotient of A by E is the set
of equivalence classes of A under E :
Theorems
Partitions and equivalence classes For every set A, the the sets of equivalence relations and parti-
tions on A are isomorphic: EqRel(A) ∼
= Part(A). The bijection is established by mapping an
equivalence relation E ∈ EqRel(A) to the quotient set A/E , and it inverse maps a partition
P ∈ Part(A) to the relation ≡ P defined as x ≡ P y ⇐⇒ ∃B ∈ P. x ∈ B ∧ y ∈ B .
Calculus of bijections Let A, B , C , X , Y be sets.
A∼
= A = B =⇒ B ∼
A∼ = A (A ∼ = C) =⇒ A ∼
= B ∧ B ∼ = C
P (A) ∼
= P (X ) A× B ∼
= X ×Y A] B ∼
= X ]Y = Rel(X , Y )
Rel(A, B) ∼
= PFun(X , Y )
PFun(A, B) ∼ = Fun(X , Y )
Fun(A, B) ∼ = Bij(X , Y )
Bij(A, B) ∼
• (P (A), ], ×, ;, [1]) forms a commutative semiring up to isomorphism:
= A ] (B ] C) and (A × B) × C ∼
– (A ] B) ] C ∼ = A × (B × C): ] and × are associative.
= B ] A and A × B ∼
– A] B ∼ = B × A: ] and × are commutative.
= A ] [0] and A ∼
– A∼ = A × [1]: [0] is the unit for ], and [1] is the unit for ×.
= (A × C) ] (B × C): × distributes over ].
– (A ] B) × C ∼
• Properties of functions (cf. Section 1.1):
D I S C R E T E M AT H E M AT I C S SUMMARY
– (A ⇒ [1]) ∼
= [1]: unique constantly 0 function from A into the singleton set.
= [1]: unique empty function from the empty set to A.
– ([0] ⇒ A) ∼
– ([1] ⇒ A) ∼
= A: elements a of A are isomorphic to functions 0 7→ a .
– (A ⇒ [0]) ∼
= [0]: if A is nonempty, there are no functions from A into the empty set
(not even the empty function, since there is no b ∈ [0] for every a ∈ A).
– (A ⇒ (B × C)) ∼
= (A ⇒ B) × (A ⇒ C): a function returning a pair can be defined as a
pair of functions.
– ((A ] B) ⇒ C) ∼
= (A ⇒ C) × (B ⇒ C): a function taking a disjoint union can be
defined as a pair of functions (cf. case analysis).
– ((A× B) ⇒ C) ∼
= (A ⇒ (B ⇒ C)): a function taking a pair can be defined as a function
returning a function (cf. currying).
= (A ⇒ (B ] [1])): a partial function can be defined as a function with
– PFun(A, B) ∼
an extra unique value in its codomain (cf. option type).
– P (A) ∼
= (A ⇒ [2]): a subset S of A can be defined via its characteristic function χS .
PFun([m], [n]) ∼
= [(n + 1) ]
m
Fun([m], [n]) ∼
= [n ]
m
Bij([n], [n]) ∼
= [n!]
Set-indexed constructions Given a set I , the family of sets indexed by I is the indexed family { Ai }i∈I
consisting of a set Ai for every i ∈ I . That is, we have a mapping i 7→ Ai from I to { Ai }i∈I .
Various set operations can be indexed by a set I : we recover the usual finitary versions with
I = N and { An }n∈N = { A0 , A1 , . . . }, and binary versions with I = [2] and { Ai }i∈[2] = { A0 , A1 }.
Indexed unions [ [
Ai ¬ { Ai | i ∈ I } = { a | ∃i ∈ I. a ∈ Ai }
i∈I
Indexed products
Ai ¬ α ∈ I ⇒ i∈I Ai ∀i ∈ I. α(i) ∈ Ai
Q S
i∈I
D I S C R E T E M AT H E M AT I C S SUMMARY
Finite sequences ]
A∗ ¬ An
n∈N
Theorems
Cantor’s diagonalisation argument For every set A, no surjection A P (A) exists. As a result, the set
P (N) is uncountable – it is ‘more infinite’ than the already infinite set N. This establishes that
the cardinality of natural numbers (called countable infinity and denoted ℵ0 ) is strictly smaller
than the cardinality of P (N) (which can be denoted as 2ℵ0 in cardinal arithmetic). Similarly,
ℵ0
| P (P (N)) | = 2(2 ) is strictly greater still, and repeated application of the powerset operation
lets us generate a countably infinite sequence of uncountably infinite sets, each strictly larger
than the previous one.
Cardinality of real numbers Any closed interval [a, b] of real numbers between a, b ∈ R is iso-
morphic to the real numbers. In particular, elements of the interval [0, 1] can be described as
binary sequence, corresponding to the bits after the ‘binary point’ in the binary expansion of a
real in [0, 1]. The set of all binary sequences [2]∞ thus also isomorphic to the real numbers,
and so is the set of functions from N to [2] that enumerate the bits in a binary sequence.
Finally, (N ⇒ [2]) is the set of characteristic functions on naturals and is isomorphic to P (N).
= [0, 1] ∼
= [2] = (N ⇒ [2]) ∼
= P (N)
∞ ∼
R∼
Given that the cardinalities of isomorphic sets are equal, this derivation shows that the cardin-
ality of the real numbers (called the continuum, denoted c) is equal to | P (N) | = 2ℵ0 .
Continuum hypothesis There is no set of cardinality strictly between the cardinality of N and R,
that is, there is no cardinal number between ℵ0 and c. Equivalently, if the smallest cardinal
D I S C R E T E M AT H E M AT I C S SUMMARY
number greater than ℵ0 is denoted ℵ1 , the continuum hypothesis states that ℵ1 = c = 2ℵ0 . A
generalisation of the hypothesis states that ℵk+1 = 2ℵk for any k ∈ N, so the infinite sequence
of cardinalities generated by #P k (N) k∈N
is exactly the sequence (ℵk )k∈N . Kurt Gödel and Paul
Cohen showed that the continuum hypothesis is neither provable nor disprovable in Zermelo–
Fraenkel set theory with the axiom of choice, so its validity is undecidable: no contradiction
would arise if either the CH or its negation is added to ZFC.
Theorem
Inductive definitions
Definitions
Axioms and rules We can inductively define a subset of a given set U with axioms and rules, written
h1 h2 ··· hn
a c
Derivation Given a set of axioms and rules for inductively defining a subset of a set U , a derivation
or proof that a particular element u ∈ U is in the subset is a finite rooted tree with vertices
labelled by elements of U such that:
A derivation for u ∈ U is therefore a concrete proof that the axioms can be combined and
translated into u via the rules.
D I S C R E T E M AT H E M AT I C S SUMMARY
Inductively defined subset Given a set of axioms and rules over U , the subset of U inductively
defined by the axioms and rules consists of all and only the elements u ∈ U for which there is
a derivation with the conclusion u.
Theorem
Closure property Given a set U and a collection of axioms and rules, the inductively defined subset
I ⊆ U is the closure of the set of axioms under the application of rules. That is, I is closed
under the rules (applying any rule to any elements of I will yield a conclusion already in I ),
and is the smallest such subset (for any other closed S ⊆ U , I ⊆ S ). This property gives rise to
the proof technique of rule induction.
Regular expressions
Definitions
r r s r s r
a ε ; (r) r |s rs r∗
Matching Each regular expression r over an alphabet Σ induces a language L(r) ⊆ Σ∗ . The strings u
in L(r) are by definition the ones that match r , where:
Finite automata
Definitions
Deterministic finite automaton (DFA) An NFA M = (Q, Σ, ∆, s, F ) with the property that for each state
a
q ∈ Q and each input symbol a ∈ Σ, there is a unique state q0 ∈ Q satisfying q −
→ q0 . That is, ∆
a
can be expressed as a next-state function δ : Q × Σ → Q where ∀q0 . q −→ q0 ⇔ q0 = δ(q, a).
"
" -transitions State transitions q −
→ q0 that do not consume any input symbol.
NFA with " -transitions (NFA" ) A tuple M = (Q, Σ, ∆, s, F, T ) where (Q, Σ, ∆, s, F ) is an NFA and T ⊆
"
Q × Q is the " -transition relation with elements (q, q0 ) ∈ T written as q −
→ q0 .
u
Language accepted by an NFA" We write q =
⇒ q0 to mean that there is a path in an NFA" M =
(Q, Σ, ∆, s, F, T ) from state q to state q0 whose non-" labels form the string u ∈ Σ∗ . A string
u
u ∈ Σ∗ is accepted by M if there exists a state t ∈ F such that s =
⇒ t . A language L(M ) accepted
by M is the set of all strings accepted by M .
Theorem
Since every DFA is an NFA" and the subset construction above creates a DFA from any NFA" , the
class of languages accepted by DFAs and NFA" s is the same – nondeterminism does not add
extra power.
Regular languages
Regular language A language is regular iff it is equal to L(M ) for some DFA M .
Theorems
Kleene’s Theorem The class of regular languages equals the class of languages accepted by a regular
expression. That is:
1. For every regex r , L(r) is a regular language. We establish this by constructing an NFA"
for any regular expression r by structural recursion on r .
2. Every regular language is of the form L(r) for some regex r . We establish this by inductively
defining a regex rq,q 0 for an NFA M = (Q, Σ, ∆, s, F ) satisfying:
S
u ∗ 0
¦ ©
S
L rq,q 0 ¬ u ∈ Σ ∗
q −
→ q in M with all intermediate states of the transitions in S
Closure properties Regular languages are closed under the following operations:
D I S C R E T E M AT H E M AT I C S SUMMARY
Decidability of equivalence Determining whether two regular expressions r and s accept the same
set of languages is decidable, since L(r) = L(s) if and only if L((∼ r) & s) = ;, and checking
whether the DFA corresponding to the regex (∼ r) & s accepts any strings can be done in a finite
number of queries.
Pumping Lemma For every regular language L , there is a number ` ∈ Z+ satisfying the pumping
lemma property: all w ∈ L with | w | ≥ ` can be expressed as a concatenation of three strings
w = u1 vu2 which satisfy (1) v 6= " , (2) | u1 v | ≤ `, and (3) for all n ∈ N, u1 v n u2 ∈ L .
To prove that a language L is not regular, we can establish the negation of the Pumping Lemma:
for each ` ≥ 1, there is some w ∈ L with | w | ≥ ` such that no matter how w is split into three
strings w = u1 vu2 , with v 6= " and | u1 v | ≤ `, there is some n ∈ N for which u1 v n u2 6∈ L .