Self-reference is a phenomenon in natural or formal languages consisting of a sentence or formula referring to itself directly, or through some intermediate sentence or formula, or by means of some encoding. In philosophy, it also refers to the ability of a subject to speak of or refer to himself, herself, or itself: to have the kind of thought expressed in English by the word "I".
Self-reference is possible when there are two logical levels, a level and a meta-level. It is most commonly used in mathematics, philosophy, computer programming, and linguistics. Self-referential statements can lead to paradoxes (but see Antinomy for limits on the significance of these).
Self-reference also occurs in literature when an author refers to his work in the context of the work itself. Famous examples include Cervantes's Don Quixote, Denis Diderot's Jacques le fataliste et son maître, Italo Calvino's If on a winter's night a traveler, many stories by Nikolai Gogol, Lost in the Funhouse by John Barth, and Luigi Pirandello's Six Characters in Search of an Author. This is closely related to the concepts of breaking the fourth wall and meta-reference, which often involve self-reference.
The surrealistic painter René Magritte is famous for his self-referential works. His painting The Treachery of Images, shown at right, includes words claiming, in French, it is not a pipe, the truth of which depend entirely on what the word "ceci" (in English, "this") is taken to refer to. Is it the pipe depicted—or is it the painting, or even the sentence itself?
Self-reference is also employed in tautology and in licensed terminology. When a word defines itself (e.g., "Machine: any objects put together mechanically"), the result is a tautology. Such self-references can be quite complex, include full propositions rather than simple words, and produce arguments and terms that require license (accepting them as proof of themselves).
In computer science, self-reference occurs in reflection, where a program can read or modify its own instructions as if they were data. Numerous programming languages support reflection to some extent with varying degrees of expressiveness. Additionally, self-reference is seen in recursion (related to the mathematical recurrence relation), where a code structure refers back to itself during computation.