Add more abstract binary-search sub.

Rewrite lower-bound and upper-bound in terms of it.