1
$\begingroup$

I am working with JAVA API and send a relation to kernel, then receive the returned solved result. Although I explicitly mentioned in my relation to have Integer Elements, the returned expressions says the conditions. means it says if x is INT etc. I do not need it. Is there any way not to get that? a sample provided .

 Simplify[Solve[
  Exists[{xPP, yPP, zPP, wPP}, Element[ {x, y, z, w}, Integers], 
   wPP == w && xPP == 2 + x && yPP == 2 + x + y && zPP == z &&
    (
     (xPP < yPP && wP == wPP && xP == xPP && yP == yPP && 
        zP == xPP + yPP)
      ||
      (! xPP < yPP && zPP > 10 && wP == wPP && xP == xPP && 
        yP == yPP && zP == 2 + yPP
       )
     )
   ]]]

Part of the returned relation: as you see there is "if" part which makes my code wrong. I just need wp->p && y>=1

{{wP->w if (w|x|y|z)\[Element]\[DoubleStruckCapitalZ]&&y>=1 
$\endgroup$
1
  • $\begingroup$ Add Element[{x, y, z, w}, Integers] to the Simplify as well. This won't get rid of the condition altogether though, since the condition that e.g. y>=1 will remain. $\endgroup$
    – MarcoB
    Oct 5 at 16:26
2
$\begingroup$
Clear["Global`*"]

$Version

(* "12.3.1 for Mac OS X x86 (64-bit) (June 19, 2021)" *)

Add Element[{x, y, z, w}, Integers]as an assumption to the Simplify and replace ConditionalExpression with And

Off[Solve::svars]

Simplify[
  Solve[
   Exists[{xPP, yPP, zPP, wPP},
    Element[{x, y, z, w}, Integers], 
    wPP == w && xPP == 2 + x && yPP == 2 + x + y && 
     zPP == 
      z && ((xPP < yPP && wP == wPP && xP == xPP && yP == yPP && 
         zP == xPP + yPP) ||
       (! xPP < yPP && zPP > 10 && wP == wPP && 
         xP == xPP && yP == yPP && zP == 2 + yPP))]],
  Element[{x, y, z, w}, Integers]] /.
 ConditionalExpression :> And

(* {{wP -> w && y >= 1, xP -> 2 + x && y >= 1, yP -> 2 + x + y && y >= 1, 
  zP -> 4 + 2 x + y && y >= 1}, {wP -> w && y <= 0 && z >= 11, 
  xP -> 2 + x && y <= 0 && z >= 11, yP -> 2 + x + y && y <= 0 && z >= 11, 
  zP -> 4 + x + y && y <= 0 && z >= 11}} *)
$\endgroup$
1
$\begingroup$

Using pattern matching, the unwanted part of the output can be filtered.

Simplify[Solve[
   Exists[{xPP, yPP, zPP, wPP}, Element[{x, y, z, w}, Integers], 
    wPP == w && xPP == 2 + x && yPP == 2 + x + y && 
     zPP == z && ((xPP < yPP && wP == wPP && xP == xPP && yP == yPP &&
          zP == xPP + yPP) || (! xPP < yPP && zPP > 10 && wP == wPP &&
          xP == xPP && yP == yPP && zP == 2 + yPP))]]] /. 
 Rule[v1_, 
   ConditionalExpression[v2_, And[Element[x__, Integers], v3_]]] -> 
  Rule[v1, And[v2, v3]]

enter image description here

$\endgroup$

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.