Mathematical Foundations and Practices for CPS