Add a custom function to the Constraint class

The custom function takes a Word and returns True if the word is part of the constraint.