Quick solution to restrictions:
context Department inv: self.staff โ forAll (s1, s2 | s1.manager = s2.manager)
context Company inv: self.employee-> forAll (e | e.manager <> e)
context Company inv: self.employee-> forAll (e | e.salary <= e.manager.salary)
By the way, I really don't see the need for a company class (how many company type objects do you have in the system?). If the restrictions for two companies are true for all companies, then they can be expressed using Person as a context in this way (for example, with number 2): context Person inv: self.manager <> self)
We can also add checks to make sure that the employee has a manager before performing the comparison
Jordi cabot
source share