Add irrelevant kinds infrastructure to TheoryModel (#4945)