In the mathematical field of set theory, an ultrafilter is a maximal filter, that is, a filter that cannot be enlarged. Filters and ultrafilters are special subsets of partially ordered sets. Ultrafilters can also be defined on Boolean algebras and sets:
Rather confusingly, an ultrafilter on a poset P or Boolean algebra B is a subset of P or B, while an ultrafilter on a set X is a collection of subsets of X. Ultrafilters have many applications in set theory, model theory, and topology.
An ultrafilter on a set X has some special properties. For example, given any subset A of X, the ultrafilter must contain either A or its complement X \ A. In addition, an ultrafilter on a set X may be considered as a finitely additive measure. In this view, every subset of X is either considered "almost everything" (has measure 1) or "almost nothing" (has measure 0).