Collection - Set

1 - About

A set is:

The objects element of the set have the same type (the type may be a composed type such as a tuple)

The mathematical concept of a set is a group of unique items, meaning that the group contains no duplicates (theory) but many data application have extended this definition with a bag (multiset) (such as a table)

The set is used to perform distinct operation (ie deleting duplicates)

3 - Examples

3.1 - In Programming language

Some real-world examples of sets include the following:

  • The set of uppercase letters 'A' through 'Z'
  • The set of nonnegative integers {0, 1, 2 …}
  • The set of reserved Java programming language keywords {'import', 'class', 'public', 'protected'…}
  • A set of people (friends, employees, clients, …)
  • The set of records returned by a database query - See resulset (in java)
  • The set of Component objects in a Container
  • The set of all pairs
  • The empty set {}

3.2 - In Computer Science

  • The idea of a “connection pool” is a set of open connections to a database server.
  • Web servers have to manage sets of clients and connections.
  • File descriptors provide another example of a set in the operating system.

4 - Basic properties of sets

The basic properties of sets:

  • Sets contains only one instance of each item
  • Sets may be finite or infinite
  • Sets can define abstract concepts

5 - Set expression

5.1 - Set of Non-negative number

In Mathese, “the set of non-negative numbers” is written like this:

delim{lbrace}{  x in bbR : x>= 0}{rbrace}


  • The colon stands for “such that”
  • the part before the colon specifies the elements of the set, and introduces a variable to be used in the second part
  • the part after the colon: defines a filter rule

The above notation can also be shortened if x is wel known :

delim{lbrace}{ x : x>= 0}{rbrace}

5.2 - Another example

Another example where the set consists of 1/2 and 1/3

delim{lbrace}{ x : x^2 - {5/6}x + {1/6} = 0}{rbrace}

5.3 - Tuple

Tuples examples in set expression:

  • The set expression of all pairs of real numbers in which the second element of the pair is

the square of the first can be written:

delim{lbrace}{(x,y) in bbR x bbR : y = x^2 }{rbrace}

of abbreviated:

delim{lbrace}{(x,y) : y = x^2 }{rbrace}

  • The set expression of triples consisting of nonnegative real numbers.

delim{lbrace}{(x,y, z) in bbR x bbR x bbR: x >= 0, y >= 0, z >=0}{rbrace}

6 - Documentation / Reference

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap