A Semantic Theory of the Internet of Things