Interaction Trees: Representing Recursive and Impure Programs in Coq
arXiv:1906.00046 · doi:10.1145/3371119
Abstract
"Interaction trees" (ITrees) are a general-purpose data structure for representing the behaviors of recursive programs that interact with their environments. A coinductive variant of "free monads," ITrees are built out of uninterpreted events and their continuations. They support compositional construction of interpreters from "event handlers", which give meaning to events by defining their semantics as monadic actions. ITrees are expressive enough to represent impure and potentially nonterminating, mutually recursive computations, while admitting a rich equational theory of equivalence up to weak bisimulation. In contrast to other approaches such as relationally specified operational semantics, ITrees are executable via code extraction, making them suitable for debugging, testing, and implementing software artifacts that are amenable to formal verification. We have implemented ITrees and their associated theory as a Coq library, mechanizing classic domain- and category-theoretic results about program semantics, iteration, monadic structures, and equational reasoning. Although the internals of the library rely heavily on coinductive proofs, the interface hides these details so that clients can use and reason about ITrees without explicit use of Coq's coinduction tactics. To showcase the utility of our theory, we prove the termination-sensitive correctness of a compiler from a simple imperative source language to an assembly-like target whose meanings are given in an ITree-based denotational semantics. Unlike previous results using operational techniques, our bisimulation proof follows straightforwardly by structural induction and elementary rewriting via an equational theory of combinators for control-flow graphs.
28 pages, 4 pages references, published at POPL 2020
References in corpus (6)
- Handling Algebraic Effects
- General Recursion via Coinductive Types
- Programming with Algebraic Effects and Handlers
- From C to Interaction Trees: Specifying, Verifying, and Testing a Networked Server
- Resumptions, Weak Bisimilarity and Big-Step Semantics for While with Interactive I/O: An Exercise in Mixed Induction-Coinduction
- Partiality, Revisited: The Partiality Monad as a Quotient Inductive-Inductive Type
Cited by in corpus (26)
- SteelCore: An Extensible Concurrent Separation Logic for Effectful Dependently Typed Programs
- Formally Verified Native Code Generation in an Effectful JIT -- or: Turning the CompCert Backend into a Formally Verified JIT Compiler
- Igloo: Soundly Linking Compositional Refinement and Separation Logic for Distributed System Verification
- Choice Trees: Representing Nondeterministic, Recursive, and Impure Programs in Coq
- Fully Composable and Adequate Verified Compilation with Direct Refinements between Open Modules (Technical Report)
- A Two-Phase Infinite/Finite Low-Level Memory Model
- Model-Based Testing of Networked Applications
- Two Guarded Recursive Powerdomains for Applicative Simulation
- Program Adverbs and Tlön Embeddings
- Formally Verified Animation for RoboChart using Interaction Trees
- A HAT Trick: Automatically Verifying Representation Invariants Using Symbolic Finite Automata
- Securing Verified IO Programs Against Unverified Code in F*
- Smart Choices and the Selection Monad
- Verifying an Effect-Handler-Based Define-By-Run Reverse-Mode AD Library
- Structural Temporal Logic for Mechanized Program Verification
- A denotationally-based program logic for higher-order store
- Let it Flow: A Formally Verified Compilation Framework for Asynchronous Dataflow
- User-Guided Verification of Security Protocols via Sound Animation
- Inductive and Coinductive Predicate Liftings for Effectful Programs
- Zooid: a DSL for Certified Multiparty Computation
- Denotation-based Compositional Compiler Verification
- SMLtoCoq: Automated Generation of Coq Specifications and Proof Obligations from SML Programs with Contracts
- Flexible Refinement Proofs in Separation Logic
- Abstraction Logic: The Marriage of Contextual Refinement and Separation Logic
- A Case Study on the Effectiveness of LLMs in Verification with Proof Assistants
- Effectful Programming in Declarative Languages with an Emphasis on Non-Determinism: Applications and Formal Reasoning