A realistic theory of science