For example, one may say that 'happy' is a synonym of 'joyous.'
However, one may also say that '5' is a synonym of '2+3'. Weird, I know, but bear with me.
In the former case, the two are not exactly the same. The words, while difficult to define, have slightly different connotations. However, the latter are exactly the same. In an ontology, one might say that the latter two identifiers (I mean '5' and '2+3') are referring to literally the same object, whereas the former two identifiers ('happy' and 'joyful') are referring to related, but slightly different, things.
So can we only say that 'x and y are synonyms' if x and y are referring to exactly the same things? Or can they be synonyms if they are merely referring to similar, but slightly different things?