I know we can make rules of the kind:
This will replace
magic[a] is the argument of a function.
Suppose I want
arg[a] to be replaced by
a, but only when
arg[a] is NOT the argument of a function. Ie. I want a rule that applies only on top-level, only in those situations where the first pattern would not apply. Making
arg[a_] := a is inadequate. In pseudocode it would be
arg[a_] := a /; Not[FunctionArgument[arg[a]]].
Is this possible to achieve in Mathematica?