Mathematical Foundations of Digital Twins