I’m trying to figure out how I would draw a syntax tree for the expression below. First, how exactly is this behaving? It looks like it takes 1 and 2 as parameters, and if n is 0, it will just return m.

Also, could someone point a start off to parse tree, or an example? I haven’t been able to find one.
Once the function is defined, you do applications of the arguments on the function itself, returning, thus, new functions, resultants of the applied args.
I’m not sure which language you used to wirte that code, but the application would result in something like:
Since
\fis the definition of the function, you can write the above as:And the applications:
Replacing the outermost variable with the innermost argument (in this case,
nby 1):Resolving it a bit:
Applying the second argument, and resolving:
We know (isZero 1) is false; so, we solve the above expression and have the resulting:
Which is the same as of applying 0 to function f, and then, 3 to the result.
The above expression may be read as: “f” is: 0 applied to “f”, and 3 applied to the result of the former application.
But f’s been defined formerly as:
So, in this case, you’d have:
In the syntax tree you would simply show the expansions, reaching the result 3.
As a more straightforward example of the application process, considering the function “sum”, defined as (\x.\y.x + y), the result of (sum 3 2) would be:
There’s no restraint on the order one solves the expressions; lambda calculus is proved to have the same result what ever may be the order of the reductions used.
See ref.
As pointed out by Giorgio,
Yis a fixed point combinator, that allows you to stop iterating at a certain point, if you’re applications return to the same expression.Since the application requires a finite number of iterations, the solution would be the same, simply noting the fixed pointer combination mark:
Reference to fixed point combinator.