RPO, Second-order Contexts, and Lambda-calculus (Logical Methods in Computer Science, 2009)