Implement goal compilation.