In mathematics, equality is a relationship between two quantities or, more generally two mathematical expressions, asserting that the quantities have the same value, or that the expressions represent the same mathematical object. The equality between A and B is written A = B, and pronounced A equals B. The symbol "=" is called an "equals sign". Thus there are three kinds of equality, which are formalized in different ways.
These may be thought of as the logical, set-theoretic and algebraic concepts of equality respectively.
Leibniz characterized the notion of equality as follows:
In this law, "P(x) if and only if P(y)" can be weakened to "P(x) if P(y)"; the modified law is equivalent to the original, since a statement that applies to "any x and y" applies just as well to "any y and x".
Instead of considering Leibniz's law as a true statement that can be proven from the usual laws of logic (including axioms about equality such as symmetry, reflexivity and substitution), it can also be taken as the definition of equality. The property of being an equivalence relation, as well as the properties given below, can then be proved: they become theorems.
The substitution property states:
Some specific examples of this are:
The reflexive property states:
This property is generally used in mathematical proofs as an intermediate step.
The symmetric property states:
The transitive property states:
These three properties were originally included among the Peano axioms for natural numbers. Although the symmetric and transitive properties are often seen as fundamental, they can be proved if the substitution and reflexive properties are assumed instead.
When A and B are not fully specified or depend on some variables, equality is a proposition, which may be true for some values and false for some other values. Equality is a binary relation, or, in other words, a two-arguments predicate, which may produce a truth value (false or true) from its arguments. In computer programming, its computation from two expressions is known as comparison.
Equality of sets is axiomatized in set theory in two different ways, depending on whether the axioms are based on a first-order language with or without equality.
In first-order logic with equality, the axiom of extensionality states that two sets which contain the same elements are the same set.
Incorporating half of the work into the first-order logic may be regarded as a mere matter of convenience, as noted by Lévy.
In first-order logic without equality, two sets are defined to be equal if they contain the same elements. Then the axiom of extensionality states that two equal sets are contained in the same sets.
When A and B may be viewed as functions of some variables, then A = B means that A and B define the same function. Such an equality of functions is sometimes called an identity. An example is (x + 1)2 = x2 + 2x + 1. Sometimes, but not always, an identity is written with a triple bar: (x + 1)2 ≡ x2 + 2x + 1.
An equation is the problem of finding values of some variables, called unknowns, for which the specified equality is true. Equation may also refer to an equality relation that is satisfied only for the values of the variables that one is interested in. For example, x2 + y2 = 1 is the equation of the unit circle.
There is no standard notation that distinguishes an equation from an identity or other use of the equality relation: a reader has to guess an appropriate interpretation from the semantics of expressions and the context. An identity is asserted to be true for all values of variables in a given domain. An "equation" may sometimes mean an identity, but more often it specifies a subset of the variable space to be the subset where the equation is true.
In some cases, one may consider as equal two mathematical objects that are only equivalent for the properties that are considered. This is, in particular the case in geometry, where two geometric shapes are said equal when one may be moved to coincide with the other. The word congruence is also used for this kind of equality.
There are some logic systems that do not have any notion of equality. This reflects the undecidability of the equality of two real numbers defined by formulas involving the integers, the basic arithmetic operations, the logarithm and the exponential function. In other words, there cannot exist any algorithm for deciding such an equality.
The binary relation "is approximately equal" between real numbers or other things, even if more precisely defined, is not transitive (it may seem so at first sight, but many small differences can add up to something big). However, equality almost everywhere is transitive.
Viewed as a relation, equality is the archetype of the more general concept of an equivalence relation on a set: those binary relations that are reflexive, symmetric, and transitive. The identity relation is an equivalence relation. Conversely, let R be an equivalence relation, and let us denote by xR the equivalence class of x, consisting of all elements z such that x R z. Then the relation x R y is equivalent with the equality xR = yR. It follows that equality is the finest equivalence relation on any set S, in the sense that it is the relation that has the smallest equivalence classes (every class is reduced to a single element).
In some contexts, equality is sharply distinguished from equivalence or isomorphism. For example, one may distinguish fractions from rational numbers, the latter being equivalence classes of fractions: the fractions and are distinct as fractions, as different strings of symbols, but they "represent" the same rational number, the same point on a number line. This distinction gives rise to the notion of a quotient set.
Similarly, the sets
are not equal sets – the first consists of letters, while the second consists of numbers – but they are both sets of three elements, and thus isomorphic, meaning that there is a bijection between them, for example
However, there are other choices of isomorphism, such as
and these sets cannot be identified without making such a choice – any statement that identifies them "depends on choice of identification". This distinction, between equality and isomorphism, is of fundamental importance in category theory, and is one motivation for the development of category theory.