Re: Simplifying inequalities
- To: mathgroup at smc.vnet.net
- Subject: [mg36807] Re: [mg36790] Simplifying inequalities
- From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
- Date: Thu, 26 Sep 2002 04:57:14 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
The reason why InequalitySolve returns it's answer in what sometimes
turns out to be unnecessarily complicated form is that the underlying
algorithm, Cylindrical Agebraic Decomposition (CAD) returns its answers
in this form. Unfortunately it seems to me unlikely that a
simplification of the kind you need can be can be accomplished in any
general way. To see why observe the following. First of all:
In[1]:=
FullSimplify[x > 0 || x == 0]
Out[1]=
x >= 0
This is fine. However:
In[2]:=
FullSimplify[x > 0 && x < 2 || x == 0 && x < 2]
Out[2]=
x == 0 || 0 < x < 2
Of course what you would like is simply 0 <= x < 2. One reason why you
can't get it is that while Mathematica can perform a "LogicalExpand",
as in:
In[3]:=
LogicalExpand[(x > 0 || x == 0) && x < 2]
Out[3]=
x == 0 && x < 2 || x > 0 && x < 2
There i no "LogicalFactor" or anything similar that would reverse what
LogicalExpand does. if there was then you could perform the sort of
simplifications you need for:
In[4]:=
FullSimplify[(x > 0 || x == 0) && x < 2]
Out[4]=
0 <= x < 2
However, it does not seem to me very likely that such "logical
factoring" can be performed by a general enough algorithm (though I am
no expert in this field). In any case, certainly Mathematica can't do
this.
I also noticed that Mathematica seems unable to show that the answer it
returns to your problem is actually equivalent to your simpler one. In
fact this looks like a possible bug in Mathematica. Let's first try the
function ImpliesQ from the Experimental context:
<< Experimental`
Now Mathematica correctly gives:
In[6]:=
ImpliesQ[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,
y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5
<= 1 + y4 + y6]
Out[6]=
True
However:
In[7]:=
ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&
y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4
+ y6]
Out[7]=
False
That simply means that ImpliesQ cannot show the implication, not that
it does not hold. ImpliesQ relies on CAD, as does FullSimplify.
Switching to FullSimplify we see that:
In[8]:=
FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&
y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4
+ y6]
Out[8]=
True
while
In[9]:=
FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,
y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5
<= 1 + y4 + y6]
Out[9]=
y4 >= -1 && y6 <= y5 <= 1 + y4 + y6
On the other hand, taking just the individual summands of Or as
hypotheses;
In[10]:=
FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,
y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]
Out[10]=
True
In[11]:=
FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,
y4 == -1 && y6 >= -1 && y5 == y6 ]
Out[11]=
True
In fact FullSimplify is unable to use Or in assumptions, which can be
demonstrated on an abstract example:
In[12]:=
FullSimplify[C,(A||B)&&(C)]
Out[12]=
True
In[13]:=
FullSimplify[C,LogicalExpand[(A||B)&&(C)]]
Out[13]=
C
This could be fixed by modifying FullSimplify:
In[14]:=
Unprotect[FullSimplify];
In[14]:=
FullSimplify[expr_,Or[x_,y__]]:=Or[FullSimplify[expr,x],FullSimplify[exp
r,y]];
In[15]:=
Protect[FullSimplify];
Now at least we get as before:
In[16]:=
FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&
y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4
+ y6]
Out[16]=
True
but also:
In[17]:=
FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,
y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5
<= 1 + y4 + y6]
Out[17]=
True
This seems to me a possible worthwhile improvement in FullSimplify,
though of course not really helpful for your problem.
Andrzej Kozlowski
Toyama International University
JAPAN
On Wednesday, September 25, 2002, at 02:51 PM, Vincent Bouchard wrote:
> I have a set of inequalities that I solve with InequalitySolve. But
> then
> it gives a complete set of solutions, but not in the way I would like
> it
> to be! :-) For example, the simple following calculation will give:
>
> In[1]:= ineq = {y4 >= -1, y5 >= -1, y6 + y4 >= y5 - 1, y5 >= y6, y6 >=
> -1};
> InequalitySolve[ineq,{y4,y6,y5}]
>
> Out[1]:= y4 == -1 && y6 >= -1 && y5 == y6 ||
> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6
>
> the result is good, but I would like it to be in the simpler but
> equivalent form
>
> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6
>
> How can I tell InequalitySolve to do that? It is simple for this
> example,
> but for a large set of simple inequalities InequalitySolve gives lines
> and
> lines of results instead of a simple result.
>
> Thanks,
>
> Vincent Bouchard
> DPHil student in theoretical physics in University of Oxford
>
>
>
>