Re: Re: Types in Mathematica thread

*To*: mathgroup at smc.vnet.net*Subject*: [mg62916] Re: [mg62848] Re: Types in Mathematica thread*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Thu, 8 Dec 2005 00:06:16 -0500 (EST)*References*: <dmp9na$hi2$1@smc.vnet.net> <roadnYOk3NcFDw7eRVn-jg@speakeasy.net> <200512050837.DAA08425@smc.vnet.net> <200512051840.NAA21063@smc.vnet.net> <200512060503.AAA02736@smc.vnet.net> <dn3jsl$8s0$1@smc.vnet.net> <200512070410.XAA23685@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

On 7 Dec 2005, at 13:10, Jon Harrop wrote: > Andrzej Kozlowski wrote: >> Yes, but obviously if the discussion is about types in the sense that >> computer scientists (not me!) use the term, then the type of objects >> with Head Real in Mathematica is exactly what is known as inexact >> numbers, or floating point number or floats etc. > > or intervals. As I've said, using Head is not a generally useful > definition > of "type" in the context of Mathematica code: > > In[1]:= Head[Sqrt[2]] > Out[2]= Power Of course I agree with you and I never expressed any support for the idea that Heads of Mathematica expressions are "types", although they sometime serve a similar purpose. But this example isn't terribly convincing since Sqrt[2] is simply converted to 2^(1/2) and is no different form, say Head[1+2^(1/3)] Plus or Head[Sin[23]] Sin etc, etc. None of these expressions will return True if you apply AtomQ to them. Obviously Heads of non-atomic expressions are not "types". Whether Heads of atomic expressions can be regarded as types is more to the point (but I think on the whole it is not a very useful way of thinking). > >> Mathematica does not know it but correctly computes its numerical >> approximation: >> >> NSum[10^(-k!), {k, 1, Infinity}] >> >> 0.110001 >> >> But in any case, all this has nothing to do with "types" in the sense >> of computer science. > > The word "type" means different things to different people even within > computer science. Some type systems provide numerics in the type > system, > even if it is accidental (e.g. church numerals encoded in C++ > templates). One reason why I think of this whole discussion as being kind of beside the point, is that it completely ignores what in my opinion is the most fundamental aspect of Mathematica: that it is a computer algebra system. Therefore the most important thing about its programming language has to be suitability for being used together with the vast amount of algebra functionality built into Mathematica. I think the current structure, including the concepts such as expression, its Head etc, are extremely well suited to this purpose (and so are the pattern matching and arrays used by Mathematica -that you mentioned in another posting. Again, they have to be considered primarily in relation to suitability for a CAS, not for other purposes). I expect that they came about by thinking in terms of the CAS aspect of Mathematica and not in terms the kind of things that are important in languages like C++, which serve a quite different purpose. In particular, if you are developing a programming language for a CAS system you had better have a good understanding of the complexity of various algorithms used frequently in manipulating mathematical expressions. This is why the idea of having a "type" corresponding to the mathematical concept of a real number seems quite inane to me. Of course, I am assuming that "types" are supposed to be something that is checked rather frequently. The difficulty of deciding whether a numerical expression represents a real number (as opposed to checking its Head) even when it can be done, would grind you programs to a halt before they got to anything really substantial. This is in an entirely different game from checking heads of expressions or types in programs like C. On the other hand, if one is talking about something meant for a special purpose, to be used only when you actually want to decide if something is a real number, then Mathematica's concept of domains already provides this functionality. It even incorporates "inheritance": In[12]:= Assuming[Element[x,Reals],FullSimplify[Element[x,Complexes]]] Out[12]= True In[14]:= Assuming[Element[x,Rationals],FullSimplify[Element[x,Reals]]] Out[14]= True I do not know whether anybody in computer science would say this has anything to do with "types", but it certainly has nothing to do with the function of Heads like Real, Rational or Complex in Mathematica. Andrzej Kozlowski

**References**:**Re: Types in Mathematica thread***From:*Kristen W Carlson <carlsonkw@gmail.com>

**Re: Re: Types in Mathematica thread***From:*Andrzej Kozlowski <akoz@mimuw.edu.pl>

**Re: Re: Re: Types in Mathematica thread***From:*Kristen W Carlson <carlsonkw@Gmail.com>

**Re: Types in Mathematica thread***From:*Jon Harrop <usenet@jdh30.plus.com>