In mathematics, especially in order theory, an **ultrafilter** is a subset of a partially ordered set (a *poset*) which is maximal among all *proper* filters. Formally, this states that any filter that properly contains an ultrafilter has to be equal to the whole poset. An important special case of the concept occurs if the considered poset is a Boolean algebra, like in the case of an ultrafilter on a set (defined as a filter of the corresponding powerset). In this case, ultrafilters are characterized by containing, for each element *a* of the Boolean algebra, exactly one of the elements *a* and ¬*a* (the latter being the Boolean complement of *a*). This can be specialized by stating that an **ultrafilter on a set** *S* is a collection of subsets of *S* that for each subset *A* of *S* either contains *A* or *S* \ *A*. The possibility of including both is eliminated since filters on sets are always assumed to be proper, i.e. not equal to the whole set. Since the common notions of filters *of a poset* and *on a set* differ only very slightly, this article will always treat both cases in parallel, not without taking care of the fine nuances in notation. Another way of looking at ultrafilters on a set *S* is to define a function *m* on the power set of *S* by setting *m*(*A*) = 1 if *A* is contained in *F* and *m*(*A*) = 0 otherwise. Then *m* is a finitely additive measure on *S*, and every property of elements of *S* is either true almost everywhere or false almost everywhere.
## Types and existence of ultrafilters
There are two very different types of ultrafilter: principal and free. A **principal** (or **fixed**, or **trivial**) ultrafilter is a filter containing a least element. Consequently, principal ultrafilters are of the form *F*_{a}={*x* | *a*≤*x*} for some (but not all) elements *a* of the given poset. In this case *a* is called the *principal element* of the ultrafilter. For the case of filters on sets, the elements that qualify as principals are exactly the one-element sets. Thus, a principal ultrafilter on a set *S* consists of all sets containing a particular point of *S*. Any ultrafilter which is not principal is called a **free** (or **non-principal**) ultrafilter. One can show that every filter is contained in an ultrafilter (see Ultrafilter Lemma) and that free ultrafilters therefore exist, but the proofs involve the axiom of choice in the form of Zorn's Lemma. Consequently explicit examples of free ultrafilters cannot be given. Nonetheless, almost all ultrafilters on an infinite set are free. By contrast, every ultrafilter of a finite poset (or *on* a finite set) is principal, since any finite filter has a least element.
## Applications Ultrafilters on sets are useful in topology, especially in relation to compact Hausdorff spaces, and in model theory in the construction of ultraproducts and ultrapowers. Every ultrafilter on a compact Hausdorff space converges to exactly one point. Likewise, ultrafilters on posets are most important if the poset is a Boolean algebra, since in this case the ultrafilters coincide with the prime filters. Ultrafilters in this form play a central role in Stone's representation theorem for Boolean algebras. The set *G* of all ultrafilters of a poset *P* can be topologized in a natural way, that is in fact closely related to the abovementioned representation theorem. For any element *a* of *P*, let *D*_{a} = { *U* in *G* | *a* in *U* }. This is most useful when *P* is again a Boolean algebra, since in this situation the set of all *D*_{a} is a base for a compact Hausdorff topology on *G*. Especially, when considering the ultrafilters on a set *S* (i.e. the case that *P* is the powerset of *S* ordered via subset inclusion), the resulting topological space is the Stone-Čech compactification of a discrete space of cardinality |*S*|. Ultrafilters on sets are used in the ultrapower construction of certain fields of hyperreal numbers. Gödel's ontological proof of God's existence uses as an axiom that the set of all "positive properties" is an ultrafilter. |