I once collected some amusing examples from Pari, Sage and Magma related to 
their different concepts of coercion. It can lead to all sorts of 
mathematical stupidity.

I concluded that trying to model maths this way is like trying to put a 
carpet down in a room with a wonky floor. You can locally get it quite 
flat, but once you get near a region that no one has flattened it's as 
crumpled as a Chinese Shar-pei.

After a little more research I discovered that maths papers weren't any 
better.

Bill.

On Thursday, 1 October 2015 21:35:37 UTC+2, Bill Page wrote:
>
> In FriCAS 
>
> (1) -> x:Polynomial(Integer) 
>                                                                    Type: 
> Void 
> (2) -> x + 1/2 
>
>             1 
>    (2)  x + - 
>             2 
>                                           Type: 
> Polynomial(Fraction(Integer)) 
>
> On 1 October 2015 at 15:28, 'Bill Hart' via sage-devel 
> <sage-...@googlegroups.com <javascript:>> wrote: 
> > 
> > 
> > On 1 October 2015 at 20:23, William Stein <wst...@gmail.com 
> <javascript:>> wrote: 
> > <SNIP> 
> > 
> >> By the way, look at how coercion "works" in Magma: 
> >> 
> >> $ magma 
> >> Magma V2.18-5     Thu Oct  1 2015 16:59:12 on compute3-us [Seed = 
> >> 629019987] 
> >> Type ? for help.  Type <Ctrl>-D to quit. 
> >> > R<x> := PolynomialRing(IntegerRing()); 
> >> > x + 1/2; 
> >> 
> >> >> x + 1/2; 
> >>      ^ 
> >> Runtime error in '+': Bad argument types 
> >> Argument types given: RngUPolElt[RngInt], FldRatElt 
> > 
> > 
> > We are call this "complex coercion" in our Nemo discussions 
> > 
> > [...as opposed to simple coercion: 
> > 
> >  R, x = PolynomialRing(QQ, "x") 
> >  K, a = NumberField(x^3 + 3x + 1,"a") 
> > 
> >  a + 1/2 # simple coercion since the result lives in K 
> > ] 
> > 
> > It's definitely quite easy to add complex coercion in Nemo/Julia (via 
> Julia 
> > generic catchall functions), but I'm resisting it quite obstinately for 
> the 
> > time being. 
> > 
> > One reason is that it easily leads to functions that are not 
> > type-consistent. You can quite easily write functions whose output type 
> > depends on the values, rather than the types of the inputs. This 
> completely 
> > screws with type inference and Jit compilation, though Julia does allow 
> it. 
> > 
> > Since Nemo focuses on highly performant generics for the time being, I'm 
> > trying to avoid introducing complex coercions, at least until we have a 
> very 
> > fast core. (Though naturally, mathematicians are keen to introduce this 
> > feature as soon as possible, since it is basically germane to any real 
> > mathematics.) 
> > 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to