The key is that, effectively, one layer of Unevaluated
is removed before the expression is pattern-matched. From the docs:
f[Unevaluated[expr]]
effectively works
by temporarily setting attributes so
that f
holds its argument unevaluated,
then evaluating f[expr]
.
Thus, in the first case, f[Unevaluated[1 + 1]]
is evaluated as f[1 + 1]
, but remaining unevaluated during pattern matching even though f
lacks Hold*
attributes, and since nothing matches f[1 + 1]
, the original expression (pre-pattern-matching) is returned unevaluated.
In the second case, f[Unevaluated[Unevaluated[1 + 1]]]
evaluates as f[Unevaluated[1 + 1]]
in the pattern-matcher, which does match a pattern for f
, and then f[1 + 1]
is evaluated recursively, and thus you get f[2]
.
In the third case, f[Unevaluated[Unevaluated[Unevaluated[1 + 1]]]]
evaluates as f[Unevaluated[Unevaluated[Unevaluated[1 + 1]]]]
, matches, and recursively evaluates as f[Unevaluated[1 + 1]]
, and we're back to the first case.
In the fourth case, f[Unevaluated[Unevaluated[Unevaluated[Unevaluated[1 + 1]]]]]
matches on f[Unevaluated[Unevaluated[Unevaluated[1 + 1]]]]
, recursively evaluates f[Unevaluated[Unevaluated[1 + 1]]]
, and we're back to the second case.
HTH!