Skip to main content
QUICK REVIEW

[Paper Review] Rust Distilled: An Expressive Tower of Languages

Aaron Weiss, Daniel Patterson|arXiv (Cornell University)|Jun 7, 2018
Logic, programming, and type systemsComputer Science11 references6 citations
TL;DR

This paper introduces Oxide, a formal semantics for Rust structured as a tower of increasingly expressive languages, using region-based linear capabilities and ghost regions to model ownership and borrowing. It enables precise reasoning about memory safety and provides a foundation for verifying Rust programs, compiler optimizations, and language extensions.

ABSTRACT

Rust represents a major advancement in production programming languages because of its success in bridging the gap between high-level application programming and low-level systems programming. At the heart of its design lies a novel approach to ownership that remains highly programmable. In this talk, we will describe our ongoing work on designing a formal semantics for Rust that captures ownership and borrowing without the details of lifetime analysis. This semantics models a high-level understanding of ownership and as a result is close to source-level Rust (but with full type annotations) which differs from the recent RustBelt effort that essentially models MIR, a CPS-style IR used in the Rust compiler. Further, while RustBelt aims to verify the safety of unsafe code in Rust's standard library, we model standard library APIs as primitives, which is sufficient to reason about their behavior. This yields a simpler model of Rust and its type system that we think researchers will find easier to use as a starting point for investigating Rust extensions. Unlike RustBelt, we aim to prove type soundness using progress and preservation instead of a Kripke logical relation. Finally, our semantics is a family of languages of increasing expressive power, where subsequent levels have features that are impossible to define in previous levels. Following Felleisen, expressive power is defined in terms of observational equivalence. Separating the language into different levels of expressive power should provide a framework for future work on Rust verification and compiler optimization.

Motivation & Objective

  • To provide a formal, compositional semantics for Rust that captures the essence of ownership and borrowing in a way accessible to both researchers and learners.
  • To address the complexity of Rust's type system and borrow checker by separating semantics into levels of increasing expressive power.
  • To enable future work in formal verification, compiler optimization, and language extension by providing a rigorous foundation.
  • To support safe interoperability between Rust and other languages through formal linking and type systems.
  • To inform the development of unsafe code guidelines by grounding low-level reasoning in a formal model.

Proposed method

  • Modeling Rust's ownership and borrowing using region-based linear capabilities, where each region represents a capability to access a value.
  • Introducing 'ghost regions' to track aliasing relationships during borrowing, distinct from physical memory locations.
  • Using an instrumented operational semantics that maintains region contexts to prove progress and preservation.
  • Designing a tower of languages (Oxide 0, 1, etc.) where each level adds expressive power not possible in prior levels, based on observational equivalence.
  • Implementing a prototype type checker in Scala and beginning a Coq formalization for proof development.
  • Planning an erasure procedure to remove ghost region information, with operational correspondence between instrumented and post-erasure semantics.

Experimental results

Research questions

  • RQ1How can a formal semantics for Rust be structured to reflect increasing levels of expressive power while preserving observational equivalence?
  • RQ2Can region-based linear capabilities with ghost regions accurately model Rust's ownership and borrowing without requiring manual capability passing?
  • RQ3How can a tower of languages be used to support modular reasoning about Rust programs and their verification?
  • RQ4What formal guarantees can be established for type safety and memory safety in a semantics that models both physical and ghost regions?
  • RQ5How can such a semantics serve as a foundation for safe language extensions and interoperability with other languages?

Key findings

  • Oxide models ownership and borrowing using region-based capabilities and ghost regions, enabling automatic tracking of aliasing and capability transfer.
  • The semantics is structured as a tower of languages, with each level adding features not expressible in previous levels, supporting Felleisen's notion of expressive power via observational equivalence.
  • Progress and preservation proofs are being developed for Oxide 0, with an instrumented semantics that tracks region contexts and aliasing relationships.
  • A prototype type checker in Scala and an initial Coq formalization are in place, supporting experimentation and future proof development.
  • The framework enables future work on safe interoperability, language extensions (e.g., for secure multiparty computation), and formal unsafe code guidelines.
  • An erasure procedure is planned to remove ghost region information, with operational correspondence to be proven between instrumented and post-erasure semantics.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.