  Ehrenfeucht's lemma (1973) asserts that whenever one element of a model of
Peano arithmetic is definable from another, then they satisfy different types.
We consider here the analogue of Ehrenfeucht's lemma for models of set theory.
The original argument applies directly to the ordinal-definable elements of any
model of set theory, and in particular, Ehrenfeucht's lemma holds fully for
models of set theory satisfying $V=HOD$. We show that the lemma can fail,
however, in models of set theory with $V\neq HOD$, and it necessarily fails in
the forcing extension to add a generic Cohen real. We go on to formulate a
scheme of natural parametric generalizations of Ehrenfeucht's lemma, namely,
the principles of the form $EL(A,P,Q)$, which asserts that whenever an object
$b$ is definable from some $a\in A$ using parameters in $P$, with $b\neq a$,
then the types of $a$ and $b$ over $Q$ are different. We also consider various
analogues of Ehrenfeucht's lemma obtained by using algebraicity in place of
definability, where a set $b$ is algebraic in $a$ if it is a member of a finite
set definable from $a$ (as in Hamkins, Leahy arXiv:1305.5953). Ehrenfeucht's
lemma holds for the ordinal-algebraic sets, we prove, if and only if the
ordinal-algebraic and ordinal-definable sets coincide. Using similar analysis,
we answer two open questions posed by Hamkins and Leahy, by showing that (i)
algebraicity and definability need not coincide in models of set theory and
(ii) the internal and external notions of being ordinal algebraic need not
coincide.
