Lattice Functions, Pair Algebras, and Finite-State Machines