Sets Relations Functions
Sets Relations Functions
A set is a collection of objects. These objects can be anything, even sets themselves. An
object x that is in a set S is called an element of that set. We write x ∈ S.
Q: the set of all rational numbers (numbers that can be written as a ratio p/q with
p and q integers)
R: the set of real numbers (points on the continuous number line; comprises the
rational as well as irrational numbers)
When all elements of a set A are elements of set B as well, we say that A is a subset of B.
We write this as A ⊆ B.
When A is a subset of B, and there are elements in B that are not in A, we say that A is a
strict subset of B. We write this as A ⊂ B.
When two sets A and B have exactly the same elements, then the two sets are the same.
We write A = B.
Some Theorems:
A⊆A
If A ⊆ B and B ⊆ C then A ⊆ C
The union A ∪ B, which is the set of all objects that are in A or in B (or both)
The intersection A ∩ B, which is the set of all objects that are in A as well as B
The difference A \ B, which is the set of all objects that are in A, but not in B
The Cartesian product A × B, which is the set of all ordered pairs (2-tuples) <a,
b> where a ∈ A and b ∈ B.
This generalizes to any number of sets, i.e. A1 × A2 × … × An is the set of all n-
tuples <a1, a2, …, an> where a1 ∈ A1, a2 ∈ A2, … , and an ∈ An.
Some theorems:
P(∅) = {∅}
A∪B=B∪A Commutation ∪
A∩B=B∩A Commutation ∩
A ∪ (B ∪ C) = A ∪ (B ∪ C) Association ∪
A ∩ (B ∩ C) = A ∩ (B ∩ C) Association ∩
A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C) Distribution ∪ over ∩
A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) Distribution ∩ over ∪
Formalization in FOL:
A relation over two sets, A and B, is called a binary relation. For a binary relation R we
often write aRb instead of <a,b> ∈ R. A binary relation R over A and B is:
Left-Total iff for all a ∈ A there exists at least one b ∈ B such that aRb
Right-Total iff for all b ∈ B there exists at least one a ∈ A such that aRb
Right-Unique iff for all a ∈ A there exists at most one b ∈ B such that aRb
Left-Unique iff for all b ∈ B there exists at most one a ∈ A such that aRb
Anti-symmetric iff for all a ∈ A and b ∈ A where a ≠ b: if aRb then not bRa
(or, what is the same thing: if aRb and bRa then a = b
Transitive iff for all a ∈ A, b ∈ A, and c ∈ A: if aRb and bRc then aRc
Antitransitive iff for all a ∈ A, b ∈ A, and c ∈ A: if aRb and bRc then not aRc
Exercise: Prove this (using non-formal, but still proper mathematical proof)
Formalization in FOL:
∀x ∃y R(x,y) R is Left-total
∀y ∃x R(x,y) R is Right-total
∀x R(x,x) R is reflexive
∀x ¬R(x,x) R is irreflexive
Examples:
(For this reason, a binary relation that is right-unique is often called functional).
A is called the domain, and B the co-domain, of the function f (note: many
mathematicians use the word domain to refer to the set of objects for which a function-
value is defined. We can call that the domain of definition. In the context of our course,
however, it is more useful to regard the domain as the domain (or universe) of discourse.)
If there is an object b such that <a, b>∈ f, then f(a) is defined as b, i.e. f(a) = b
The range of a function f : A → B is the set of all b ∈ B for which there exists some a ∈
A such that f(a) = b
A function f : A → B is:
Surjective (or onto) iff for all b ∈ B, there exists some a ∈ A such that f(a) = b
Injective (or one-to-one) iff there do not exist a1 ∈ A and a2 ∈ A such that a1 ≠
a2 and f(a1) = f(a2)
(So this is a binary relation that has all 4 interesting properties: right-
unique, right-total, left-unique, and left-total. Conceptually, this means
that every element from A corresponds to exactly one element in B, and
vice versa. Indeed, the name makes sense: remember that a binary relation
that is left-total and right-total is a correspondence, i.e. this is where there
is at least one element from B is associated for every element from A, and
vice versa. Accordingly, a functional correspondence would be a function
(right-unique) that is total (left-total) and onto (right-total). Add one-to-
one (left-unique), and you not only have a functional one-to-one
correspondence, but also a binary relation that is right-unique, right-total,
left-unique, and left-total.
For a one-to-one function function f : A → B, we can define its inverse function f-1 : B →
A as follows:
f-1(b) = a if f(a) = b
f-1(b) = undefined otherwise
Note that since f is one-to-one, there can at most be one a such that f(a) = b, so this
function is well-defined.
For any two functions f : A → B and g : B → C we can define the composite function (or
their composition) gf : A → C as follows: