Everything is considered as being in three categories, object (referent, denotation), name, or concept (sense).
The ontology was developed by Alonzo Church[1] based on ideas of Gottlob Frege[2][3] to resolve some paradoxes.
However, Mary does not believe that Pluto is Neptune, a paradox.
The Frege–Church ontology resolves this by saying the belief introduces an "intensional context" whereby the terms following the words "believes that" are in a context whereby they refer not to the denotation of the words, but to the concept associated with the words for the believer.
“The farthest planet from the sun”, as it appears in proposition (1) is Mary’s concept of “the farthest planet from the sun”, not about the actual farthest planet from the sun as it appears in (2), so the substitution cannot be done.