I have two questions about the validity of lambda expressions.
First, is a variable on its own a valid lambda expression (ex: λx)
Second, take for example these two lambda expressions (λx.fxya and λz.fxya). They're identical besides the fact that the bounded variable is different. Does this affect its validity?
Also, if these are all valid, is there a way to see some invalid lambda expressions so I can get an idea between what a valid and invalid one looks like?
It depends on what you mean by valid. Let's start with "syntactically valid". The definition of a valid lambda expression is inductive.
αandβare two valid lambda expressions, then so isα β. We refer to this as the application ofαtoβ.tis some term (as defined above) andαis any lambda expression, thenλt. αis a valid lambda expression. We call this the abstraction ofαover the termt.By this definition,
eis a valid lambda expression, since it's just a term. So isλf. f x, and so isa b c d e f.λ x, on its own, is not. It looks like the start of an abstraction but we never finished it, so it's just a nonsense sequence of letters. However,xon its own is an expression, and so isλx. x.By this definition,
λx. f x y aandλz. f x y aare both lambda expressions. Specifically, they're an abstraction of several applications of terms.Now, for many purposes, we also want a lambda expression to have no free variables. A free variable is one that appears outside of any abstraction bindings for it. The opposite of a free variable is a bound variable. So in
λx. f x y a, thexis bound (by the lambda abstraction), whilef,y, andaare free. Inλz. f x y a, all off,x,y, andaare free. Having the unusedzabstraction is perfectly acceptable.