Let R be a real closed field. The Pierce-Birkhoff conjecture says that any piecewise polynomial function f on R^n can be obtained from the polynomial ring R[x_1,...,x_n] by iterating the operations of maximum and minimum. The purpose of this paper is twofold. First, we state a new conjecture, called the Connectedness conjecture, which asserts the existence of connected sets in the real spectrum of R[x_1,...,x_n] satisfying certain conditions. We prove that the Connectedness conjecture implies the Pierce-Birkhoff conjecture. Secondly, we construct a class of connected sets in the real spectrum which, though not in itself enough for the proof of the Pierce-Birkhoff conjecture, is the first and simplest example of the sort of connected sets we really need, and which constitutes a crucial step on the way to a proof of the Pierce-Birkhoff conjecture in dimension greater than 2, to appear in a subsequent paper.