Lambda-Calculus: binding precedence

lambda-calculus

I'm utterly confused and hope to find clarification here. I came across a $\lambda$-calculus Interpreter by Liang Gong (who ever that is :)) claiming to be of California University of Berkley. Link: https://jacksongl.github.io/files/demo/lambda/index.htm#firstPage

Besides the associativity rules of $\lambda$-calculus, I learnt that application binds stronger than abstraction. That would mean the following equivalence holds:
$$ \lambda f x. f (f x) \equiv \lambda f. \lambda x. (f (f x)) $$

However, the above mentioned interpreter interprets it as the following equivalence:
$$ \lambda f x. f (f x) \equiv \lambda f .(\lambda x. f) (f x)$$

Can anyone help me and tell me what is correct? Thanks in advance!

Best Answer

It's just conventions. Underlyingly, everything is unambiguously bracketed, it's just that we're lazy and sometimes want to omit brackets for easier readability and writability, and we need to establish conventions on which term we mean (the term with the one or with the other application/abstraction structure) when we leave brackets away. These are the precedence rules. If the source is good, it will explicitly specify the precedence rules and state whether terms with not all of the brackets present are to be read as one or as the other term of the two you listed. Application having precedence over abstraction is the more usual convention, but defining it the other way round is just as "correct" as long as it's done consistently. So the interpreter is not "wrong", it's just a bit sloppy for not stating its precedence conventions explicitly, or rather, contradicting the precedence conventions used in the source it references at the bottom of the page.
If you want to evaluate your term $ \lambda f x. f (f x)$ in the interpreter but with the application preceding abstraction reading, you just need to explicitly indicate the intended structure by providing all the necessary brackets $ \lambda f. \lambda x. (f (f x)) $ in order to override the interpreter's default reading as $ \lambda f .(\lambda x. f) (f x)$.

Related Question