Necessity of identity

In modal logic, the necessity of identity is the thesis that for every object x and object y, if x and y are the same object, it is necessary that x and y are the same object. The thesis is best known for its association with Saul Kripke, who published it in 1971, although it was first derived by the logician Ruth Barcan Marcus in 1947, and later, in simplified form, by W. V. O. Quine in 1953.
Kripke's derivation.
The derivation in Kripke's 'Identity and Necessity' is in three steps:
The first premise is simply postulated: every object is identical to itself. The second is an application of the principle of substitutivity: if a = b, then a has all the properties b has, thus from Fa, infer Fb, where F is 'nec(a = --)'. The third follows by elementary predicate logic.
Rigid designation.
In the later "Naming and Necessity", Kripke suggested that the principle could be derived directly, assuming what he called rigid designation. A term is a rigid designator when it designates the same object in every possible world in which that object exists. When a name's referent is fixed by the original act of naming, it becomes a rigid designator. Some examples of rigid designators include proper names (i.e. ‘Richard Nixon’), natural kind terms ( i.e. ‘gold’ or ‘H2O’) and some descriptions.
Proper names are typically rigid designators, but definite descriptions are typically not. So we can speak of "Richard Nixon" referring to the same person in all possible worlds, but the description "the man who won the 1968 election" could refer to many different people. According to Kripke, the proper name "Richard Nixon" can only be used rigidly, but the description "the man who won the 1968 election" can be used non-rigidly. Kripke argues, that if names are rigid designators, then identity must be necessary, because the names ‘a’ and ‘b’ will be rigid designators of an object x if a is identical to b, and so in every possible world, ‘a’ and ‘b’ will both refer to this same object x, and no other, and there could be no situation in which a might not have been b, otherwise x would not have been identical with itself.
This does not mean that we have knowledge of this necessity. Before the discovery that Hesperus (the evening star) and Phosphorus (the morning star) were the same planet, this fact was not known, and could not have been inferred from first principles. Thus there can be a posteriori necessity.
The principle can also be applied to natural kinds. If water is H2O, then water is "necessarily" H2O. Since the terms 'water' and 'H2O' pick out the same object in every possible world, there is no possible world in which 'water' picks out something different from 'H2O'. Therefore, water is necessarily H2O. It is possible, of course, that we are mistaken about the chemical composition of water, but that does not affect the necessity of identities. What is not being claimed is that water is necessarily H2O, but "conditionally", "if" water is H2O (though we may not know this, it does not change the fact if it is true), then water is necessarily H2O.