  Let f:X-->R be a function defined on a connected nonsingular real algebraic
set X in R^n. We prove that regularity of f can be detected on either algebraic
curves or surfaces in X. If dimX>1 and k is a positive integer, then f is a
regular function whenever the restriction f|C is a regular function for every
algebraic curve C in X that is a C^k submanifold homeomorphic to the unit
circle and is either nonsingular or has precisely one singularity. Moreover, in
the latter case, the singularity of C is equivalent to the plane curve
singularity defined by the equation x^p=y^q for some primes p<q. If dimX>2,
then f is a regular function whenever the restriction f|S is a regular function
for every nonsingular algebraic surface S in X that is homeomorphic to the unit
2-sphere. We also have suitable versions of these results for X not necessarily
connected.
