type inference by logic programming