On 7/22/07, Robert Dodier <robert.dodier at gmail.com> wrote:
> On 7/21/07, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
>
> > On 7/21/07, Robert Dodier <robert.dodier at gmail.com> wrote:
> > > Something like
> > > if x > 0 then %pi/4 elseif x < 0 then 5*%pi/4 else 'atan2(x, x)
> > > could be useful here.
> >
> > I am not sure what you are suggesting here. Are you suggesting that
> > atan2(q,q) simplify to the expression "if q>0 then etc.etc."?
>
> Yes. The point of this is that to make further progress doesn't
> require knowing anything about atan2, only the simpler expressions
> in the predicate and each branch of the conditional.
I have three problems with this (leaving aside the issue of the form
of conditional expressions).
One is simply that we don't yet have the machinery to manipulate
conditional-expressions in useful ways. We don't even have
simple-seeming simplifications like "if x>1 then (if x>0 then a else
b) else c" => "if x>1 then a else c" and "(if x>0 then a else b)*(if
x>0 then b else a)" => a*b. Until we have that machinery, expanding to
conditional expressions actually makes the expressions *less* useful.
Secondly, expanding functions into conditional expressions will lead
to blow-up in the size of expressions, making them harder to read.
Would you really rather see "if x>0 then 1 elseif equal(x,0) then 0
else signum(x^2)" rather than just signum(x^2)? What does that
accomplish? Expanding *is* useful sometimes, but not always, so I
would prefer that expanding into conditional form be an explicit
transformation, similar to "expand". But even then, it's not
particularly useful until we get the necessary simplifications into
the system.
Finally, if we *did* have the appropriate simplification machinery,
then if we resimplified the expanded form of atan2(x,x), we would get:
if x > 0 then %pi/4
elseif x < 0 then 5*%pi/4
else (if x > 0 then %pi/4
elseif x < 0 then 5*%pi/4
else 'atan2(x, x))
which I suppose would simplify to
if x > 0 then %pi/4
elseif x < 0 then 5*%pi/4
elseif x > 0 then %pi/4
elseif x < 0 then 5*%pi/4
else 'atan2(x, x)
and then back to
if x > 0 then %pi/4
elseif x < 0 then 5*%pi/4
else 'atan2(x, x))
given an appropriate simp-if. Is this really how we want the system to operate?
Those recursive atan2's are both confusing and inefficient.
-s