Implement constant() and variable() in terms of function()

Specifically,

  - A constant is a function with zero derivative
  - A variable is a function with unit derivative with respect to
    itself.