Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.1K Views
|
15 Replies
|
15 Total Likes
View groups...
Share
Share this post:

Simplifying multiple inequalities

Posted 11 months ago

Can you please tell me which function in Wolfram can convert the formula

(y == 0 && x == 0) || (y == 1 && x == 1) || (0 < y < 1 && x == y)

to the formula:

0 <= y <= 1 && x == y

I can't even prove their equivalence:

FullSimplify[((y == 0 && x == 0) || (y == 1 && x == 1) || (0 < y < 1 && x == y)) \[Equivalent] (0 <= y <= 1 && x == y), (x | y) \[Element] Reals]

Wolfram works in one direction only:

FullSimplify[(0 <= y <= 1 && x == y) \[Implies] ((y == 0 && x == 0) || (y == 1 && x == 1) || (0 < y < 1 && x == y)), (x | y) \[Element] Reals]

Out: True
POSTED BY: Sasha Mandra
15 Replies
Posted 11 months ago
POSTED BY: Updating Name
Posted 11 months ago

Dear Michael! It seems to me that the problem is not related to Pi properties. For some reason Wolfram breaks the calculation. It is the expression that Wolfram is evaluating.

Reduce[(\[Pi]/2 < x < \[Pi] && y == \[Pi] - x) || (x == \[Pi] && y == 0), {x, y}, Reals]
Out: \[Pi]/2 < x <= \[Pi] && y == \[Pi] - x

This one, which is a bit more complicated, does not:

Reduce[(0 < x < \[Pi]/2 && y == x) || (x == \[Pi]/2 && y == \[Pi]/2) || (\[Pi]/2 < x < \[Pi] && y == \[Pi] - x) || (x == \[Pi] && y == 0), {x, y}, Reals]

What do you think about that?

POSTED BY: Sasha Mandra
POSTED BY: Gianluca Gorni
Posted 11 months ago

Thank you! What would I do without you?

The easiest way to get around this obstacle seems to be this:

Reduce[0 < pi && (x == -\[Pi] && y == \[Pi]) || (-\[Pi] < x <= 0 && 
  y == -x) || (0 < x < \[Pi] && y == x) /. Pi -> pi, {x, y}, Reals] /. pi -> Pi
POSTED BY: Sasha Mandra

Re-reducing the solution from the Pi example pairwise seems to work:

Simplify[
 Reduce[
  ((x == -\[Pi] && y == \[Pi]) || (-\[Pi] < x <= 0 && y == -x) ||
    (0 < x < \[Pi] && y == x)),
  {a, x, y}, Reals],
 TransformationFunctions -> {
   # /. Verbatim[Or][a___, A_, b___, B_, c___] :>
      Or[a, Reduce[A || B, {}, Reals], b, c] &
   }]

I'm not sure simplification is any more reliable than Reduce appears (reliable in the sense of producing the desired form).

POSTED BY: Michael Rogers

I suppose it's because Head[Pi] is Symbol, and Pi is numeric but not a number. For instance, it seems Pi is replaced by an internal variable, the system reduced, and then the internal variable is replaced by Pi. The cylindrical decomposition seems to apply something like the trichotomy law and consider the three cases x < ..., x == ..., and x > ... separately. Actual numbers are handled more simply, or Reduce looks to see if cases can be combined for numbers and not for symbols. I'm just guessing here. I don't think these details are published.

Pursuing this line may be futile.

Here's a somewhat bizarre workaround, replacing Pi by a nonnumeric symbol:

Reduce[a == Pi &&
   ((x == -\[Pi] && y == \[Pi]) || (-\[Pi] < x <= 0 && y == -x) ||
      (0 < x < \[Pi] && y == x) /. Pi -> a),
  {a, x, y}, Reals] /. a -> Pi
(*  (-\[Pi] <= x <= 0 && y == -x) || (0 < x < \[Pi] && y == x)  *)

On the other hand, it handles equivalence without tricks:

Reduce[
 Equivalent[
  (x == -\[Pi] && y == \[Pi]) || (-\[Pi] < x <= 0 && y == -x) ||
   (0 < x < \[Pi] && y == x),
  (-\[Pi] <= x <= 0 && y == -x) || (0 < x < \[Pi] && y == x)]
 , {x, y}, Reals]
(*  True  *)
POSTED BY: Michael Rogers
Posted 11 months ago
POSTED BY: Sasha Mandra

Hi Sasha,

I didn't understand the first part of your reply.

For the second part, the following nearly does what you wrote as the desired result:

Reduce[
 (x == -1 && y == 1) || (-1 < x < 0 && y == -x) ||
  (x == 0 && y == 0) || (0 < x < 1 && y == x),
 {x, y}, (* or equivalently  y  instead of  {x, y}  *)
 Reals]
(*  (-1 <= x <= 0 && y == -x) || (0 < x < 1 && y == x)   *)

The conditions in front of the equations are disjoint; that is, the intervals -1 <= x <= 0 and 0 < x < 1 do not overlap. This is because of the way Reduce[] handles the cylindrical decomposition. I doubt there's anyway to get Reduce[] to close the interval. Of course x <= 1 is ruled out by the x < 1 in the input. (I assume one of them is a typo, or something was omitted from the input.)

POSTED BY: Michael Rogers
POSTED BY: Michael Rogers
Posted 11 months ago

Thank you. What about this?

(x == -1 && y == 1) || (-1 < x < 0 && y == -x) || (x == 0 && y == 0)

I also don't understand. If “x” is the ordinate and “y” is the obcissa, then many x's can correspond to one y. As far as I understand, your formula excludes this. In my formula, x determines y, not the other way around.

If we take

Reduce[(x == -1 && y == 1) || (-1 < x < 0 && y == -x) || (x == 0 && y == 0) || (0 < x < 1 && y == x), Reals]

we'll get the right result. But that's not what I'd like to get, namely:

(-1 <= x <= 0 && y == -x) || (0 <= x <= 1 && y == x)

In other words, that which is closer to piecewise functions

POSTED BY: Sasha Mandra
POSTED BY: Gianluca Gorni

Perhaps this?:

Reduce[(y == 0 && x == 0) || (y == 1 && x == 1) || (0 < y < 1 && x == y), {y, x}, Reals]
(*  0 <= y <= 1 && x == y  *)
POSTED BY: Michael Rogers
Posted 11 months ago

That's great! I didn't know the CylindricalDecomposition function existed. Thanks!

POSTED BY: Sasha Mandra

Here is a way:

formula0 = (y == 0 && x == 0) || (y == 1 && x == 1) || (0 < y < 1 && 
    x == y)
CylindricalDecomposition[formula0, {x, y}]

As for proving the equivalence, here are my attempts:

formula0 = (y == 0 && x == 0) || (y == 1 && x == 1) || (0 < y < 1 && 
    x == y)
formula1 = 0 <= y <= 1 && x == y
Reduce[Equivalent[formula0, formula1], {x, y}]
Reduce[Not[Equivalent[formula0, formula1]]]
CylindricalDecomposition[
 Equivalent[formula0, formula1], {x, y}]
POSTED BY: Gianluca Gorni
Posted 11 months ago
POSTED BY: Sasha Mandra
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard