Changed all the separate k-regular invariants to a single invariant that returns k if k-regular and 0 otherwise.