An algorithm for testing conversion in type theory