1
$\begingroup$

I have a boolean expression and need to distribute all it's part. I used LogicalExpand and it works fine somehow. but I see for some sub-parts it does not Simpify or solve it. I tried Simplify for whole relations but it does not help. please look this sample:

LogicalExpand[ x == xP &&  z == zP && ((w ==  wP && ((x + z == yP && z >= 0) || (x + 2 z == yP && w  
< x &&  z < 0 && w <= x + 2 z))) || (wP == 4 + x && x + 2 z == yP && (w >= x || x + 2 z < w) && (w < x || z < 0)))]

 ( wP == w && xP == x && x + z == yP && zP == z &&  z >= 0)
 || ( 4 + x == wP && xP == x && x + 2 z == yP && zP == z && w >= x && w < x) # issue
 || ( 4 + x == wP && xP == x && x + 2 z == yP && zP == z && w >= x && z < 0)
 || ( 4 + x == wP && xP == x && x + 2 z == yP && zP == z && w < x &&  x + 2 z < w)
 || (4 + x == wP && xP == x &&  x + 2 z == yP && zP == z && z < 0 && x + 2 z < w)
 || ( wP == w && xP == x && x + 2 z == yP && zP == z && w < x && z < 0 && w <= x + 2 z)

as you see in second line w >= x && w < x means Flase. But logicalExpand only expanded the relations without making final reduce or something. How can I remove the second which become false without furthur reduce for each sub-part? note that this relations happens automaticaly in my program and I must create proper command before sending it to Mathematica Kernel. The output format is completely OK and I must have it like this. using Simplify will change the style of output,it will change it to UnExpanded again, mixing the relations which is not my desire. thanks

$\endgroup$
4
  • $\begingroup$ Simplify the result. $\endgroup$
    – Bill Watts
    Commented Nov 3, 2021 at 20:54
  • $\begingroup$ @BillWatts yes I mentioned in th question . Actually it helps and it does not help. Simplify will again make it UnExpanded. which is not my desire. it will remove that issue but the format will change. $\endgroup$
    – Azzurro94
    Commented Nov 3, 2021 at 21:07
  • $\begingroup$ @BillWatts yes. but this is just one example. this program makes different reltions each time. so I want something that works all the time without manual works. i thought there might be some funtion that resolve it automatically. $\endgroup$
    – Azzurro94
    Commented Nov 3, 2021 at 21:32
  • $\begingroup$ Try Reduce on the result. $\endgroup$ Commented Nov 4, 2021 at 0:41

1 Answer 1

2
$\begingroup$

Since LogicalExpand will typically produce an expression of the form Or[cond1,cond2,…] (cond1||cond2||…), you can Map (/@) Simplify over this result. This simplifies down the individual branches (cond1,cond2,…), but will leave the top-level untouched:

Simplify /@ 
 LogicalExpand[
  x == xP && 
   z == zP && ((w == 
        wP && ((x + z == yP && z >= 0) || (x + 2 z == yP && w < x && 
           z < 0 && w <= x + 2 z))) || (wP == 4 + x && 
       x + 2 z == yP && (w >= x || x + 2 z < w) && (w < x || z < 0)))]
(* (w == wP && x == xP && x + z == yP && z == zP && 
   z >= 0) || (wP == 4 + x && x == xP && x + 2 z == yP && z == zP && 
   w >= x && z < 0) || (wP == 4 + x && x == xP && x + 2 z == yP && 
   z == zP && w < x && x + 2 z < w) || (wP == 4 + x && x == xP && 
   x + 2 z == yP && z == zP && z < 0 && x + 2 z < w) || (w == wP && 
   x == xP && x + 2 z == yP && z == zP && w < x && z < 0 && 
   w <= x + 2 z) *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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