In philosophy, identity is the quality of being "the same as". It is of particular interest to logicians and metaphsicians.
In logic, the identity relation is normally, (by definition), the transitive, symmetrical, and reflexive relation that holds only between a thing and itself. That is, identiy is the two-place predicate, _=_, such that for all x, y, "x=y" is true iff x is y.
More usefully, it can be expressed formally in second-order logic or in set theory: For all objects x, y, if for all properties F, Fx iff Fy, then x=y
It is an axiom of most normal modal logics that for all x, if x=x then necessarily x=x.
(These definitions are of course inapplicable in some area of quantified logic, such as fuzzy logic and fuzzy set theory, and with respect to vague objects.)
Metaphysicians, and sometimes philosophers of language and mind, ask other questions:
A traditional view is that of Gottfried Leibniz, who held that x is the same as y if and only if every predicate true of x is true of y as well.
Leibniz's ideas have taken root in the philosophy of mathematics, where they have influenced the development of the predicate calculus as Leibniz's law. Mathematicians sometimes distinguish identity from equality. More mundanely, an identity in mathematics may be an equation that holds true for all values of a variable.
More recent metaphysicians have discussed trans-world identity -- the notion that there can be the same object in different possible worlds.
Two objects can be called identical, meaning that they have the same shape, size and other properties. Thus, when we interchange the two objects, we do not see any difference. However, in terms of a stricter sense of identity, the initial and final situation are different. By observing not just the initial and final situation but the move itself, we can know this.
In object-oriented programming, object identity is a mechanism for distinguishing different objects from each other. This is based on the philosophical concept of identity, but applied to data structures.
In programs, one frequently may have several variables (or pointers) which refer to the same underlying data structure. An identity predicate allows one to ask whether two variables refer to the same thing. In many languages, identity can be determined more efficiently than equality since the former involves simply a pointer comparison while the latter must traverse data structures.