Correction in type theory, added sections 7 and 8.