Click on all of the free variable occurrences below and then check your answer on the right.
Consider each (non-binding) variable occurrence in turn. If the expression contains no binding occurrence with the same name as the variable occurrence under consideration, then this variable occurrence is clearly free.
If there is one or more binding occurrences with the same name as the variable occurrence under consideration, determine whether it belongs to the scope of one of these binding occurrences. If so, then the variable occurrence in question is bound. Otherwise, it is free.
If you are still not sure what the correct answer is, here
is a complete and correct algorithm to determine whether or
not a given variable occurrence is free in a given lambda
expression:
1. Build a parse tree for the
expression.
2. Find the leaf node in this tree that
corresponds to the variable occurrence in
question.
3. Starting from this leaf node, repeatedly go
up along the edges of the tree until you reach a node for a
lambda abstraction whose parameter has the same name as the
variable in question.
4. If you find such a node, then
the variable occurrence is bound; otherwise, it is
free.