# FullSimplify, TransformationFunctions, Assumptions

How can I make Mathematica consider Assumptions in FullSimplify also when applying custom Transformation Functions?

It works with the Automatic Transformation Functions:

FullSimplify[Sqrt[a^2], a < 0]
-a
FullSimplify[a < 0, a < 0]
True


It does not work with custom Transformation Functions:

custom Transformation function replacing negative terms by pi:

tf2[e_] := e /. a__ /; a < 0 -> π


custom complexity function making pi as a result attractive:

myCount = (-Count[#, π, {0, Infinity}]) &;

mySimplify = (FullSimplify[#, a < 0, TransformationFunctions -> {tf2},
ComplexityFunction -> myCount]) &;


This works for numbers

mySimplify


1

mySimplify[-3]


π

It does however not consider the assumption that a<0

mySimplify[a]


a

• A bit hacky, but you could do tf2[e_] := e /. {a__ /; ToCharacterCode[ToString@a] == {97} -> Pi, a__ /; a < 0 -> Pi} I don't know why your example doesn't work though. Jan 8, 2017 at 10:36
• O.k., but a is just an example, I want to match more complex terms later. Jan 8, 2017 at 10:45
• I think it's a matter of mistaking how much assumptions is willing to do. After all Assuming[a < 0, TrueQ[a < 0]] doesn't work, and /; tests the truth of a condition. Jan 8, 2017 at 10:58
• Your tf2 is not using any function using assumptions. Try tf2[e_] := e /. a_ /; Refine[a < 0] -> \[Pi] and mySimplify = Assuming[a < 0, FullSimplify[#, TransformationFunctions -> {tf2}, ComplexityFunction -> myCount]] &;. Apr 10, 2017 at 13:55