# Faster way to perform SameQ[Reduce[…], Reduce[…]]

I'm have some expressions that I need to confirm the equality of. SameQ[Reduce[...], Reduce[...]] works like a charm for the more simple expressions, however when they get much more complicated than the ones below Mathematica takes an inordinately large period of time, memory and CPU power to return an answer.

SameQ[
Reduce[(a > b && a > c && a > d && a > e && a > f && a > g && a <= h) || (a <= b && b > c && b > d && b > e && b > f && b > g && b <= h) || (a <= c && c >= b && c > d && c > e && c > f && c > g && c <= h) || (a <= d && d >= b && d >= c && d > e && d > f && d > g && d <= h) || (a <= e && e >= b && e >= c && e >= d && e > f && e > g && e <= h) || (a <= f && f >= b && f >= c && f >= d && f >= e && f > g && f <= h) || (a <= g && g >= b && g >= c && g >= d && g >= e && g >= f && g <= h), {a,b,c,d,e,f,g,h}, Reals],
Reduce[(a <= h && b <= h && c <= h && d <= h && e <= h && f <= h && g <= h), {a,b,c,d,e,f,g,h}, Reals]
]


Can I rephrase this query to Mathematica that would enable it to run any quicker?

• I tried TautologyQ[Equivalent[p1, p2], {a, b, c, d, e, f, g, h}] but it's not working and don't know why. – b.gates.you.know.what May 22 '13 at 7:47
• After 1945 seconds (half hour), this gave me True : Resolve[ ForAll[{a, b, c, d, e, f, g, h}, BooleanMinimize /@ (p1 \[Equivalent] p2)], Reals] – Rojo May 22 '13 at 20:49
• Why do you think this is inordinately slow? It takes my computer 50 seconds (10.0.2 Macbook Air). Seems reasonable to me given the complex nature of the output of Reduce. – djp Mar 2 '15 at 5:06

gcd1 = Simplify@
GenericCylindricalDecomposition[(a > b && a > c && a > d && a > e &&
a > f && a > g && a <= h) || (a <= b && b > c && b > d &&
b > e && b > f && b > g && b <= h) || (a <= c && c >= b &&
c > d && c > e && c > f && c > g && c <= h) || (a <= d &&
d >= b && d >= c && d > e && d > f && d > g &&
d <= h) || (a <= e && e >= b && e >= c && e >= d && e > f &&
e > g && e <= h) || (a <= f && f >= b && f >= c && f >= d &&
f >= e && f > g && f <= h) || (a <= g && g >= b && g >= c &&
g >= d && g >= e && g >= f && g <= h), {a, b, c, d, e, f, g, h}];
gcd2 = Simplify@
GenericCylindricalDecomposition[(a <= h && b <= h && c <= h &&
d <= h && e <= h && f <= h && g <= h), {a, b, c, d, e, f, g,  h}];

Resolve[ForAll[{a, b, c, d, e, f, g, h},
Implies[gcd2, gcd1] && Implies[gcd1, gcd2]], Reals]

(* True *)


Edit (J.M.):

or (I don't know why it was not working before*)

Resolve[ForAll[{a, b, c, d, e, f, g, h},  Equivalent[gcd1, gcd2]], Reals]
(* True *)

• ...or Resolve[ForAll[{a, b, c, d, e, f, g, h}, Equivalent[gcd1, gcd2]], Reals]. – J. M.'s ennui Mar 4 '16 at 18:58
• @J.M. Yep. But doesn't work here (V9) – Dr. belisarius Mar 4 '16 at 18:59
• @J.M. Wait ... tried again and works. Strange, probably I made some error the first time. That never happens – Dr. belisarius Mar 4 '16 at 19:09
• As you say, el señor doctor... ;) – J. M.'s ennui Mar 4 '16 at 19:15