refactor pattern matching environment
refactor type environment
refactor predefined relations
refactor around type