All this discussion of divide by zero made me think of another similar
case: 'subtractIfCan' in NonNegativeInteger. If might be surprising
how often this is used in the Axiom code. In OpenAxiom Gaby has raised
this sort of construction

  Union("failed",X)

to the level of special support for the domain constructor

  Maybe(X)

in the Spad language. I think this is a good thing! :) In a sense this
allows the function

  f : A -> Maybe(B)

to be "partial" but it goes much deeper than that.

It occurs to me to ask the more "algebraic" question of: "What if we
did the same thing to subtraction in NonNegativeIntegers as was
proposed here for division?" I.e. Just make it equal to 0. How much
algebra would that break? Currently we have

(1) -> (1-2)$NNI

   The function - is not implemented in NonNegativeInteger .

but that is rather inconvenient sometimes and results in non-compact
coding styles such as

   (r:=substractIfCan(x,y)) case "failed" => z:=0; z:=r

or worse! Of course the point is that often you migth want to do
something else as a result of the boundary condition other than just
setting the result to zero.

In the interpreter we can write:

(1) -> subtractIfCan(2,1)$NNI + 1

   (1)  2
                                                        Type: PositiveInteger

But there is some magic going on here. If we try to do this in the
compiler things are more difficult. One might argue: just as they
should be! :)

One potentially really good thing about the Maybe domain constructor
in OpenAxiom is to try to have it both ways: for the most part we can
operate on the domain Maybe(X) in almost the same way as the original
domain X, i.e. have the special support for 'Maybe' try to make this
(mostly) invisible.

Anyway, what do you think of the proposal to implement '-' in
NonNegativeInteger such that

  (1-2)$NNI

would return 0?  Does this mean then that NonNegativeInteger could be
considered an AbelianGroup?

Bill Page.

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to