A realist theory of science