# Nested set

In a naive set theory, a nested set[dubious ] is a set containing a chain of subsets, forming a hierarchical structure, like Russian dolls.

It is used as reference-concept in all scientific hierarchy definitions, and many technical approaches, like the tree in computational data structures or nested set model of relational databases.

Sometimes the concept is confused with a "set of sets" with a hereditary property (like the finiteness in a hereditarily finite set).

## Formal definition

Some authors prefer to use the term nested set collection, because it is a formal definition of a collective property of many sets. Others prefer to classify this relation as an inclusion order. A collection is a "set of sets".

Let B be a non-empty set and C be a collection of subsets of B. Then C is a nested set collection if:

• $B\in C$ (and $\emptyset \notin C$ )
• $\forall H,K\in C~:~H\cap K\neq \emptyset \implies H\subset K~\lor ~K\subset H$ The first condition states that set B, which contains all the elements of any subset, must belong to the Nested Set Collection. Some authors also state that B is not empty or the empty is not a subset of C.[clarification needed]

The second condition states the intersection of every couple of sets in the Nested Set Collection is not the empty-set only if one set is a subset of the other.

In particular, when scanning all pairs of subsets at the second condition, it is true for any combination with B.

### Example

Using a set of atomic elements, as the set of the playing card suits:

B = {♠, ♥, ♦, ♣};     B1 = {♠, ♥};   B2 = {♦, ♣};   B3 = {♣};
C = {B, B1, B2, B3}.

The second condition (of the formal definition) can be checked by combining all pairs:

B1B2 = ∅;  B1B3 = ∅;  B3B2.

There is a hierarchy that can be expressed by two branches and its nested order: B3B2BB1B.

## Derived concepts

As sets, that are general abstraction and foundations for many concepts, the nested set is the foundation for "nested hierarchy", "containment hierarchy" and others.

### Nested hierarchy

A nested hierarchy or inclusion hierarchy is a hierarchical ordering of nested sets. The concept of nesting is exemplified in Russian matryoshka dolls. Each doll is encompassed by another doll, all the way to the outer doll. The outer doll holds all of the inner dolls, the next outer doll holds all the remaining inner dolls, and so on. Matryoshkas represent a nested hierarchy where each level contains only one object, i.e., there is only one of each size of doll; a generalized nested hierarchy allows for multiple objects within levels but with each object having only one parent at each level. Illustrating the general concept:

${\text{square}}\subset {\text{quadrilateral}}\subset {\text{polygon}}\subset {\text{shape}}\,$ A square can always also be referred to as a quadrilateral, polygon or shape. In this way, it is a hierarchy. However, consider the set of polygons using this classification. A square can only be a quadrilateral; it can never be a triangle, hexagon, etc.

Nested hierarchies are the organizational schemes behind taxonomies and systematic classifications. For example, using the original Linnaean taxonomy (the version he laid out in the 10th edition of Systema Naturae), a human can be formulated as:

${\text{H. sapiens}}\subset {\text{Homo}}\subset {\text{Primates}}\subset {\text{Mammalia}}\subset {\text{Animalia}}$ Taxonomies may change frequently (as seen in biological taxonomy), but the underlying concept of nested hierarchies is always the same.

### Containment hierarchy

A containment hierarchy is a direct extrapolation of the nested hierarchy concept. All of the ordered sets are still nested, but every set must be "strict" — no two sets can be identical. The shapes example above can be modified to demonstrate this:

${\text{square}}\subsetneq {\text{quadrilateral}}\subsetneq {\text{polygon}}\subsetneq {\text{shape}}\,$ The notation $x\subsetneq y\,$ means x is a subset of y but is not equal to y.

Containment hierarchy is used in class inheritance of object-oriented programming.