[Haskell-cafe] Re: mathematical notation and functional programming
Henning Thielemann
lemming at henning-thielemann.de
Mon Jan 31 14:04:31 EST 2005
On Mon, 31 Jan 2005, Chung-chieh Shan wrote:
> (Is Lemming the same person as Henning Thielemann?)
Yes. :-)
> > For the expression '1+x' I
> > conclude by type inference that 'x' must be a variable for a scalar
> > value, since '1' is, too. But the expression '1/O(n^2)' has the scalar
> > value '1' on the left of '/' and a set of functions at the right side.
> > Type inference fails, so my next try is to make the operands compatible
> > in a somehow natural way.
>
> It seems to me that your classification of certain notations as "wrong"
> and others as "right" assumes a certain type inference system that
> allows adding a number to a placeholder but disallows dividing a
> function by a set of functions.
Let's see if we share a common interpretation of notation before
discussing who uses it consistently and who does not. :-)
For me 1, x and + are identifiers. The strings "1", "x" and "+" are not
mathematical objects. But '1' denotes a unique mathematical object. Only
almost, because depending on the underlying explanation it may be
identified with the natural number 1, with the rational number 1, with the
real 1, with the complex 1, you will probably need a different
representation. Further this representation depends on how you represent
natural numbers, reals and so on, e.g. by sets. '+' also denotes a
mathematical object, more precisely a function, and again we have
ambiguities like that for '1', since '+' might be the natural addition,
the rational one or even a mixed one. 'x' denotes no special mathematical
object but it may be replaced by one, and the special thing is, that
within a certain scope all occurences of 'x' must be replaced with the
same mathematical object. Functions are special, in the sense that if I
write "1+2" I don't want to consider this as the sequence of three objects
denoted by "1", "+", "2" but I want that the function denoted by "+" is
applied on the values denoted by "1" and "2".
So I imagine a layer of notation and a layer of mathematical objects. Do
you share this interpretation?
What are consequences of this interpretation? "2+2" and "4" denote the
same object. A function has only access to the value (the mathematical
object) but not to the generating expression. So how can I define e.g.
differentation with respect to a variable? I can't, but I don't miss it
because I can define it for functions, and yes Jerzy :-), also for other
objects. For me differentiation was introduced by limits. The definition
of limits don't need expressions as mathematical objects, the
differentation of functions don't need them, too. But later we got used
to differentiate expression (e.g. x^2 + y^2 is turned into 2*x * dx + 2*y
* dy), but no-one defined what that is.
What are the consequences of treating expressions as mathematical
objects, too? "2+2" and "4" are different expressions. I guess we would
still ask for a value, thus we need a mathematical function which maps
expressions to values. I think Mathematicas Evaluate is made for this
purpose. If mathematical functions can transform expressions - is it
possible that they change my writing? ;-)
Indeed, I really like this separation: On the one side expression, on the
other side mathematical objects. Simplifications of expressions are
nothing I allow a mathematical function. But if I simplify an expression I
must assert that the denoted mathematical object remains the same.
Differentation of a function is possible if you only know its graph, but a
computer algebra system can find an expression for the derivation if you
have an expression for the function. There are many functions that can be
integrated, but a computer algebra system cannot find an expression
without the Integrate function for it. When a pupil says "the function can
not be integrated" he means that he couldn't find an expression for the
integrated function without the integral sign. When a professor teaching
calculus says "the function can not be integrated" he means that there is
some divergence. It seems to me that in this case the pupil considers
expressions as mathematical objects and the professor does not.
> Lambda notation also involves much ambiguity and many implicit
> conversions.
Following the interpretation above I like to see lambda as a notation
instead of an mathematical operator. lambda expressions denote functions.
I can replace every occurence of lambda expressions textually. If "\A ->
B" occurs I can also write "f" and "where holds \forall A f(A)=B". So
lambda notation involves no more ambiguities than the rest of the
notation.
> > You use 'ask' twice in the second expression. Does this mean that there
> > may be two different values for 'ask'? If this is the case your second
> > interpretation differs from my second interpretation.
>
> No -- when I use "ask" I mean the one defined in Control.Monad.Reader.
Sorry for my imprecise question :-) What I meant was that 'ask' somehow
injects a value into the mathematical operation, I wondered if the values
it introduces are equal or not.
More information about the Haskell-Cafe
mailing list