Nucleon-pair shell model: Formalism and special cases