6
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ I tried TautologyQ[Equivalent[p1, p2], {a, b, c, d, e, f, g, h}] but it's not working and don't know why. $\endgroup$ – b.gates.you.know.what May 22 '13 at 7:47
  • $\begingroup$ After 1945 seconds (half hour), this gave me True : Resolve[ ForAll[{a, b, c, d, e, f, g, h}, BooleanMinimize /@ (p1 \[Equivalent] p2)], Reals] $\endgroup$ – Rojo May 22 '13 at 20:49
  • $\begingroup$ 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. $\endgroup$ – djp Mar 2 '15 at 5:06
2
$\begingroup$
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 *)
| improve this answer | |
$\endgroup$
  • $\begingroup$ ...or Resolve[ForAll[{a, b, c, d, e, f, g, h}, Equivalent[gcd1, gcd2]], Reals]. $\endgroup$ – J. M.'s discontentment Mar 4 '16 at 18:58
  • $\begingroup$ @J.M. Yep. But doesn't work here (V9) $\endgroup$ – Dr. belisarius Mar 4 '16 at 18:59
  • 1
    $\begingroup$ @J.M. Wait ... tried again and works. Strange, probably I made some error the first time. That never happens $\endgroup$ – Dr. belisarius Mar 4 '16 at 19:09
  • $\begingroup$ As you say, el señor doctor... ;) $\endgroup$ – J. M.'s discontentment Mar 4 '16 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.