FullSimplify and Min/Max

I was coding up some bounds propagation in some constraint satisfaction code I was playing with and decided to see if Mathematica could simplify an expression involving Min and Max. I extracted the essence of what it seemed not to be able to do.

For example:

FullSimplify[Max[a, Max[b, c]]]

gives what I expect:

Max[a, b, c]

But

FullSimplify[Max[a, Max[b + z, c + z] - z]]

doesn't:

Max[a, -z + Max[b + z, c + z]]

Often though Mathematica knows more than me. Am I missing something here?

• Curious: Max[a, FullSimplify[Max[b + z, c + z] - z]] works. Mar 21 '18 at 18:49
• FullSimplify[Max[b + z, c + z] - z] yields a Piecewise expression, not Max[b,c] as you might expect. Suppose that has something to do with it. Mar 21 '18 at 19:01

IMO, the problem is that there is no built-in transformation like the one the OP seems be to thinking of. We can try adding it, and the desired result occurs:

Simplify[Max[a, Max[b + z, c + z] - z],
TransformationFunctions -> {Automatic,
Replace[#, HoldPattern[Max[args__] + b_] :> Max @@ ({args} + b)] &}]

(*  Max[a, b, c]  *)

If we consider the domain of Max, which includes ±Infinity in addition to the real numbers, then the above result is only generically correct, which may explain why the desired result takes some work to obtain:

Max[a, Max[b + z, c + z] - z] /. {a -> 1, b -> -Infinity, c -> 10, z -> Infinity}
(*  Infinity::indet: Indeterminate expression warning  *)
(*  Out[]= Indeterminate  *)

Max[a, b, c] /. {a -> 1, b -> -Infinity, c -> 10, z -> Infinity}
(*  Out[]= 10  *)

Nonetheless, even if you exclude infinities, the needed transformation does not seem to exist:

FullSimplify[Max[a, Max[b + z, c + z] - z], Thread[-∞ < {a, b, c, z} < ∞]]
(*  Max[a, -z + Max[b + z, c + z]]  *)
• That's very interesting. Thank you for this. May 22 '18 at 14:21
Simplify[Max[a, Max[b + z, c + z] - z]] // PiecewiseExpand Max[a, Simplify[Max[b + z, c + z] - z]] // PiecewiseExpand % == %%

(* True *)
• Well that doesn't really enlighten me any. I tried FindInstance[ Max[a, Max[b + z, c + z] - z] != Max[a, b, c], {a, b, c, z}] and it found no instances. So I am not missing something. Mar 21 '18 at 22:10
• interesting, ((a - b >= 0 && b - c >= 0) || (b - c < 0 && a - c >= 0)) should reduce to a>=b&&a>=c which would make the equivalence to Max[a,b,c] more clear. Mar 21 '18 at 22:33