Constraint referencing multiple tables
What you have described is modeled as follows:


What you are attempting to do is a design flaw (logic bomb); it's called a Fan-Trap in relational database design. 

To get around the logic flaw that you are bumping into, you must collect (resolve) the relation from all three tables, Tasks, Roles and Tools into a single associative entity as follows:


Each row of Access collects the relationships between Tools, Tasks and roles. 

As far as complexities of constraints is concerned, I think you are confusing the implementation method with design. Good design will clarify the intent, help the developers and maintain performance. The constraints are declarative (and in the SQL standard) to keep things simple while offering verification, validation and enforcement of the design. When you get to the point where you are considering implementing your constraints in code; take a moment to reflect (can an alternate design address this issue in a more elegant way? That's the fun part of design anyway).

Sometimes it cannot (Business Rules come to mind), and the use of triggers/functions is supportable; but your job just got a LOT more complex and bug prone.