In mathematics, the term "almost all" means "all but a negligible amount". More precisely, if is a set, "almost all elements of " means "all elements of but those in a negligible subset of ". The meaning of "negligible" depends on the mathematical context; for instance, it can mean finite, countable, or null.
In contrast, "almost no" means "a negligible amount"; that is, "almost no elements of " means "a negligible amount of elements of ".
Throughout mathematics, "almost all" is sometimes used to mean "all (elements of an infinite set) but finitely many". This use occurs in philosophy as well. Similarly, "almost all" can mean "all (elements of an uncountable set) but countably many".[sec 1]
When speaking about the reals, sometimes "almost all" can mean "all reals but a null set".[sec 2] Similarly, if S is some set of reals, "almost all numbers in S" can mean "all numbers in S but those in a null set". The real line can be thought of as a one-dimensional Euclidean space. In the more general case of an n-dimensional space (where n is a positive integer), these definitions can be generalised to "all points but those in a null set"[sec 3] or "all points in S but those in a null set" (this time, S is a set of points in the space). Even more generally, "almost all" is sometimes used in the sense of "almost everywhere" in measure theory,[sec 4] or in the closely related sense of "almost surely" in probability theory.[sec 5]
In number theory, "almost all positive integers" can mean "the positive integers in a set whose natural density is 1". That is, if A is a set of positive integers, and if the proportion of positive integers in A below n (out of all positive integers below n) tends to 1 as n tends to infinity, then almost all positive integers are in A.[sec 7]
More generally, let S be an infinite set of positive integers, such as the set of even positive numbers or the set of primes, if A is a subset of S, and if the proportion of elements of S below n that are in A (out of all elements of S below n) tends to 1 as n tends to infinity, then it can be said that almost all elements of S are in A.
In graph theory, if A is a set of (finite labelled) graphs, it can be said to contain almost all graphs, if the proportion of graphs with n vertices that are in A tends to 1 as n tends to infinity. However, it is sometimes easier to work with probabilities, so the definition is reformulated as follows. The proportion of graphs with n vertices that are in A equals the probability that a random graph with n vertices (chosen with the uniform distribution) is in A, and choosing a graph in this way has the same outcome as generating a graph by flipping a coin for each pair of vertices to decide whether to connect them. Therefore, equivalently to the preceding definition, the set A contains almost all graphs if the probability that a coin flip-generated graph with n vertices is in A tends to 1 as n tends to infinity. Sometimes, the latter definition is modified so that the graph is chosen randomly in some other way, where not all graphs with n vertices have the same probability, and those modified definitions are not always equivalent to the main one.
In topology and especially dynamical systems theory (including applications in economics), "almost all" of a topological space's points can mean "all of the space's points but those in a meagre set". Some use a more limited definition, where a subset only contains almost all of the space's points if it contains some open dense set.
In abstract algebra and mathematical logic, if U is an ultrafilter on a set X, "almost all elements of X" sometimes means "the elements of some element of U". For any partition of X into two disjoint sets, one of them will necessarily contain almost all elements of X. It is possible to think of the elements of a filter on X as containing almost all elements of X, even if it isn't an ultrafilter.
This can also be expressed in the statement: 'Almost all prime numbers are odd.'