A constraint function is a mathematical expression that represents a limitation or condition imposed on the variables of an optimization problem. In the context of finding extrema of a function, constraint functions define the boundaries within which a solution must lie. They are essential in optimization problems, particularly when using methods like Lagrange multipliers, to ensure that solutions adhere to specified criteria.