TITLE: How does second-order logic relate to lambda calculus?
QUESTION [7 upvotes]: How does second-order arithmetic/logic relate to lambda calculus? By lambda calculus, I mean both typed and untyped. And is there any relationship with recursive and recursively enumerable sets?
Edit: some edits.

REPLY [8 votes]: The question is rather vague. However, I recall something that you may be interested in:
System F is a typed lambda calculus that has a very interesting property:

An arithmetic function can be represented in System F if and only if it can be proved total in second order Peano arithmetic.

This also means that in System F we can represent basically all total functions we can ever imagine.
There is also a weaker system called Gödel System T, for which there is a similar theorem:

An arithmetic function can be represented in System T if and only if it can be proved total in first order Peano arithmetic.

System T is the simply typed calculus enriched with booleans, natural numbers and primitive recursion on them.
Also:

All functions representable in System F and System T are total.
This means that those systems (unlike the untyped lambda calculus) are not Turing complete.

All this is described in detail in Proofs and Types by Jean-Yves Girard, Yves Lafont and Paul Taylor.