arXiv:2611.07916cs.PLNov 2026

Manuscript Offprint

arXiv:2611.07916

SymFC: Configurable Semantics for All Paths Symbolic Execution in Haskell via Embeddings

Robin Webbers, Wind Wong, Klaus v. Gleissenthall

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ROBIN WEBBERS, Vrije Universiteit Amsterdam, The Netherlands

WIND WONG, Vrije Universiteit Amsterdam, The Netherlands

KLAUS VON GLEISSENTHALL, Vrije Universiteit Amsterdam, The Netherlands

Lightweight formal methods like QuickCheck have proven to be extraordinarily successful in functional languages and beyond, as they let users specify properties as Boolean functions, directly in code. We can replicate some of their benefits for (bounded) proofs, via symbolic execution. If we can execute arbitrary functions symbolically, we can specify properties just as easily. Unfortunately, existing symbolic execution tools for Haskell, are restricted to a subset of the language that excludes many real-world applications like IO; they also have a hard time scaling to larger programs, making them a poor fit for a general purpose, lightweight verification method. One reason behind these limitations is that existing techniques only offer fixed symbolic semantics for SMT base types that are then lifted to other language features. This makes it hard to cover more programming constructs and libraries; it also makes it difficult to fine-tune symbolic representations for better performance.

In this paper, we present SymFC, a new symbolic execution method for Haskell that offers configurable semantics via embeddings. An embedding of a function in SymFC is just another Haskell function that can use arbitrary code, as well as SMT primitives. Embeddings make it easy to support new programming constructs, and let us fine-tune symbolic representations for speed. To integrate embeddings into Haskell's type system, we make use of an existing feature: coercions that let us transparently convert between a Haskell type and the type of its embedding. We realize embeddings in SymFC, an all-paths symbolic execution engine for Haskell, that, unlike related work, lets us symbolically represent arbitrary types and values in GHC core. We implement SymFC as a GHC plugin, and evaluate it by checking properties of Haskell's container library, and the iproute library. We build embeddings for IORef, Haskell's Ptr/ForeignPtr interface, and the hardware library ClambdaSH, and evaluate SymFC against G2 – another symbolic execution tool for Haskell – where we report a 6.25x speedup on G2's own benchmarks.

1 Introduction

Motivation and Problem. Lightweight formal methods like Property Based Testing (PBT) à la QuickCheck [9] have proven to be extremely successful and are (next to types), among the most widely used formal tools in functional languages and beyond [14]. What makes property based testing so appealing is its ease of use: users specify the properties they want to test directly as Boolean valued functions as part of the code; checks are fast since they only need to run the underlying program.

We can replicate some benefits of property based testing, even if we want more stringent guarantees on correctness: if the properties we want to prove only involve bounded recursion, we can use symbolic execution [18] to obtain proofs. If we can symbolically execute arbitrary functions, symbolic execution lets us specify properties in code, just as easily as PBT. Unfortunately, existing symbolic execution tools for Haskell are typically restricted to a subset of the language which often excludes important real-world applications like IO. They also scale poorly to larger programs, which limits their applicability, and makes them less convenient to use.

One reason behind these limitations is that existing techniques like G2 [15] only offer fixed symbolic semantics for primitive types (e.g. Int as the SMT BitVector type), which they lift to other language constructs. This makes it difficult to cover a larger class of programming constructs

Authors' Contact Information: Robin Webbers, Vrije Universiteit Amsterdam, Amsterdam, The Netherlands, r.m.a.webbers@vu.nl; Wind Wong, Vrije Universiteit Amsterdam, Amsterdam, The Netherlands, t.f.w.wong@vu.nl; Klaus von Gleissenthal, Vrije Universiteit Amsterdam, Amsterdam, The Netherlands, k.freiherrvongleissenthal@vu.nl.

Robin Webbers, Wind Wong, and Klaus von Gleissenthall

and libraries. It also affects performance. Indeed, we often want more fine-grained control over how we represent expressions symbolically. For example, when reasoning about Haskell's text library, we can embed strings as SMT strings, when we want to reason about its usage. This makes reasoning much faster and more scalable than reasoning about a direct bit-level encoding. On the other hand, when verifying the implementation of text itself, we need to expose bit-level operations and pointers. Both are valid encodings, and which one is right depends on the user intent. To build scalable symbolic execution tools that are fast, easy to use and cover large classes of programming constructs, we need to allow the semantics of programs to be configurable by the user, on a per-property basis.

Our Solution. In this work, we present SymFC a new symbolic execution method for Haskell that offers configurable semantics via a new notion of embeddings. An embedding of a function in SymFC is just another Haskell function that may make use of arbitrary Haskell code, as well as SMT primitive in arbitrary theories. Embeddings allow us to fine-tune symbolic representations according to need on a per-property level which helps both coverage and scalability.

We integrate embeddings into Haskell by exploiting an existing language construct: coercions. Coercions transparently convert between a type and its SMT embedding making it easy to derive custom interpretations. By reusing Haskell's typeclass infrastructure for coercions, we were able to implement embeddings as a light-weight extension to GHC in only ~ 500 lines of Haskell code.

To be scalable, SymFC implements an all-paths symbolic execution engine. Unlike existing work, SymFC can symbolically represent arbitrary values and types in GHC core, which allows us to do highly efficient all paths symbolic execution and merging. For this, SymFC builds on new evaluation calculus that offers an alternative symbolic semantics for System FC via reduction rules on symbolic values and symbolic environments. We present merging rules for symbolic values in our calculus which yield smaller expressions and makes it easier to scale our technique. Our calculus also handles laziness natively – symbolic execution is just reduction in the alternative symbolic semantics.

We implement SymFC as a GHC plugin and evaluate it on a number of examples. We use it to verify properties in Haskell's containers library, in iproute, where we uncover a bug in the library. We also give three case studies for embeddings: IORef to model IO, Haskell's pointer, and foreign pointer interface Ptr/ForeignPtr, and Clambda, a library for writing hardware in Haskell. Finally, we evaluate SymFC against G2 and show that its all-path symbolic execution with merging makes SymFC faster and more scalable. On average, we report a 6.25x speedup over G2 on their own benchmark set.

Contributions. In summary, we make the following contributions:

  • A new configurable symbolic semantics for SymFC that allows us to represent arbitrary values and types symbolically.
  • A notion of embeddings as coercions that allows us to customize symbolic semantics by reusing Haskell's coercion infrastructure.
  • Merging rules for symbolic expressions in our calculus which keep constraint sizes low.
  • An implementation of SymFC as a GHC plugin.
  • An evaluation that shows that SymFC covers a wide range of language constructs and libraries, and performs better than existing work.

References (14)