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

> > > 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 :-)
> 
> :-)
> 
> > (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.
> 
> Just a short question: does the interpreter handle transitivity:
> i.e. if there is a coercion A -> B and one B -> C, then deduce one for
> A -> C?

I just realized that you probably "really" are asking about how to
deal with domains that have many representations, bases, etc., like
symmetric functions.  I.e., in the very simplest case you have

symmetric functions in elementary symmetric functions
                   ... complete ...
                   ... homogeneous ...
                   ... forgotten ...

etc, and you want to specify some coercions, but not all
binomial(n,2).

I have not come up with a completely satisfying answer yet.  One
possibility is to have a coercion package that performs the
coercion.  A complete (but silly) example is attached.

The problem with this approach is that

    MyDom1 has coerce: % -> MyDom2

gives false, because the coerce is not exported by MyDom1, but rather
by MyCoerce...

The good thing about this approach is that you can play all tricks
you like in MyCoerce.  For example, you could easily implement
Dijkstra to find a shortest coercion path.  Of course, you could also
cache this.

Is this what you had in mind?

Martin

)abb category MYCAT MyCat
MyCat(): Category == SetCategory with 
        0: constant ->  %
        1: constant ->  %
        "+": (%,%) -> %
        "*": (NonNegativeInteger,%) -> %
        coerce: % -> NonNegativeInteger
    add
        a * b ==
            if zero? a then 0$%
            else subtractIfCan(a, 1)::NonNegativeInteger * b + b

)abb domain MYDOM1 MyDom1
MyDom1(): MyCat
    == add
        Rep := NonNegativeInteger
        0 == 0$NonNegativeInteger
        1 == 1$NonNegativeInteger
        coerce(a: %): NonNegativeInteger == a::Rep 
        coerce(a: %): OutputForm == coerce(a::Rep)$NonNegativeInteger
        a + b ==
            (a::Rep + b::Rep)$NonNegativeInteger


)abb domain MYDOM2 MyDom2
MyDom2(): MyCat
    == add
        Rep := String
        0 == ""
        1 == "a"
        coerce(a: %): NonNegativeInteger == #(a::Rep)
        coerce(a: %): OutputForm == coerce(a::Rep)$String
        a + b == concat(a::Rep, b::Rep)

)abb package MYCOERCE MyCoerce
MyCoerce(A: MyCat, B: MyCat): with
        coerce: A -> B
    == add
        coerce a == a::NonNegativeInteger * 1$B





--~--~---------~--~----~------------~-------~--~----~
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