"Nicolas M. Thiery" <nicolas.thi...@u-psud.fr> writes:

> On Sat, Mar 14, 2009 at 03:51:36PM +0100, Martin Rubey wrote:
> > 
> > "Nicolas M. Thiery" <nicolas.thi...@u-psud.fr> writes:
> > 
> > > Well, maybe we could join forces, and write a paper "coercion and
> > > dispatch in Sage and MuPAD". Having more than one implementation of
> > > the concept would even make it a standard :-)
> > 
> > Maybe it's even possible to include the FriCAS coercion system, too?
> 
> I don't know precisely how the FriCAS coercion system works. But if it
> indeed is close enough, it would make sense. And this certainly would
> be a good occasion to compare them in detail and cross-polinize the
> best ideas.
> 
> Do you foresee any occasion to meet physically all three of us?

Well, at least two of us are at FPSAC 09 at RISC.

(I love all these abbreviations, it feels so french :-)

I should admit that I did not read the whole thread... Maybe it would
be useful to start with a wiki page (possibly on MathAction, since we
can use FriCAS and Sage, and possibly even MuPAD there -- although I
guess you can do that on the Sage Wiki, too, but I don't know -- and
because it's intended use originally was to allow for cooperation
between different CAS...)

FriCAS coercion in two words:

(1) There are FriCAS-Categories (i.e., roughly classes -- "%" is FriCAS
    speak for "self")

        CoercibleTo(S) with coerce: % -> S,
        ConvertibleTo(S) with convert: % -> S and 
        RetractableTo(S) with coerce: S -> % and retract: % -> S

    the idea was that one can then ask 

        A has CoercibleTo B

    and get true if this is possible and false otherwise.

    Unfortunately, this was never implemented thoroughly.  There is a
    (stupid) reason, which takes too long to explain here

(2) in truth, most domains inherit various operations 

        coerce: % -> S and coerce: S -> %

    from the categories (classes in OO speak) they inhering from.

    the only thing special about the name coerce is that it has
    syntactic sugar.  s::S is short for coerce(s)@S (the "@" sign
    followed by a domain "S" means: use the operation coerce that
    gives me an element in S)
  
    For example:

Algebra(R:CommutativeRing): Category ==
  Join(Ring, Module R) with
    --operations
      coerce: R -> %
          ++ coerce(r) maps the ring element r to a member of the algebra.
 add
  coerce(x:R):% == x * 1$%


    I.e., every Algebra over R exports an operation coerce: R -> %.

    One can then do 
    
    (1) -> SQMATRIX(2, INT) has Algebra INT
    
       (1)  true
                                                    Type: Boolean
    (2) -> SQMATRIX(2, INT) has coerce: Integer -> %
    
       (2)  true
                                                    Type: Boolean

(3) The interpreter makes a heuristic choice which signatures to
    prefer over others.  This algorithm works usually very very well,
    although it could be still improved.

Sorry for being so short,

Martin


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to