Newton: A Language for Describing Physics

11/12/2018 ∙ by Jonathan Lim, et al. ∙ University of Cambridge 0

This article introduces Newton, a specification language for notating the analytic form, units of measure, and sensor signal properties for physical-object-specific invariants and general physical laws. We designed Newton to provide a means for hardware designers (e.g., sensor integrated circuit manufacturers, computing hardware architects, or mechanical engineers) to specify properties of the physical environments in which embedded computing systems will be deployed (e.g., a sensing platform deployed on a bridge versus worn by a human). Compilers and other program analysis tools for embedded systems can use a library interface to the Newton compiler to obtain information about the sensors, sensor signals, and inter-signal relationships imposed by the structure and materials properties of a given physical system. The information encoded within Newton specifications could enable new compile-time transformations that exploit information about the physical world.



There are no comments yet.


page 1

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Newton

Newton is a language for specifying dimensionally-annotated constraints and invariants on values obtained from sensors embedded in physical structures. The Newton specification compiler provides a library interface that programming language compilers can use to obtain information about the physical constraints on the signals in the programs they process. Compiled programs and runtime systems can also access information about their physical environments and sensor invariants using Newton’s runtime library, which provides routines for runtime querying of invariant properties (6).

1.1 Example

The example below shows the Newton specification for the relationship between the period of an idealized simple pendulum, the distance between the pivot point of the pendulum and its primary mass, and constants (e.g., acceleration due to gravity).

