## 2014-06-28

### J meets Haskell, for maths

This is the introductory post on a few of my ideas for mathematical notation. Some are more useful or realistic than others (with no particular correlation between the two). It's based on Jakub Marian's notation without variables, so big thanks to Jakub.

Here are some ways in which my notation differs from Jakub's:
• Juxtaposition means function application. So it's $f\,x$ as much as it's $\sin x$. This is the only feasible notation for application of curried functions, other than having some explicit left-associative infix operator. And because I plan on using functions a lot (as JM does), brevity of application is important. Function application is the closest-binding operation.
• Juxtaposition doesn't mean multiplication. So it's $2\cdot x$ as much as it's $2\cdot 3$. There's nothing special and fundamental about multiplication, so it doesn't have particularly special notation.
• Implicit mapping is better-defined. When applying a function to some functor that it doesn't handle, the function is $\text{fmap}$ed until it can match its argument. Otherwise, it's not $\text{fmap}$ed at all. There's a bit more to it, and it probably deserves its own post.
• Implicit mapping is controlled via subscripted numbers before the function. The numbers work in the same way as array ranks in J (the " conjunction), but also work for mapping over other functors, like functions. It's rare to actually use these, but they're there for anyone who needs them.
• Exponentiation is generalised, and the exponent is written before the base. $_\cdot^2x$ (notice the dot) denotes the square of $x$, and $_\circ^\infty\cos 0$ denotes the fixpoint of $\cos$, starting from $0$ ($\circ$ is the explicit function composition operator). The subscript-superscript pair is considered a function, so the usual precedence and mapping rules for function application apply. I haven't decided how this handles non-associative operators.
• Subtraction and division have their operands switched. I wrote a Quora answer about this, so I won't explain it here, yet. This also requires that both are right-associative (though fixity of division is not used much).
• This also applies to the $\bmod$ function, now also written in prefix (like any other function with a name made of letters). $\bmod 2\ 5=1$. An alternative is to use $\mathbin\%$ (ugly) or repurpose $\mathbin|$ (like J). Both of those are written with \mathbin in $\LaTeX$, which adds spacing.
• Limits of integration are also swapped.
• Elision of arguments implies partial application, not use of a default argument. So it's $2-0$, like it's $\frac{2}{1}$ (remember, they both got flipped, so $2-0$ is negative 2). This may seem annoying, but being able to use partially-applied infix operators has its own rewards.
• Oversetting and undersetting can be used for composition around infix operators. $x\mathbin{\underset\log+}y=\log x+\log y=\log(x\cdot y)=x\mathbin{\overset\log\cdot}y$. Ironically, this nifty non-linear notation comes from two J conjunctions. This is possibly most useful for defining weaker equality operators, as seen in modular arithmetic ($5\mathbin{\underset{\bmod 2}=}3$).
Numerals are separate to everything I've listed here, and are not really relevant. For the record, I prefer balanced base twelve at the moment, but I'm going to try balanced base twenty-four soon. Balanced bases have the advantage, amongst other advantages, that small negative numbers can be written with a single character, rather than three (as I propose).

Of all these, switching of parameters is probably the most jarring and incompatible with standard maths notation. It takes a while to get used to, so I'll try to spare you from it as much as possible on this blog. The other large differences mostly don't clash with existing notation, and others don't have counterparts in the current system.