A correct-by-construction approach to approximate computation
Lead Research Organisation:
Heriot-Watt University
Department Name: School of Mathematical and Computer Sciences
Abstract
Correct-by-construction program development uses advanced type systems to describe both the data manipulated by computation, and the correctness of those computations. Embedding correctness within software has many advantages, as certified by several decades of pioneering work in the UK and elsewhere, which have culminated in systems such as Agda, Idris, Coq, Lean, HOL, Isabelle, etc., which are powerful enough to implement this vision and which are now having significant impact in both academia and industry.
The main question that motivates this research is: can correct-by-construction programming be extended to computation with approximate values, e.g. in: i) stochastic systems where one needs to handle inherent/simulated randomness; ii) resource limited environments, where exact computation is prohibitively expensive; iii) systems with imperfect/partial recall, where one only has limited information about what has happened or the intentions/trustworthiness of each agent; and iv) non-exact computation where primitive data (e.g. from sensors) is inexact and supplied with error bars. These scenarios arise in e.g. cyber-physical systems, machine learning, robotics, automotive engineering, aerospace, and energy systems. Measuring how close measurements might be from their true values naturally leads to the use of metrics but, despite some successes, their use suffers from a number of drawbacks, e.g. i) metrics defined in one problem domain often do not carry over to others; ii) metrics based upon system structure often do not reflect behavioural similarity and vice-versa; and iii) increasingly accurate models of a system's structure are not guaranteed to have increasingly accurate behaviours to that of the modelled system.
We conjecture that these problems are manifestations of the deeper problem that all of the mathematics underpinning computation takes exact equality as primitive, so approximation is built over an exact meta-theory. However, in a recent breakthrough, Mardare and his collaborators introduced Quantitative Algebra (QA) which generalises one of the central pillars of modern mathematics, namely universal algebra (UA), to allow approximate equations in formal reasoning. The generality of this new idea - replacing classical reasoning with a more refined approximate reasoning in the very fabric of mathematics - gives us a new paradigm which supports a rigorous logical framework for a proper approximation theory, where bounds can be handled, convergences proven and limits approximated.
This project will transform the theory and applications of approximate computation by designing, implementing and deploying a new language for trusted approximate computation. It involves:
i) Mathematical Research: We replicate the shift from UA to QA with a similarly revolutionary one from exact computation to approximate computation by developing new quantitative generalisations of the common mathematical structures underpinning exact computation. Approximate computation will then be driven by these new approximate versions of the key structures that drive exact computation.
ii) Type Theory & Programming Languages Research: We develop a core dependent type theory incorporating equality-up-to-approximation and type checking to ensure approximation bounds are adhered to; and we convert our type theory into a usable programming language by developing high level features.
iii) Applications and Impact Generation: We create case studies in systems biology and digital twins to validate our research and create impact with academic/industrial collaborators who have co-created this proposal. This involves the development of approximate game theory as both these case studies involve autonomous agents that need to make optimal decisions in the presence of uncertainty.
The main question that motivates this research is: can correct-by-construction programming be extended to computation with approximate values, e.g. in: i) stochastic systems where one needs to handle inherent/simulated randomness; ii) resource limited environments, where exact computation is prohibitively expensive; iii) systems with imperfect/partial recall, where one only has limited information about what has happened or the intentions/trustworthiness of each agent; and iv) non-exact computation where primitive data (e.g. from sensors) is inexact and supplied with error bars. These scenarios arise in e.g. cyber-physical systems, machine learning, robotics, automotive engineering, aerospace, and energy systems. Measuring how close measurements might be from their true values naturally leads to the use of metrics but, despite some successes, their use suffers from a number of drawbacks, e.g. i) metrics defined in one problem domain often do not carry over to others; ii) metrics based upon system structure often do not reflect behavioural similarity and vice-versa; and iii) increasingly accurate models of a system's structure are not guaranteed to have increasingly accurate behaviours to that of the modelled system.
We conjecture that these problems are manifestations of the deeper problem that all of the mathematics underpinning computation takes exact equality as primitive, so approximation is built over an exact meta-theory. However, in a recent breakthrough, Mardare and his collaborators introduced Quantitative Algebra (QA) which generalises one of the central pillars of modern mathematics, namely universal algebra (UA), to allow approximate equations in formal reasoning. The generality of this new idea - replacing classical reasoning with a more refined approximate reasoning in the very fabric of mathematics - gives us a new paradigm which supports a rigorous logical framework for a proper approximation theory, where bounds can be handled, convergences proven and limits approximated.
This project will transform the theory and applications of approximate computation by designing, implementing and deploying a new language for trusted approximate computation. It involves:
i) Mathematical Research: We replicate the shift from UA to QA with a similarly revolutionary one from exact computation to approximate computation by developing new quantitative generalisations of the common mathematical structures underpinning exact computation. Approximate computation will then be driven by these new approximate versions of the key structures that drive exact computation.
ii) Type Theory & Programming Languages Research: We develop a core dependent type theory incorporating equality-up-to-approximation and type checking to ensure approximation bounds are adhered to; and we convert our type theory into a usable programming language by developing high level features.
iii) Applications and Impact Generation: We create case studies in systems biology and digital twins to validate our research and create impact with academic/industrial collaborators who have co-created this proposal. This involves the development of approximate game theory as both these case studies involve autonomous agents that need to make optimal decisions in the presence of uncertainty.
Organisations
- Heriot-Watt University (Lead Research Organisation)
- UNIVERSITY OF OXFORD (Project Partner)
- National Physical Laboratory (Project Partner)
- UNIVERSITY OF ST ANDREWS (Project Partner)
- UNIVERSITY OF NOTTINGHAM (Project Partner)
- UNIVERSITY OF EDINBURGH (Project Partner)
- McGill University (Project Partner)
Publications
Bacci G
(2024)
Sum and Tensor of Quantitative Effects
in Logical Methods in Computer Science
Bacci G
(2026)
Rational Lawvere Logic
Forbes A
(2025)
Preserving model structure and constraints in scientific computing
in Measurement: Sensors
Furber R
(2026)
Interpreting Lambda Calculus in Domain-Valued Random Variables
König B
(2025)
Behavioural Metrics and Quantitative Logics (Dagstuhl Seminar 24432)
in Dagstuhl Reports (DagRep)
Mardare R
(2025)
Metric Equational Theories
in Electronic Proceedings in Theoretical Computer Science
McBride C
(2025)
LabMate: A prospectus for types for MATLAB
in Measurement: Sensors
Related Projects
| Project Reference | Relationship | Related To | Start | End | Award Value |
|---|---|---|---|---|---|
| EP/Y000455/1 | 01/11/2023 | 29/09/2024 | £692,875 | ||
| EP/Y000455/2 | Transfer | EP/Y000455/1 | 30/09/2024 | 30/10/2027 | £568,555 |
| Description | 1. We investigated compositions of quantitative equational reasoning through combinations of algebraic computational effects, via sum and tensor operations. Building on this, we developed a corresponding framework for quantitative algebraic effects, which are monadic computational effects defined on categories of metric spaces and presented algebraically through quantitative equational theories (QETs). We proved that the sum and tensor of two QETs correspond to the categorical sum and tensor of their associated quantitative monads. We developed a theory of quantitative effect transformers based on these operations, providing quantitative analogues of well-known monad transformers, including exception, resumption, reader, and writer transformers. 2. To support WP3, we investigated how QETs can be combined with Enriched Lawvere Theories. This led to the extension of QETs into Metric Equational Theories (METs). Unlike traditional universal algebra-where operations have finite arities-METs allow arities drawn from countable metric spaces. In this more general setting, the validity of terms cannot be guaranteed independently from the validity of equations. To address this, we adapted the complete proof system for QETs to METs, exploiting structural properties specific to metric spaces. 3. The development of a quantitative type theory, guided us to the foundational computational aspects of the lambda calculus. We introduced Boolean-valued domain theory, demonstrating how the lambda calculus can be interpreted using domain-valued random variables, which provide an intrinsically quantitative semantics. Our work focuses on the reflexive domain construction. We developed the necessary Boolean-valued set theory from first principles and then built Boolean-valued domain theory on top of it. Within this framework, equality and partial order receive Boolean-valued interpretations, meaning that an equation is valid when its interpretation corresponds to the top element of the Boolean algebra. 4. We identified a novel perspective: quantitative equalities can be viewed as real-valued predicates in Lawvere's quantale. To explore this, we developed Rational Lawvere Logic (RL) - is defined over the extended positive reals and combines the algebraic structures of the Lawvere quantale and a multiplicative quantale, forming a semiring. We provided a complete deduction system for finitely axiomatizable theories and established complexity results for validity and consequence. As an application relevant to WP6, we derived a classical result from probability theory relating the Kantorovich distance and the total variation distance. 5. We developed a constructive notion of ordinal exponentiation that supports induction, recursion, and program termination in correct-by-construction settings (WP3). Two seemingly different definitions were proposed and proven equivalent. We showed that this construction is optimal in a constructive framework: a fully general ordinal exponentiation function exists if and only if the law of excluded middle holds. 6. We implemented an intrinsic representation of type theory in Cubical Agda, inspired by Awodey's natural models. The initial natural model is defined using quotient inductive-inductive-recursive types, producing a syntax accepted by Cubical Agda without transports, postulates, or custom rewrite rules. We formalized several meta-properties, including the standard model, normalisation by evaluation for typed terms, and strictification constructions, all of which compute efficiently thanks to Cubical Agda's native support for quotient inductive types. |
| Exploitation Route | Our results have already had a significant impact on the theoretical computer science research community. This is reflected in the growing number of papers on related topics submitted to major international conferences. Further evidence of this influence is the increasing citation count of our foundational paper on Quantitative Algebraic Reasoning, which has reached 144 citations according to Google Scholar, as well as the continued citations of our other publications in this area. In October 2024, we organised the Dagstuhl Seminar 24432 on Behavioural Metrics and Quantitative Logics. The seminar brought together leading researchers in the field, helped establish a number of research priorities, and provided an excellent opportunity to present and discuss the core ideas of our project. In addition, two workshops on quantitative reasoning were organised at the Bellairs Research Institute in Barbados, in April 2024 and March 2025. These events further contributed to fostering collaboration and advancing discussion on the topics addressed by our research. |
| Sectors | Digital/Communication/Information Technologies (including Software) |
| Description | Quantitative Predicate Logic as a Foundation for Verified ML |
| Amount | £750,000 (GBP) |
| Funding ID | MSAI-PR01-P05 |
| Organisation | Advanced Research and Innovation Agency (ARIA) |
| Sector | Public |
| Country | United Kingdom |
| Start | 08/2024 |
| End | 08/2027 |
