# Any differences between Activate[...] vs ReplaceAll[...,Inactive[f_]-f>]?

I can activate an expression with Inactive objects such as

expr = Inactive[f][Inactive[f][x], y] + Inactive[f]

by applying Activate:

Activate[expr]
(*f + f[f[x],y]*)

But also, I can achieve the same task with ReplaceAll:

expr /. Inactive[f] :> f

Should I be aware of any differences between these two methods of activation? Or is Activate really just ReplaceAll under the hood? Or maybe it is the same as Replace[expr,Inactive[f] :> f,{0,Infinity},Heads->True due to similarities in options?

There is at least one difference in evaluation between Activate and either of your proposed equivalents, for a malformed Inactive expression:

Inactive[1 + 1, 5] // Activate
Inactive[1 + 1, 5] /. Inactive[x_] :> x
Replace[Inactive[1 + 1, 5], Inactive[x_] :> x, {0, -1}, Heads -> True]
2

Inactive[1 + 1, 5]

Inactive[1 + 1, 5]

Therefore the replacement appears to be closer to:

Inactive[1 + 1, 5] /. Inactive[x_, ___] :> x
2

This however does not match with nested Inactives:

Inactive[Inactive[a]] // Activate
Inactive[Inactive[a]] /. Inactive[x_, ___] :> x
a

Inactive[a]

But the modified Replace form does:

Replace[Inactive[Inactive[a]], Inactive[x_, ___] :> x, {0, -1}, Heads -> True]
a

I have yet to make this behave differently from Activate.

• So perhaps it is equivalent to ReplaceRepeated (//.) with your modified rule Inactive[x_, ___] :> x? Commented Mar 8, 2020 at 7:50
• @QuantumDot That could be less efficient than the Replace form and I don't see the advantage of it, and ReplaceRepeated doesn't supports Heads does it? Commented Mar 8, 2020 at 8:46