49

I am relatively new to the world of academical mathematics, but I have noticed that most, if not all, mathematical textbooks that I've had the chance to come across, seem completely oblivious to the existence of lambda notation.

More specifically, in a linear algebra course I'm taking, I found it a lot easier to understand "higher order functionals" from the second dual space, by putting them in lambda expressions. It makes a lot more sense to me to put them in the neat, clear notation of lambda expressions, rather than in multiple variable functions where not all the arguments are of the same "class" as some are linear functionals and others are vectors. For example, consider the canonical isomorphism - $$A:V \rightarrow V^{**}$$

It would usually be expressed by $$Av(f) = f(v)$$ This was a notation I found particularly difficult to understand at first as there are several processes taking place "under the hood", that can be put a lot more clearly, in my opinion, this way:

$$A = \lambda v \in V. \lambda f \in V^{*}. f(v)$$

I agree that this notation may become tedious and over-explanatory over time, but as a first introduction of the concept I find it a lot easier as it makes it very clear what goes where.

My question is, basically, why isn't this widespread, super popular notation in the world of computer science, not as popular in the field of mathematics? Or is it, and I'm just not aware?

Noa
  • 953
  • 8
  • 16
  • 1
    I assume you're referring to something like $\eta(v)=\lambda\phi.\phi(v)$ versus $\overline\eta(v,\phi)=\phi(v)$. If this is accurate, I'm not sure why you have an issue with all the arguments not being of the same "class". In *typed* lambda calculi, this would be $\eta:V\to((V\to\mathbb R)\to\mathbb R)$ versus $\overline\eta:V\otimes(V\to\mathbb R)\to\mathbb R$ which are bijectively related via currying. Having arguments of different types is an extremely common thing in typed lambda calculi. – Derek Elkins left SE Jul 12 '17 at 09:52
  • 14
    The functional notation came much earlier and is widespread. For those not used to it, lambda calculus is perfectly unreadable. –  Jul 12 '17 at 10:15
  • 2
    Similarly: category theorists love to write things like $\mathcal C/(–)$ that would often be clearer as $ X\mapsto\mathcal C/X$. – MJD Jul 12 '17 at 12:02
  • 4
    @MJD I don't see how the latter is any clearer. The former is unambiguous (if defined properly) and the latter would force me to give it a new name because it is way to long. Not to mention this is a functor, not merely a function on objects. – Stefan Perko Jul 12 '17 at 12:06
  • 5
    Please add an example of what sort of “before” and “after” notational change you're thinking of. I have a feeling that at least some of the people have misunderstood your question (and I'm pretty sure I don't understand it myself). – ShreevatsaR Jul 12 '17 at 15:59
  • 8
    I believe there's also a chicken-and-egg problem here. It is not widespead, hence it is unfamiliar to many mathematicians, so it is not used in papers, hence it does not spread, etc. Related: it is also not taught to (most) new students -- doing that would also make it more popular. Instead, we continue to write "$f(g)$ where $g(x)=\ldots$" instead of "$f(x \mapsto \ldots)$" or its $\lambda$ variant. (Personally, I'd also love if we at least stopped writing/teaching "the function $f(x)$" instead of "the function $f$", which is a bad habit and copes with $\lambda$ notation) – chi Jul 12 '17 at 20:56
  • 3
    I think mathematicians are fairly reactionary about notation, and often do not care too much about formal correctness as long as the proof / idea is adequately (and correctly) communicated. – PJTraill Jul 12 '17 at 21:13
  • It would really help if you were to edit your question to give an example, as requested by @ShreevatsaR: show us an example of notation you find unsatisfactory and how you would improve it! And please illustrate your point about classes of arguments too. – PJTraill Jul 12 '17 at 21:15
  • 1
    lambda calculus is a tool designed to study computability but is not a tool designed to express mathematical concepts. – Masacroso Jul 13 '17 at 00:18
  • 7
    @Masacroso This is inaccurate both historically and currently. Many theorem provers such as Coq are basically fancy typed lambda calculi, but maybe the [Feit-Thompson theorem](http://repository.cmu.edu/cgi/viewcontent.cgi?article=1605&context=philosophy) is a result of computability now. Historically, Alonzo Church was not setting out to study computability but [exactly *was* trying to build a tool to express mathematics](https://doi.org/10.2307/1968337), admittedly at a foundational level. – Derek Elkins left SE Jul 13 '17 at 17:29
  • @Derek Thank you for you enlightening comment, I dont knew the history of the lambda calculus. But today it seems something more useful for computability that to express efficiently mathematical notions. – Masacroso Jul 13 '17 at 20:06
  • @ShreevatsaR Sorry for the delay, I edited the original post and added a concrete example (: – Noa Jul 14 '17 at 13:39
  • @Noa Much better now. And to be clear, your question is not about $x\mapsto f(x)$ versus $\lambda x. f(x)$, correct? That is, compared to $Av(f) = f(v)$ you'd prefer _either_ $A = \lambda v \in V. \lambda f \in V^{*}. f(v)$ or (say) $A = (v \in V) \mapsto ( (f \in V^{*}) \mapsto f(v))$ is that right? Or is your question about the distinction between the latter two? – ShreevatsaR Jul 14 '17 at 13:48
  • 1
    @ ShreevatsaR Exactly, only that the ↦ notation is one I rarely encounter. – Noa Jul 14 '17 at 14:19
  • 2
    @StefanPerko $X \mapsto \mathcal{C}/X$ is more clear than $\mathcal{C}/(-)$ because it delimits the scope of the "hole"; the undelimited one could also mean $\mathcal{C}/(X \mapsto X)$, and the rules for disambiguating here often require a fairly deep knowledge of the field. Even when you are very knowledgable about the field it can take quite some effort to disambiguate such things in an unfamiliar development. – Daniel Wagner Jul 15 '17 at 03:52
  • 1
    @Noa If you haven't already, you may want to read [SICM](https://mitpress.mit.edu/sites/default/files/titles/content/sicm/book.html) for a critique of standard mathematical notation along these lines. (It's also a fascinating book otherwise.) – Derek Elkins left SE Jul 15 '17 at 23:11
  • @DerekElkins Thanks for the recommendation! Hope I get a chance to read it when I'm done with my exams (: – Noa Jul 17 '17 at 05:46

2 Answers2

41

As Derek already said, there is no essential difference between functions $A\times B \to C$ and functions $A\to (B \to C)$ via Currying (this is also more abstractly expressed by the universal property of an exponential which unifies the set-theoretical currying and currying in a typed lambda calculus).

On the notational side of things, I personally prefer $x\mapsto f(x)$ to $\lambda x. f(x)$ and I suspect many other mathematicians feel the same (especially since $\lambda$ is such a commonly used letter).


EDIT: (now that my answer stopped being one, let me add some rambling that the 29 people so far have not upvoted for):

I'm guessing many mathematicians are less "comfortable" with nested expressions like $v\mapsto (f \mapsto f(v))$. That would be nothing extraordinary, since there are various concepts that some mathematicians feel less comfortable about. Here are two (unrelated) things that I have encountered:

  • empty metric spaces: Some people deliberately require metric spaces to be non-empty which is a nuisance: given a metric space $(X,d)$ and $Y\subseteq X$, $(Y,d|_{Y^2})$ is a metric space again... unless of course $Y=\emptyset$; apparently it doesn't feel "right" for metric spaces to be empty
  • $f(x)$ instead of $f$: Some people refer to a function $f$ as $f(x)$; this is (unfortunately) what I learned in high school and is (rein)forced by notation like $\frac{d f(x)}{d x}$ and $\int f(x) \,dx$

Although, your example:

Let $A : V\to V^{**}$ such that $Av(f) = f(v)$ for all $v\in V$ and $f\in V^*$

is fine and not hard to understand, in my opinion. For every $v\in V$ we have $Av\in V^{**}$, i.e. $Av : V^* \to \mathbb K$. Hence we can plug in an $f\in V^*$ to get $f(v) \in \mathbb{K}$. If the author thinks it is easy to understand and is more used to it than $v\mapsto (f \mapsto f(v))$ then they would obviously have no reason to change the notation.

So the reason why $v\mapsto (f\mapsto f(v))$ (or a variant thereof) is not used as much is probably: "I'm not used to this notation and I'm perfectly happy with mine."

By the way, my personal favourite is also not: $$A : V \to V^{**}, v \mapsto (f\mapsto f(v))$$ but $$A : V\to V^{**}, v\mapsto \_(v)$$ where it is implied that $\_$ is a placeholder, i.e. $\_(v) : V^* \to \mathbb{K}, f\to f(v)$.

Stefan Perko
  • 11,817
  • 2
  • 23
  • 59
  • 19
    +1 for your last sentence; I'm feeling the same way. This notation was indeed bad marketing by the inventor of lambda calculus. – Christian Blatter Jul 12 '17 at 10:09
  • 7
    Note that $B^A \to C$ and $(A \to B) \to C$ mean the same thing, while $A \times B \to C$ and $A \to (B \to C)$ are equivalent through Currying. There's a hugh difference between $(A \to B) \to C$ and $A \to (B \to C)$. – md2perpe Jul 12 '17 at 10:27
  • 10
    The real issue with the $\mapsto$ notation is that it is rarely clearly specified. You could treat $x\mapsto f(x)$ as notation for $\lambda x.\! f(x)$ but that doesn't help if you are unfamiliar with the lambda calculus. I suspect many mathematicians would be uncomfortable with the equivalent of the more complicated nested expressions that are common in lambda calculus. At any rate, the $\mapsto$ notation is *also* arguably underused. – Derek Elkins left SE Jul 12 '17 at 10:47
  • @md2perpe Thanks for spotting that mistake! – Stefan Perko Jul 12 '17 at 12:01
  • @ChristianBlatter The notation was not a choice, it was accidental... https://cs.stackexchange.com/questions/55917/what-does-the-lambda-in-lambda-calculus-stand-for – Klangen Jul 12 '17 at 13:18
  • 4
    @Pickle I still choose to think it is a reference to Aristotle's Metaphysics. Church's explanation is a bit like John Lennon saying "oh, my toddler just drew a cool picture of a lambda so I put it on the fridge, really liked it and made it into a song" – Darren Ringer Jul 12 '17 at 14:00
  • 1
    Another +1 for $\mapsto$! A usage example from my area: the length function embedding of the space of hyperbolic structures on a surface, which I like to write in the curried form $\text{hyperbolic structure } \rho \mapsto (\text{loop } C \mapsto \text{length of } C \text{ in } \rho)$. – Vectornaut Jul 12 '17 at 19:49
  • 7
    To my mind $ x \mapsto f(x) $ pretty much **is** lambda calculus, just with different syntax from $ \lambda x. f(x) $ — unfortunately the asker has not (yet) favoured us with a concrete example where lambda syntax is clearer. Both notations may be considered incomplete, as they do not specify range and domain, though we do have $ g: X \to Y : x \mapsto f(x) $ . Both can also equally need either bracketing or a convention for precedence. I suppose the big difference is that a ↦-expression is not generally used as part of a larger expression, while a λ-expression very often is. – PJTraill Jul 12 '17 at 21:06
  • @DerekElkins, could you expand on the statement that $\mapsto$ is "rarely clearly specified"? Do you mean that $\mapsto$ has multiple commonly understood meanings, that $\mapsto$ is an informal notion that somehow doesn't capture the subtleties of $\lambda$, or something else? – Vectornaut Jul 12 '17 at 21:50
  • @PJTraill This is the notation I use in all my personal notes. That way it contains all the relevant data at once. – A. Thomas Yerger Jul 12 '17 at 22:33
  • @Vectornaut The most reasonable interpretation of $x\mapsto f(x)$ to a "normal" mathematician is as an abbreviation for $\{(x,f(x))\mid x\in X\}$ where $X$ is some implicitly understood domain. I don't think I've seen this stated often if at all. You rarely see things like $g(x\mapsto f(x))$ or $x\mapsto(y\mapsto h(x,y))$, let alone something like $(f\mapsto f(f))(f\mapsto f(f))$ which you definitely *don't* want. So while you *can* think of $\mapsto$ like $\lambda$, you don't want to without a type system, and I'm pretty sure I've never seen a type system articulated for $\mapsto$ either. – Derek Elkins left SE Jul 12 '17 at 23:51
  • @DerekElkins, I rarely see $\mapsto$ used without an explicit type signature. Here are typical usage examples from books I grabbed off my shelf. (a) Viana's *Lectures on Lyapunov Exponents* (2014), pp. 6, 7. (b) Bridson and Haefliger's *Metric Spaces of Non-Positive Curvature*, pp. 40, 49, 51. (c) Da Silva's *Symplectic Toric Manifolds* (2001), pp. 6, 8, 18, 19 (in the second use on p. 18, the signature is specified by the phrase "Let $G = \mathbb{C} \setminus \{0\}$ act on $M = \mathbb{C}^n$"). [*cont.*] – Vectornaut Jul 13 '17 at 15:18
  • @DerekElkins [*cont.*] The only uses I found without a signature were in Baez and Muniain's delightfully informal *Gauge theory, knots, and gravity*, pp. 9, 40, 96, 97. In the book by da Silva from above, I found one place (p. 14) where $\mapsto$ only specifies a function partially; I'm not sure if that's allowed in the $\lambda$ formalism. Note, however, that this usage does come with an explicit type signature! Da Silva declares the function as a "moment map", a type alias defined in Definition 1.4.3. – Vectornaut Jul 13 '17 at 15:21
  • @Vectornaut I agree that it is rare to see $\mapsto$ being used without it being rather clear what the domain is (modulo points of undefinedness), but that's a different thing than providing a type system. A type system would specify the types for *all* legal expressions involving $\mapsto$ which would require specifying what the legal expressions were in the first place which is part of what I'm claiming is usually not fully specified. Part of the distinction is that the lambda calculus is primarily a syntactic theory, so these things *must* be spelled out as there is nothing to fall back on. – Derek Elkins left SE Jul 13 '17 at 16:54
  • 1
    As the OP made clear just now, the question is not about $x\mapsto f(x)$ versus $\lambda x. f(x)$: it's about why neither of them is used. For example, it is about why $A:V \rightarrow V^{**}$ is written as $Av(f) = f(v)$ rather than say $A = (v \in V) \mapsto ( (f \in V^{*}) \mapsto f(v))$ (not necessarily $A = \lambda v \in V. \lambda f \in V^{*}. f(v)$). – ShreevatsaR Jul 14 '17 at 16:15
  • @DerekElkins you're a legend! – Noa Jul 19 '17 at 13:44
14

Lambda calculus is related with computer science through and through. To quote Wikipedia:

Lambda calculus (also written as λ-calculus) is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution.

Highlights mine. Here, "computation", "application" and "substitution" are very well defined operations on symbols as understood in CS. That is literally what lambda calculus is all about, to start out with: to reason about substituting symbols in formal languages.

Processes like Currying are there because they have relatively practical applications - for example, they make abstract reasoning easier (by reducing all lambdas with multiple arguments to ones with single arguments). "Meta" topics like lazy evalation, typing, strictness etc. can all be explored in the context of lambda calculus and have little impact on general mathematic formulae. For CS, it is important to be super exact with these things, as computers, basically, are machines for manipulating symbols.

So, lambdas have use for the theoretical computer linguist / computer scientist / logician; on the surface you could probably use the notation for general mathematics, but many of the advanced "benefits" do not transfer (or at least not in a helpful manner). In most parts of mathematics, especially applied mathematics (physics...), the question of how exactly to "apply" and "substitute" variables is crystal clear and of little interest to anybody - it is often quite usual to skip writing bound variables completely.

Oh, and the other answer: people are just used to the usual representation. Plenty of mathematical areas tend to have their own notations for quite similar things. It's just how it is.

AnoE
  • 770
  • 3
  • 10
  • Is the precision of lambda calculus really needed because computers manipulate symbols? After all, how often does anyone programme in lambda calculus? – PJTraill Jul 12 '17 at 21:19
  • 1
    Untyped lambda calculus is the basis for Lisp, and typed is the basis for Haskell and ML. – Chara Jul 13 '17 at 02:05
  • 3
    @Marty: Which just proves that *nobody* (to within experimental error, and excluding academics because commercial software engineering is much bigger) actually programs in lambda calculus – Kevin Jul 13 '17 at 03:12
  • @Kevin There's a small but significant minority of commercial projects written in Haskell and other ML derivatives; look at Jane Street Capital, all of whose infrastructure is built in OCaml. Facebook somewhat recently rewrote their spam detection software in Haskell. There's a handful of companies who use Clojure, a Lisp dialect. I wouldn't say that's nobody, even within "experimental error" (whatever that means for something that isn't an experiment). – chbaker0 Jul 13 '17 at 04:14
  • @chbaker0: I'm exaggerating, of course, but the vast majority of developers do not work in lambda calculus, nor in anything that closely resembles it. The *word* lambda does provide a convenient term for anonymous functions in many popular languages, but they're all way more imperative than the lambda calculus. The point is that, while the lambda calculus may need computers to justify its existence, computers don't particularly need the lambda calculus in the modern era. – Kevin Jul 13 '17 at 04:18
  • 2
    Lambda abstraction can be used outside of the context of studying and processing formal languages. (much like how sets can be used by people who aren't studying set theory) –  Jul 13 '17 at 06:31
  • @Kevin For what it's worth, many features from functional programming languages have been leaking into popular imperative/OO programming languages in recent years. Lambdas, currying, maps, filters, and higher-order functions are fairly commonplace in languages like Python and C#. – Mateen Ulhaq Jul 13 '17 at 10:01
  • 2
    All of you are right; keep in mind that this answer primarily answers the question of "why do we write `f(x)=x+1` instead of `\lambda x.x+1`", that is, a plausible reason why the whole of mathematics did not switch to lambda notation when it was invented. – AnoE Jul 13 '17 at 18:36