Synonym

A synonym is a word, morpheme, or phrase that means exactly or nearly the same as another word, morpheme, or phrase in the same language. For example, the words "begin", "start", "commence", and "initiate" are all synonyms of one another; they are synonymous. The standard test for synonymy is substitution: one form can be replaced by another in a sentence without changing its meaning. Words are considered synonymous in only one particular sense: for example, "long" and "extended" in the context "long time" or "extended time" are synonymous, but "long" cannot be used in the phrase "extended family". Synonyms with exactly the same meaning share a seme or denotational sememe, whereas those with inexactly similar meanings share a broader denotational or connotational sememe and thus overlap within a semantic field. The former are sometimes called cognitive synonyms and the latter, near-synonyms, plesionyms or poecilonyms. 
Lexicography.
Some lexicographers claim that no synonyms have exactly the same meaning (in all contexts or social levels of language) because etymology, orthography, phonic qualities, connotations, ambiguous meanings, usage, and so on make them unique. Different words that are similar in meaning usually differ for a reason: "feline" is more formal than "cat"; "long" and "extended" are only synonyms in one usage and not in others (for example, a "long arm" is not the same as an "extended arm"). Synonyms are also a source of euphemisms.
Metonymy can sometimes be a form of synonymy: "the White House" is used as a synonym of "the administration" in referring to the U.S. executive branch under a specific president. Thus a metonym is a type of synonym, and the word "metonym" is a hyponym of the word "synonym".
The analysis of synonymy, polysemy, hyponymy, and hypernymy is inherent to taxonomy and ontology in the information-science senses of those terms. It has applications in pedagogy and machine learning, because they rely on word-sense disambiguation.
Etymology.
The word is borrowed from Latin "synōnymum", in turn borrowed from Ancient Greek "synōnymon" (), composed of "sýn" ( 'together, similar, alike') and "-ōnym-" (), a form of "onoma" ( 'name').
Sources of synonyms.
Synonyms are often some from the different strata making up a language. For example, in English, Norman French superstratum words and Old English substratum words continue to coexist. Thus, today we have synonyms like the Norman-derived "people", "liberty" and "archer", and the Saxon-derived "folk", "freedom" and "bowman". For more examples, see the list of Germanic and Latinate equivalents in English.
Loanwords are another rich source of synonyms, often from the language of the dominant culture of a region. Thus most European languages have borrowed from Latin and ancient Greek, especially for technical terms, but the native terms continue to be used in non-technical contexts. In East Asia, borrowings from Chinese in Japanese, Korean, and Vietnamese often double native terms. In Islamic cultures, Arabic and Persian are large sources of synonymous borrowings.
For example, in Turkish, "kara" and "siyah" both mean 'black', the former being a native Turkish word, and the latter being a borrowing from Persian. In Ottoman Turkish, there were often three synonyms: water can be "su" (Turkish), "âb" (Persian), or "mâ" (Arabic): "such a triad of synonyms exists in Ottoman for every meaning, without exception". As always with synonyms, there are nuances and shades of meaning or usage.
In English, similarly, we often have Latin and Greek terms synonymous with Germanic ones: "thought", "notion" (L), "idea" (Gk); "ring", "circle" (L), "cycle" (Gk). English often uses the Germanic term only as a noun, but has Latin and Greek adjectives: "hand", "manual" (L), "chiral" (Gk); "heat", "thermal" (L), "caloric" (Gk). Sometimes the Germanic term has become rare, or restricted to special meanings: "tide", "time"/"temporal", "chronic".
Many bound morphemes in English are borrowed from Latin and Greek and are synonyms for native words or morphemes: "fish", "pisci-" (L), "ichthy-" (Gk).
Another source of synonyms is coinages, which may be motivated by linguistic purism. Thus the English word "foreword" was coined to replace the Romance "preface". In Turkish, "okul" was coined to replace the Arabic-derived "mektep" and "mederese", but those words continue to be used in some contexts.
Uses of synonyms.
Synonyms often express a nuance of meaning or are used in different registers of speech or writing.
Different technical fields may appropriate synonyms for specific technical meanings.
Some writers avoid repeating the same word in close proximity, and prefer to use synonyms: this is called elegant variation. Many modern style guides criticize this.
Examples.
Synonyms can be any part of speech, as long as both words belong to the same part of speech. Examples:
Synonyms are defined with respect to certain senses of words: "pupil" as the "aperture in the iris of the eye" is not synonymous with "student". Similarly, "he expired" means the same as "he died", yet "my passport has expired" cannot be replaced by "my passport has died".
A thesaurus or synonym dictionary lists similar or related words; these are often, but not always, synonyms.