That was it.
Here is my solution.
not_op(__e):= psubst(['notequal='equal, 'equal='notequal, ">"="<=", ">="="<", "<"=">=", "<="=">"],__e);
simpiif(__cnd, __a, __b):=
block(
[prederror:false],
if not member(safe_op(__cnd), [">", "<", ">=", "<=", 'equal, 'notequal]) then
error("Only inequalility relational operators are allowed and equal() and notequal().")
elseif is(__cnd)=true then
__a
elseif is(__cnd)=false then
__b
else
/* simp_assuming does not work right here for some reason, assuming works okay. */
simpfuncall('iif, __cnd, simp_assuming(__a, __cnd), simp_assuming(__b, not_op(__cnd)))
)$
iif(x>2,iif(x>4,a,b),iif(x<-2,c,d)); /* should not simplify */
iif(x > 2, iif(x > 4, a, b), iif(x < - 2, c, d))
iif(x>-2,iif(x>4,a,b),iif(x<=-2,c,d)); /* should simplify */
iif(x > - 2, iif(x > 4, a, b), c)
iif(notequal(x,0),iif(x>0,a,b),iif(x>2,c,d)); /* should simplify */
iif(notequal(x, 0), iif(x > 0, a, b), d)
Which is the behavior I wanted.
Thank you,
Rich
--------------------------------------------------
From: "Barton Willis" <willisb at unk.edu>
Sent: Tuesday, September 21, 2010 7:47 PM
To: "Richard Hennessy" <rich.hennessy at verizon.net>
Cc: "Maxima List" <maxima at math.utexas.edu>
Subject: Re: [Maxima] Possible bug in simp_assuming()
> Try trace("not")--I think you'll discover the problem is with "not," and not with
> simp_assuming. Try replacing
>
> simp_assuming(__b, not __cnd))
>
> with
>
> simp_assuming(__b, mynot(__cnd)))
>
> where mynot is something like (would need to be extended)
>
> mynot(e) := psubst(["<" = ">=", ">=" = "<"],e);
>
> Right now, I can't decide if this is a bug with "not", an evaluation policy (likely), or ...
>
> --Barton
>
> -----maxima-bounces at math.utexas.edu wrote: -----
>
>
>>Here is a better example. Much simpler to reproduce. Try
>
>>(%i4) simpiif(__cnd, __a, __b):=
>>block(
>> [prederror:false],
>> if not member(safe_op(__cnd), [">", "<", ">=", "<=", 'equal,
>>'notequal, "not"]) then
>> error("Only relational operators are allowed including
>>equal(), notequal() and not.")
>> elseif is(__cnd)=true then
>> __a
>> elseif is(__cnd)=false then
>> __b
>> else
>> /* simp_assuming does not work right here for some
>>reason, it leaves facts on the facts list
>>without removing them all. Don't know why. */
>> simpfuncall('iif, __cnd, simp_assuming(__a, __cnd),
>>simp_assuming(__b, not __cnd))
>>)$
>>