Fix injectivity check for open type families

Previously I used some ad-hoc hack, now I have an algorithm that
seems to be correct. I also added some stub comments. Need to add
more later