Reference. Everybody’s Got To Be Somewhere

The key to any nameless representation of syntax is how it indicates the variables we choose to use and thus, implicitly, those we discard. Standard de Bruijn representations delay discarding maximally till the leaves of terms where one is chosen from the variables in scope at the expense of the rest. Consequently, introducing new but unused variables requires term traversal. This paper introduces a nameless ‘co-de-Bruijn’ representation which makes the opposite canonical choice, delaying discarding minimally, as near as possible to the root. It is literate Agda: dependent types make it a practical joy to express and be driven by strong intrinsic invariants which ensure that scope is aggressively whittled down to just the support of each subterm, in which every remaining variable occurs somewhere. The construction is generic, delivering a universe of syntaxes with higher-order metavariables, for which the appropriate notion of substitution is hereditary. The implementation of simultaneous substitution exploits tight scope control to avoid busywork and shift terms without traversal. Surprisingly, it is also intrinsically terminating, by structural recursion alone.

Cite

Cite as @mcbrideEverybodysGotToBeSomewhere2018 (helia, typst) · \cite{mcbrideEverybodysGotToBeSomewhere2018} (LaTeX)
BibTeX
bibtex · 11 lines
@inproceedings{mcbrideEverybodysGotToBeSomewhere2018,
 title = {Everybody's Got To Be Somewhere},
 author = {McBride, Conor},
 year = {2018},
 booktitle = {Proceedings of the 7th Workshop on
   Mathematically Structured Functional Programming (MSFP 2018)},
 series = {EPTCS},
 volume = {275},
 pages = {53--69},
 doi = {10.4204/EPTCS.275.6}
}
hayagriva YAML (typst)
yaml · 15 lines
mcbrideEverybodysGotToBeSomewhere2018:
  type: article
  title: Everybody's Got To Be Somewhere
  author: McBride, Conor
  date: 2018
  page-range: 53-69
  serial-number:
    doi: 10.4204/EPTCS.275.6
  parent:
    type: proceedings
    title: Proceedings of the 7th Workshop on Mathematically Structured Functional Programming (MSFP 2018)
    volume: 275
    parent:
      type: proceedings
      title: EPTCS
Cited by (4)

Canonical bidirectional typechecking mihejevs-2025-canonical

We demonstrate that the checkable/synthesisable split in bidirectional typechecking coincides with existing dualities in polarised System L, also known as polarised 𝜇𝜇˜-calculus. Specifically, positive terms and negative coterms are checkable, and negative terms and positive coterms are synthesisable. This combines a standard formulation of bidirectional typechecking with Zeilberger’s ‘cocontextual’ variant. We extend this to ordinary ‘cartesian’ System L using Mc Bride’s co-de Bruijn formulation of scopes, and show that both can be combined in a linear-nonlinear style, where linear types are positive and cartesian types are negative. This yields a remarkable 3-way coincidence between the shifts of polarised System L, LNL calculi, and bidirectional calculi.
arXiv

Modular abstract syntax trees (MAST): substitution tensors with second-class sorts fiore-2025-modular

We adapt Fiore, Plotkin, and Turi’s treatment of abstract syntax with binding, substitution, and holes to account for languages with second-class sorts. These situations include programming calculi such as the Call-by-Value lambda-calculus (CBV) and Levy’s Call-by-Push-Value (CBPV). Prohibiting second-class sorts from appearing in variable contexts changes the characterisation of the abstract syntax from monoids in monoidal categories to actions in actegories. We reproduce much of the development through bicategorical arguments. We apply the resulting theory by proving substitution lemmata for varieties of CBV.
DOI · arXiv

Fulls Seldom Differ koch-2025-fulls

Many programs process lists by recursing in a wide variety of sequential and/or divide-and-conquer patterns. Reasoning about the correctness and completeness of these programs requires reasoning about the lengths of the lists, techniques for which are typically undecidable or at least NP-complete. In this paper we show how introducing a relatively simple (sub-)language for expressions describing list lengths, whilst not completely general, covers a great number of these patterns. It includes not only doubling but also exponentiation (iterated doubling), and moreover admits a simple length-checking algorithm that is complete over a predictable problem domain. We prove termination of the algorithm via category-theoretic pullbacks, formalized in Agda, as well as providing a more realistic implementation in Rocq, and a toy language Fulbourn with interpreter in Haskell.
PDF · DOI · pldb

Vehicle: Interfacing Neural Network Verifiers with Interactive Theorem Provers daggitt-2022-vehicle

Verification of neural networks is currently a hot topic in automated theorem proving. Progress has been rapid and there are now a wide range of tools available that can verify properties of networks with hundreds of thousands of nodes. In theory this opens the door to the verification of larger control systems that make use of neural network components. However, although work has managed to incorporate the results of these verifiers to prove larger properties of individual systems, there is currently no general methodology for bridging the gap between verifiers and interactive theorem provers (ITPs). In this paper we present Vehicle, our solution to this problem. Vehicle is equipped with an expressive domain specific language for stating neural network specifications which can be compiled to both verifiers and ITPs. It overcomes previous issues with maintainability and scalability in similar ITP formalisations by using a standard ONNX file as the single canonical representation of the network. We demonstrate its utility by using it to connect the neural network verifier Marabou to Agda and then formally verifying that a car steered by a neural network never leaves the road, even in the face of an unpredictable cross wind and imperfect sensors. The network has over 20,000 nodes, and therefore this proof represents an improvement of 3 orders of magnitude over prior proofs about neural network enhanced systems in ITPs.
arXiv
Cites 23 works (2 here)
With notes (2)

Type-and-scope safe programs and their proofs allais-2017-type

PDF · DOI · pldb

First-order unification by structural recursion mcbrideFirstorderUnification2003

First-order unification algorithms (Robinson, 1965) are traditionally implemented via general recursion, with separate proofs for partial correctness and termination. The latter tends to involve counting the number of unsolved variables and showing that this total decreases each time a substitution enlarges the terms. There are many such proofs in the literature (Manna & Waldinger, 1981; Paulson, 1985; Coen, 1992; Rouyer, 1992; Jaume, 1997; Bove, 1999). This paper shows how a dependent type can relate terms to the set of variables over which they are constructed. As a consequence, first-order unification becomes a structurally recursive program, and a termination proof is no longer required. Both the program and its correctness proof have been checked using the proof assistant LEGO (Luo & Pollack, 1992; McBride, 1999).
PDF · DOI · pldb
mcbrideEverybodysGotToBeSomewhere2018 reference entries/refs/mcbrideEverybodysGotToBeSomewhere2018/mcbrideEverybodysGotToBeSomewhere2018.hel