Patrik Jansson

Professor of Computer Science


Curriculum vitae



+46317725415


Computer Science and Engineering

Chalmers University of Technology

Room number: EDIT-6452
My office is in the EDIT building of campus Johanneberg, near Rännvägen 6.



Dimensional Analysis meets Dependent Types


Types, equations, dimensions and the Pi theorem


December 02, 2025

(About a pre-print by Nicola Botta & Patrik Jansson)

Specialization in the physical sciences has widened the gap between the languages of mathematical physics and those of functional programming (FP). While computer-based modelling critically needs precise specifications, dependently typed languages are not yet well-equipped to encode the "grammar of dimensions" that rules physics (Dimensional Analysis, DA).

In our new pre-print, Types, equations, dimensions and the Pi theorem (arXiv:2308.09481), we take a step toward bridging this gap.

The Grammar of Dimensions

We analyzed dimension functions, physical quantities, and units of measurement through the lens of Programming Languages. Based on this, we propose a small Domain-Specific Language (DSL) in Idris (or Agda). This DSL leverages the host type system to enforce dimensional consistency and assess dimensional dependence and independence.

Formalizing Covariance

Beyond simple unit checking, we formalized the covariance principle: the requirement that physical laws must be independent of the chosen system of units. We define this as a homomorphism between the algebra of physical quantities and the algebra of real numbers.

Screenshot of a diagram illustrating the covariance principle (or principle of relativity of measurements) for a function between physical quantities.
Screenshot of the covariance principle from the paper (p. 27)

By proving that elementary arithmetic operations preserve this property, we explain the type-theoretic foundation for dimensionally consistent programming.

A Constructive Pi Theorem

Classically, Buckingham's Pi theorem is formulated non-constructively. In our work, we add a constructive direction.

This allows us to go beyond merely checking existing equations. It enables the definition of functions that fulfil the covariance principle by construction. Consequently, dependently typed languages can support DA-driven program derivation, where the type checker actually assists modellers in identifying valid physical laws from empirical data constraints.

Looking Ahead

We view this work as a contribution toward understanding relativity principles through formalization. While these principles are well understood in engineering and physics, it is unclear how they apply to economics, biology, or climate science. We believe that Type Theory and FP can contribute significantly to answering this question.

Full pre-print: https://arxiv.org/abs/2308.09481

Associated code: PIK-Potsdam GitLab Repository



Share

Tools
Translate to