1time: signal  = {
2   name       = "second" English;
3   symbol     = s;
4   derivation = none;
7length: signal = {
8   name        = "meter" English;
9   symbol      = m;
10   derivation  = none;
13mass: signal  = {
14   name       = "kilogram" English;
15   symbol     = kg;
16   derivation = none;
19Pi : constant = 3.14;
20g  : constant = 9.8*m*s**-2;
22pendulum: invariant(L: length, period: time) = {
23   period ~ 2*Pi*((L/g)**(1/2))

2 Related Research

Dimensional analysis has been a valuable tool in science and engineering disciplines for over a century. Early work by Buckingham (7), laid the foundations for the more systematic study and application of dimensions in both design and system evaluation. Central to many modern applications of dimensional analysis has been the Buckingham Pi Theorem, which states that any constraint between physical quantities, comprising dimensionally-independent physical quantities, can be represented using a reduced number, , of monomial expressions constructed from the original physical quantities.

In programming languages, introducing dimension types has been explored through both built-in types and libraries. House (8) proposed extending the Pascal language with units and dimensions, and F# (9) includes mechanisms for a programmer to declare dimensions of physical quantities. F# allows programmers to use these dimension types in programs, and provides support for type checking and type inference based on a dimension unification algorithm (10). Similarly, XeLda (11) provides type checking for data in Excel spreadsheet programming.

Unlike techniques and systems for expressing and checking dimensions in programming languages, the objective of Newton is instead to allow sensor manufacturers, embedded system hardware platform manufacturers, industrial design engineers, and physicists to describe mechanical and other physical invariants obeyed by physical artifacts instrumented with sensors. Programming language compilers can then use these specifications to guide static compile-time and dynamic run-time program transformations. Newton enables compilers to extend their use of physical information beyond dimension type checking: Using information on sensor signal relationships obtained from Newton at compile time or at runtime, code generated by compilers that use Newton could check not only dimensions, but also physics-derived and platform-specific signal property invariants.

3 Newton Descriptions

There are three components of a Newton description: signal definitions, constant definitions, and invariant definitions.

3.1 Signals

Signals in Newton define either fundamental or derived signals, and their units. They typically represent signals that can be read from sensors on a hardware platform, such as acceleration from accelerometers, magnetic flux density from magnetometers, and angular rate from gyroscopes. Some fundamental signal types (e.g., time) exist primarily to be able to define derived signal types relevant to sensors, while others directly represent the signals of sensors (e.g., temperature). The Newton language does not specify which signals are fundamental a priori, and a Newton specification can define its own choice of fundamental signals. The compiler installation provides a standard set of signal definitions and in practice most Newton descriptions build on top of this standard set of definitions.

All signal definitions in Newton have a derivation statement. Fundamental signals have none as their derivation, while non-fundamental signals have a derivation which is a monomial expression comprising previously-defined fundamental or derived signals.

Newton specifications can define multi-dimensional signals, as the examples of the signals distance and speed below illustrate. Example uses of multi-dimensional signals include sensors such as 3-axis accelerometers and specifying signals from a single sensor sampled at different locations in space.

1time : signal  = {
2    name       = "second" English;
3    symbol     = s;
4    derivation = none;
7distance : signal(i: 0 to 2) = {
8    name       = "meter" English;
9    symbol     = m;
10    derivation = none;
13speed : signal(i: 0 to 2) = {
14    derivation = distance@i / time;

The name field of a signal definition is a human-readable word or phrase describing the signal in a specific set of units and therefore includes a language designator (e.g., English). The symbol field in a signal definition specifies a token that can be used as an alias for a specific unit for the signal. For example, distance in the example above is defined as a fundamental signal (derivation = none) with units description "meter" and unit symbol m. This approach is similar to aliasing in F# (9).

3.2 Constants

Constants are fixed values with a dimension formed from a monomial expression of previously-defined signals. Constants can also be dimensionless, such as the mathematical constant :

1speedLimit  : constant = 100 * m / s;
2Pi    : constant = 3.1415926535897932384626433832795;

3.3 Invariants

Invariant definitions take in a list of parameters (signals and constants) with designated dimensions and define a physical relationship between those parameters and previously-defined signals and constants. The bodies of Newton invariants are comma-separated lists of expressions involving a relational operator and these expressions are interpreted as being in a conjunction.

This research was initiated when the authors were both with the Computer Science and Artificial Intelligence Laboratory (CSAIL), Massachusetts Institute of Technology. The authors thank Zhengyang Gu for contributing an SMT-based analysis pass 

(12), Vlad Mihai Mandric, Youchao Wang, and James Rhodes for assisting with the implementation of linear-algebraic dimensional analysis passes, and Rae Zhao for beta-testing the syntax for Newton sensor descriptions. PSM is supported in part by an Alan Turing Institute award TU/B/000096 under EPSRC grant EP/N510129/1 and by Royal Society grant RG170136.


  • (1) French Ministry for sustainable development (2013) Sensor Malfunction Fact Sheet.
  • (2) (1996) Aeroperu flight 603 ( Accessed: 2017-05-16.
  • (3) MacPherson M (1998) The black box: All-new cockpit voice recorder accounts of in-flight accidents. (William Morrow New York).
  • (4) Sampson A, et al. (2014) Expressing and verifying probabilistic assertions in Proceedings of the 35th Conference on Programming Language Design and Implementation, eds. O’Boyle MFP, Pingali K. (ACM), p. 14.
  • (5) Cocke J, Kennedy K (1977) An algorithm for reduction of operator strength. Commun. ACM 20(11):850–856.
  • (6) Lim J (2017) Newton: A Language for Describing Physics. M.Eng. Thesis, Massachusetts Institute of Technology, Department of Electrical Engineering and Computer Science.
  • (7) Buckingham E (1914) On physically similar systems; illustrations of the use of dimensional equations. Phys. Rev. 4(4):345–376.
  • (8) House RT (1983) A proposal for an extended form of type checking of expressions. Comput. J. 26(4):366–374.
  • (9) Kennedy A (2010) Types for units-of-measure: Theory and practice in Proceedings of the Third Summer School Conference on Central European Functional Programming School, CEFP’09. (Springer-Verlag, Berlin, Heidelberg), pp. 268–305.
  • (10) Kennedy A (1994) Dimension types in Proceedings of the 5th European Symposium on Programming: Programming Languages and Systems, ESOP ’94. (Springer-Verlag, London, UK, UK), pp. 348–362.
  • (11) Antoniu T, Steckler PA, Krishnamurthi S, Neuwirth E, Felleisen M (2004) Validating the unit correctness of spreadsheet programs in Proceedings of the 26th International Conference on Software Engineering, ICSE ’04. (IEEE Computer Society, Washington, DC, USA), pp. 439–448.
  • (12) Gu Z (2018) Checking Physical Invariants In Algorithms. M.Eng. Thesis, University of Cambridge, Department of Engineering.