Conditionals and logic was Re: piecewise function with integrals



There are a variety of conditional concepts in popular use.

There is the "case" construct which might look like

case( [x<0, -x], [x>=0, x])
    which would be  a definition of abs(x)  and might be simplified to 
abs(x).

There is a lisp programming language if  which  might look like this:

if  test  then [ test is anything other than the canonical value 
#false}  else  [test is exactly #false]

There is a more generic if
if  test  then [ test is exactly the  canonical value #true } else  
[test is exactly #false] error [test results in an error signal] failure 
[test is inconclusive]

which is implemented in Maxima via prederror.

There are post-expression conditionals also, which I think we found 
essential in Tilu (table of integrals lookup),

like  the transformation (x^2-1)/(x+1)    simplifies to the result  " 
x+1  unless  x= -1"

This kind of expression  (actually expression + assumptions made during 
transformations)
is not something that is easy to do, but (as I've expressed previously) 
might solve difficult
problems that are present in computer algebra systems.



RD wrote...

On a bit of a tangent -- a proposal was floated a while ago to make 
"and", "or" and "not"
simplifying commutative operators, and create new ones "and_then", 
"or_else" as short-circuit operators
. Makes sense to me, and it probably wouldn't really be a lot of work. 
best, Robert Dodier _

I think that if one wishes to introduce simplifying boolean commutative 
operators, it is
easy to do (and I seem to recall has been done at least once). I think 
that changing
the existing and/or/not is an incompatible change that would break some 
programs.

There seem to me to be at least 2 versions that would be useful. The 
logical binary
bit-masking kind of thing given in common lisp as boole-*  e.g. boole-ior

and a stand-in for the logic symbols in expressions that have 
indeterminates in them.
e.g. lor (land(a,b)),land(c,d))

and then you can do things like distribute, re-order, use deMorgan's 
law, etc etc.
There is a huge literature on the simplification of boolean expressions in
circuit analysis.  This stuff can be represented in various canonical or 
non-canonical
ways in Maxima, and there are many algorithms available for messing with it.
A proposal that seriously addresses these types of computations using 
Maxima as
a front end might be interesting.
A proposal to just include a handful of functions to do very simple 
logical operations
like logical AND: land(A,A) --> A is less interesting.  In the context 
of Maxima, I think it would be
more plausible to say land(A,A)->   "A, assuming A has type logical 
value T or F and is
an expression that is evaluated with no side effects".  In the context 
of boolean
logic simplification, those assumptions are given.

RJF