I usually use WReach's define tool to define new functions.
For example, running
define[f[x_]:=x]
FullDefinition[f]
we got a bunch of definitions.
f[x_]:=x
def$:f[___]:=(Message[define::badargs,f,def$];Abort[])
Attributes[def$]={Temporary}
Attributes[define]={HoldAll}
define[body_,attribute_Symbol]:=define[body,{attribute}]
define[body:_Set|_SetDelayed,attributes_List:{}]:=define[CompoundExpression[body],attributes]
define[body:CompoundExpression[(Set|SetDelayed)[name_Symbol[___],_]..],attributes_List:{}]:=(ClearAll[name];SetAttributes[name,DeleteCases[attributes,Open]];If[!MemberQ[attributes,Open],def:name[___]:=(Message[define::badargs,name,def];Abort[])];body;)
def:define[___]:=(Message[define::malformed,def];Abort[])
define/:define::badargs=There is no definition for '``' applicable to ``.
define/:define::malformed=Malformed definition: ``
Now I define another function
define[g[x_]:=x]
We know function g
is actually equivalent to f
except with a different name. Is there a way to have a function
compareFullDefinition[f,g]
that check this actual equivalence and will give True for this case?
DownValues[]
somehow, after making some obvious function name replacements. $\endgroup$