Can a function be applied to itself?

The answer is no, if the axiom of foundation is accepted as part of set theory. (If it isn't, then this question possibly becomes much more difficult and interesting, and too difficult for me.)

For assume we have a pair $(f,y)$ that belongs to $f$. We have $(f,y) = \{ \{f\},\{f,y\} \}$ Then:

$$f \in \{ f \} \in (f,y) \in f$$

Thus the nonempty set $C = \{ f, \{f\}, (f,y) \}$ doesn't have an $\in$-minimal element. That is, there is no element $x$ of $C$ such that $x \cap C = \emptyset$. This contradicts the axiom of foundation.


As several people have pointed out, this is impossible when we view a function as a "set of ordered pairs". But, if we view a function instead as an algorithm, then it is perfectly possible. For example, I can write a python program that takes a string of characters as input and returns the number of characters in the string. I can then apply this program to itself to determine how many characters it has.

This concept is pushed to the limit in functional programming languages such as Scheme and in the untyped $\lambda$ calculus. These languages eliminate the difference between "code" and "data".

One challenge in finding semantic models for these languages is the set theoretic difficulties mentioned above. But there are, in fact, semantic models for these languages. This is what user322483 referred to in his or her answer.


Yes, see http://en.wikipedia.org/wiki/Domain_theory .

It will not work for the set theoretic definition of a function $f: A\to B \in B^A$ since $B^A \cap A = \emptyset$ when constructed in the category $\cal Set$. This construction is possible in the category of domains, though.


A function $f:A\to B$ can be seen as an element of the set $B^A$. For a function to act on itself, we need a map $g:B^A\to A$. We would also want this map to be a bijection, so that elements of $B^A$ are identified with elements of $A$.

This would require $|B|^{|A|}=|A|$, so $|A|=1$ and $|B|\in\{0,1\}$.

If we have $\mathbb{id}:\{\mathbb{1}\}\to\{\mathbb{1}\}$, given by $\mathbb{1}\mapsto\mathbb{id}(\mathbb{1})=\mathbb{1}$. If we identify $\mathbb{id}$ with $\mathbb{1}$, then $\mathbb{1}(\mathbb{1})=\mathbb{1}$ makes some amount of sense.

So the answer is no, except in some way for trivial cases.