| Set Notation
Set notation is a way of describing the membership of and relationships
between groups of objects. Set notation is used in a wide range of
documents and contexts, one example being the definition of a database
query. This page is written from the perspective of a programmer who
is likely to find set notation in specifications and description of
algorithms and who needs to decode it.
In theory, much math and programming is self defining, however, the
necessary understanding is usually only acquired after a verbal or written
description or an example.
The examples below are based on integer values which are treated as
objects, however the same notation is applied to non-numeric objects, e.g.
footballers, planets and anything else for which a database has been
created.
Universal Set
The term universal set is used to describe all the items under
consideration. It gets round the problem of handling things which
are not in a set. The examples below are based on a
universal set which is all positive integers, this means we are not
dealing the value of pi, a pair of high heeled
shoes or the family dog.
Definition of a Set
It is a feature of language that it is convenient to give an object a
name, so we'll use the creativity that programmers are famous for and call
our example set "A". This can be defined simply by listing its
members between curly brackets:

Whilst this works for simple sets, it may be more practical to use use
functions, equalities or other devices as appropriate as shown below:

In this case the universal set has been defined as all positive integers,
thus set A is all values of x which are greater than or equal to zero and
less than or equal to 19. The colon is shorthand for "such that".
Membership of Sets
The notation for showing if an object is a member of a set is:

Equality of sets
Sets are described as equal if they contain the same members, thus:

Disjointed Sets
Two or more sets are said to be disjointed if they do not have any common
members:
Subsets
Subsets are sets which are formed from the members of an existing set:
If a set operation is required to produce a set which is either equal to
another set or a subset of it, the condition is:
If the desired result is a set which is not a subset, the following
condition should be true:

Intersections
An intersection operation between two sets produces a result which
contains elements which are common to both sets:
Unions
A union operation between two sets produces a result which contains the
members of both sets:
In the above example, the sets have a common element, the number five, but
a union can be formed from disjointed sets.
Compliments
The compliment of a set is all members of the universal set which are not
in a specific set. In this example, the universal set is all
positive integers:

Empty sets
An empty or null set is defined as a set with no members, it has its own
symbol, the operation below produces an empty set:

|