Manuscript Offprint
arXiv:2611.07916SymFC: Configurable Semantics for All Paths Symbolic Execution in Haskell via Embeddings
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.
Properties as Haskell Functions. A property in SymFC is a Haskell function that returns SMT Bool, the symbolic Boolean type. The function's arguments are the symbolic inputs; SymFC generates a fresh symbolic value for each argument when it begins execution. A property is attached to the theory it should be checked under via an annotation pragma. As a first example, consider verifying that inserting a key into a Data.Map and immediately looking it up returns the inserted value:
1 {-# ANN mapLookupInsert (Theory embeddings) #-} 2 mapLookupInsert :: Int -> Int -> SMT Bool 3 mapLookupInsert k v = 4 SMT boolean $ Map.lookup k (Map.insert k v Map.empty) == Just v
The Theory embeddings annotation selects the built-in embedding set, which provides symbolic interpretations for GHC's numeric primitives. The body is ordinary Haskell: Map.insert, Map.lookup, and (==) are the real library functions from Data.Map.Strict. The SMT boolean function lifts a concrete Bool result into the symbolic domain, asserting that the expression must hold for every possible k and v. Verification is triggered at compile time and its result can be retrieved at runtime with a Template Haskell splice:
1 $(symFC 'mapLookupInsert) shouldBe Nothing
The splice expands to the Z3 result at compile time. If the property is valid, it evaluates to Nothing; if it is invalid, it evaluates to Just counterexample.
Counterexample Generation. SymFC produces counterexamples for invalid properties. Consider the following broken variant, which asserts membership without the necessary precondition that the two keys are equal:
1 {-# ANN mapMemberWrongKey (Theory embeddings) #-} 2 mapMemberWrongKey :: Int -> Int -> Int -> SMT Bool 3 mapMemberWrongKey k1 k2 v = 4 SMT boolean $ Map.member k1 (Map.singleton k2 v)
SymFC finds a counterexample immediately and returns it as a Just at compile time. The counterexample is a list of (name, value) pairs mapping each argument name to a pretty-printed string of the concrete value that falsifies the property, in this case, [("k1", "0"), ("k2", "1"), ("v", "0").] Whenever the SMT solver finds a satisfying assignment that violates the property, SymFC reconstructs the concrete input values and surfaces them to the developer.
Symbolic Algebraic Data Types. SymFC is not limited to primitive types. It can symbolically execute code that operates over arbitrary algebraic data types (ADTs), including recursive ones. The Data.Map.Strict and Data.Set properties in the example above illustrate this: both structures are internally balanced binary trees (weight-balanced trees), implemented in roughly a thousand lines of Haskell. SymFC Symbolically executes the actual tree operations: insert, delete, rotations, rebalancing, exploring all execution paths through the full implementation. No specialized embeddings or abstract models for the container types are required; SymFC works directly on their source code.
Embeddings. Symbolic execution of the full implementation is not always desirable. For types implemented via foreign primitives or IO, the source code is unavailable or too low-level to execute symbolically. For types with rich SMT theories such as bitvectors or strings, a direct abstract encoding is far more efficient than re-deriving the same facts by executing thousands of lines of library code. SymFC addresses this with coercions as embeddings: user-supplied mappings from a
Haskell type or function to an alternative interpretation. For example, a common embedding is that of the base Haskell Integer to the SMT solver primitive SMT.Integer, which starts by specifying exactly this mapping.
1 Integer → SMT.Integer
The mapping exposes a local instance of Coercible: the standard Haskell typeclass which witnesses that two types are (representationally) equivalent. We can use this local witness to give an embedding of the Integer addition operation plusInteger:
1 plusEmbed :: Coercible Integer SMT.Integer 2 => Integer -> Integer -> Integer 3 plusEmbed = coerce SMT.addInteger
Here, we coerce the SMT.Integer addition to operate over values of type Integer. The instance of Coercible allows us to safely convert between values of type Integer and SMT.Integer. With this, we can create a well-formed embedding:
1 plusInteger → plusEmbed
SymFC will provide the Coercible instance to plusEmbed, after which its type matches up exactly to that of plusInteger.
Multiple Embeddings. Most symbolic execution frameworks allow at most one embedding per type: at worst only a handful of hardcoded built-in interpretations (e.g. G2 [15]), at best a single user-defined mapping to an SMT primitive (e.g. LiquidHaskell [29]). SymFC lifts this restriction by scoping embeddings per property. Multiple embeddings can be composed by the monoid operation and selected independently for each property:
1 {-# ANN example (Theory (textAsSMTString <> int64AsBitVec64)) #-} 2 example = ...
This per-property scoping matters because there is often no single correct embedding for a type. Consider the Text type from the text library. A library user verifying their own code wants Text → SMT.String: SMT solvers provide a dedicated string theory that can reason about string operations natively, and this is by far the most efficient encoding available. Without the embedding, symbolic execution would have to unfold every string operation into the low-level array allocations and pointer dereferences that underlie Text's implementation, which quickly becomes intractable. The library author verifying the text implementation itself wants the opposite: embedding Text as an SMT string would hide the very behavior they are trying to check. Both are valid; SymFC accommodates both by letting each property declare its own embedding.
Unrestricted Embeddings. Another restriction commonly imposed on embeddings is that they can only map directly to SMT types and functions. Lifting this restriction opens up a wide variety of ways to model types which would otherwise be unsupported. A concrete example is the bitvector type in the C@aSH library [2]. Clash.BitVec n can range over any natural n, including zero, whereas SMT.BitVec n requires n to be positive, so a direct embedding is incomplete. Instead, we can define Wrap.BitVec n, which uses SMT.BitVec n for all positive sizes and a unit constructor for the zero-sized case:
1 data Wrap.BitVec n where 2 BitVecZero :: Wrap.BitVec 0 3 BitVecPos :: 1 ≤ n => SMT.BitVec n -> Wrap.BitVec n
BitVecZero can only be instantiated when is zero; BitVecPos carries the evidence that alongside a primitive SMT bitvector. We can then embed Clash.BitVec as Wrap.BitVec , which is both complete and uses the SMT solver primitive whenever the size is positive.
Embedding IO. The same principle lets us model IO in SymFC. Here RealWorld#, the GHC token that sequences IO operations, is embedded as heap of type IntMap Any: a map that may contain a value of any type.
1 RealWorld# IntMap Any
This heap can be indexed with a value of type Int, resembling a pointer. As such, the mutable reference type IORef can be modeled by this pointer into our heap accordingly:
1 IORef a Int
With these type embeddings, we can embed the IORef operations newIORef, readIORef and writeIORef as a set of functions that manipulate this heap using its pointer. No special solver support is needed to embed IO: the model is written entirely in Haskell. We will describe these embeddings in full detail in § 5.
3 Theory
We will now describe our core language SYMCORE, which is based on System FC [26]. We formalize a lazy, symbolic reduction semantic of SYMCORE. Compared to G2 [15, 16], we show how to generalize symbolic representation not just to SMT primitives, but to full expressions in the language. G2's restriction to symbolic base types forces it to perform a search over branches (i.e., enumerating execution paths), which SymFC can avoid. Instead, SYMCORE allows symbolic representation of expressions of any type. This lets us merge common prefixes across expressions, allowing us to represent multiple paths at once.
3.1 Language
We define SYMCORE's syntax in Figure 1; SYMCORE extends System FC with additional constructs for symbolic representation. It features standard lambda calculus constructs such as variables, literals, data constructors, lambda abstractions, function applications, case expressions and types. The literals and primitive operations supported by SYMCORE mirror those found in SMT solvers. For example, SYMCORE supports the literal of type SMT.BitVec 8 and the primitive bitvector addition operation SMT.bvadd.
Cast and Coercion. The defining feature of System FC compared to System F is the introduction of a type safe cast e , which uses a coercion to convert the type of a term. A coercion is a witness of type equality between two types and is captured by the following judgement.
This judgement says that witnesses an equality between types and . In this paper, we will mainly focus on coercions whose role is (representational), which tells us that a type have the same memory layout at runtime [4]. Traditionally, the kind says that the kinds of the coercible types and are equivalent. We will relax this constraint slightly to permit coercions between different kinded types that are safe under symbolic evaluation, as we will elaborate on in § 4.2. We can cast expression e of type with coercion to an expression of type , written e . Both the cast operation e as well as coercions are valid expressions in SYMCORE.
Branching. SYMCORE supports branching through case expressions. Case expressions case e of operate on algebraic data types which are constructed using data constructor D. During evaluation, the expression e is matched to any of the patterns in of the form . If any pattern

Fig. 1. Expressions in SYMCORE.
matches, the right-hand side is evaluated. The arguments in to data constructor are bound to the variables in the evaluation of .
SYMCORE additionally exposes a specialized form of branching with the symbolic expression if then else , following the ordered guards representation introduced by Grisette [21]. Unlike a case expression, the branch condition can only contain expressions of type SMT Bool. The conditional remains symbolic during evaluation, which allows us to represent symbolic expressions as cascading trees of concrete expressions. During evaluation, we merge common sub-expressions in leaves of the tree. To illustrate, the expression if then else can be merged with the expression (if then else ) as the expressions share the same data constructor .
Bottom. Bottom values refer to computations that never complete successfully. Like Haskell, we support error calls through raise as an impure error throw. Diverging computation due to an infinite loop is a bottom value, but does not require a definition of its own. We introduce two new values that have similar behavior to these bottom values during evaluation. Bottom value , which we refer to as unreachable, represents a path that cannot be reached. Unreachable can show up naturally through path pruning. In a similar spirit, bottom value ? denotes undefined behavior. Undefined behavior shows up through reduction if a data constructor does not match any pattern. The bottom values and ? respectively allow us to naturally define assumptions and assertions within expressions. For example, to assume predicate holds in the evaluation of , we can introduce a conditional with in its false branch: if then else . As a consequence, the reduction semantic of SYMCORE does not require a global store of assertions and assumptions; these are directly represented inside the symbolic expression.
3.2 Reduction
Next, we will define a lazy, symbolic reduction semantic for SYMCORE with the judgement:
Here, is a path condition used to prune unreachable expressions and is the substitution environment used for variable lookup. The path condition is a Boolean statement expressed solely in
Fig. 2. Environments used in the reduction of SymCORE.
SMT solver primitives. The substitution environment contains a mapping from variables to closures, consisting of an expression together with their environment. Figure 2 shows their definition. Judgement reduces expression to weak head normal form (WHNF) [23] expression .
WHNF. The WHNF of expressions in SymFC differs from the standard definition for System FC: it allows including symbolic expressions in its head. The symbolic expressions are restricted to contain only SMT solvable primitives. An expression is solvable if it satisfies the following predicate.
Symbolic variables are the only free variables that occur during evaluation. For this reason, we can check whether a variable x is symbolic in environment with the predicate . Using solvable, we can define what it means for a SymFC expression to be in WHNF as follows:
Rules. We present the reduction rules of SymCORE in Figure 3. Almost all reduction rules are standard: they follow the same evaluation as System FC. For example, the head or spine of an application is first reduced via App–Spine after which we might find a primitive reduction which we can reduce via App–Prim. Unlike System FC, the primitive reduction may remain symbolic. The call to reduce–prim in App – Prim permits optimization of symbolic values e.g., constant folding.
Case Split. The key difference between reduction in SymCORE and System FC is in case expressions. Instead of pattern matching a single data constructor, an expression in SymCORE may match
Fig. 3. Reduction rules of SYMCORE.
multiple. Rule Case evaluates the scrutinee, merges it and then folds over all its branches as follows:
Any branches are recursively traversed. If we find a data constructor at a leaf, we find the matching alternative and reduce it. Bottom values simply get propagated. If the expression does not match any of these cases, this is considered undefined behaviour.
Merge. Naively pattern matching and evaluating all branches of our cascading if-then-else expression is problematic: this just enumerate all paths. Instead, we want to merge common prefixes before pattern matching. Merging data constructors is particularly important as it restricts the evaluation to reduce every alternative in a case expression at most once. The full merging algorithm of ordered guards as defined in [21] is out of scope of this paper. Instead, we will define solely how to merge common prefixes of expressions. To sort the leaves in the ordered guards representation, both trivially and arbitrarily we can pick a total ordering for expressions. We define the expression merging of two leaves in the following way:
We merge only the head of a WHNF expression: any remaining inner expression is left simply as a branch. As discussed before, a matching data constructor between the two branches allows us to push the conditional statement into its arguments. We allow for SMT theory specific optimisation of branches via reduce-prim. A lambda can be merged if its binding variable matches and a cast can merge if its coercion matches, the latter also merging its body. Concrete types, coercions and bottom values are only merged if they are exactly equivalent. If no prefix of the expression matches, then we simply retain the expression as a branch.
Prune. Prune allows the evaluator to stop evaluating a branch early by concluding that the path is unreachable. If a branch is unreachable, we can just return 0 for its reduction. As per the merging of expressions described above, 0 paths are merged, which reduces constraint size considerably.
4 Implementation
SymFC is a full-path symbolic evaluation for GHC Core. We implemented SymFC as a GHC plugin that can check validity of a Boolean valued Haskell statement. SymFC is written in ~8000 lines of Haskell code, and uses the Grisette library for both its ordered guards merging algorithm and its primitive symbolic data types. We will now first discuss the internals of the symbolic evaluator. We then explain embeddings and their implementation in more detail.
4.1 Evaluation
Primitives. In SymFC, primitive SMT theories are exposed via a set of built-in types and operations.
1 data SMT Bool = ... 2 data SMT.BitVec (n :: Nat) = ... 3 data SMT.Array k v = ... 4 5 SMT.and :: SMT Bool -> SMT Bool -> SMT Bool 6 SMT.bvadd :: SMT.BitVec n -> SMT.BitVec n -> SMT.BitVec n 7 SMT.select :: SMT.Array k v -> k -> v
The functions have a built-in interpretation in SymFC which binds them to their respective SMT operations during symbolic evaluation. As a convenience, the SMT primitives exported by SymFC also have a Haskell implementation that reflects their operations. This way, a user can execute their Haskell code using these primitives after receiving a satisfying instance from the solver. Exposing the primitives in this way is a deliberate choice over deploying them through Haskell primitive types. To illustrate, it is more convenient in embeddings to have SMT.BitVec available directly compared to Int8#, Int16#, etc. In fact, even primitive types might require a different embedding based on the verification task and SymFC places no such restriction in this way.
Primitive Optimisation. To keep symbolic evaluation fast, SymFC employs lightweight, but effective rewrites of primitive types, which it inherits from Grisette. This technique is not novel, but it is an effective way to reduce constraint size. The most straightforward of these is constant folding, e.g. we rewrite SMT.bvadd 6 5 ↔ 0xb. As ordered guards style merging often introduces large compound conditionals, we have observed that boolean rewrites such as x ∧ (¬x ∨ y) ↔ x ∧ y are vital to keep branch conditions small.
4.2 Embeddings
Embeddings come in two flavors: type embeddings and term embeddings.
- Type Embeddings dictate what the representation of a type should be during symbolic execution. Each type embedding produces a coercion which witnesses that two types are (representationally) equivalent.
- Term Embeddings allow us to define an alternative implementation for a function during symbolic execution.
There is an important interplay between type and term embeddings: term embeddings consume the type equality witnesses produced from type embeddings. This coercion witness allows a term embedding to safely cast values to their symbolic interpretation. We will show how to check consistency of user defined type and term embeddings at compile time.
Invocation. Embeddings should be local to each invocation as every verification task might require different, incompatible embeddings. To support this, SymFC allows every invocation to pass in an Embedding data type that carries exactly this information. Below we give an example invocation.
1 embedding :: Embedding
2 embedding = ...
3
4 { -# ANN example (Theory embedding) #-}
5 example :: SMT Bool
6 example = ...
The embedding is just a normal Haskell value that we pass to SymFC via an annotation. The data type Embedding is defined as a record that contains a list of type-, and term-embeddings.
1 data Embedding = Embedding
2 { typeEmbeddings :: [TypeEmbedding]
3 , termEmbeddings :: [TermEmbedding]
4 }
Coercible. Haskell does not directly expose syntax to construct a cast. Instead, it exposes the function coerce which internally casts its argument into a different type.
1 coerce :: Coercible a b => a -> b
The coercion witness that ensures the cast is well-founded, is provided by the typeclass Coercible. It is sufficient to view Coercible as a coercion which is passed to a function at call site automatically if requested by its type signature. The typeclass for Coercible is defined as follows, and its sole purpose is to carry coercion instance a ~_R b.
1 class a ~_R b => Coercible (a :: k) (b :: k)
A coercion a ~_R b says that type a and b have the same representation (i.e. memory layout at runtime), though they are not the same type. To illustrate, we can define a data type Age as a newtype of Int.
1 newtype Age = MkAge Int
This creates the coercion Age ~R Int, which ensures the typeclass instance Coercible Age Int exists. As long as MkAge is in scope, we can safely coerce between Age and Int as follows:
1 convert :: Age -> Int 2 convert x = coerce x
The instance Coercible Age Int is implicitly passed into the call to coerce.
Type Embeddings. Type embeddings denote what representation a type should have during symbolic execution. We point out the similarity to a coercion and thus implement type embeddings as local, user-defined instances of Coercible. For example, to denote that Int64# should behave as an SMT.BitVec 64 during symbolic execution, we would want to have the following instance available.
1 instance Coercible Int64# (SMT.BitVec 64)
Instances of Coercible cannot be provided in this way, for two reasons.
(1) User defined instances are not well-founded outside of symbolic evaluation. For example, coercing between Int64# and SMT.BitVec 64 in the Haskell runtime would quickly turn into undefined behavior as these types are not actually representationally equivalent in this context.
(2) A fixed, global instance for embeddings is undesirable as the choice which embedding to use changes depending on the verification goal.
Instead, we expose the data type TypeEmbedding which contains the two types for which SymFC can conjure an instance of Coercible. It can be passed to SymFC as part of an Embedding, which ensures the instances remain local to each invocation of the symbolic evaluator.
1 data TypeEmbedding = TypeEmbedding 2 { originalType :: Type 3 , interpretationType :: Type 4 }
Term Embeddings. A term embedding replaces a function call with a new definition. To be well-formed, the type of the new definition should match the original function call exactly: we do not know how to call the new definition in place of the original otherwise.
For example, if we want to give an alternative definition of plusInt64# then we need to provide a function that has the same type Int64# -> Int64# -> Int64#. In this restrictive setting, we cannot actually give it the interpretation of using SMT.bvadd: the types simply do not match.
To resolve this issue, we are allowed to use any of the local type embeddings that we have in our context. Thus, we can define a term embedding for plusInt64# as follows:
1 plusEmbed :: Coercible Int64# (SMT.BitVec 64) 2 => Int64# -> Int64# -> Int64# 3 plusEmbed = coerce SMT.bvadd
The type embedding instances are passed to the term embeddings before checking type equivalence of the definitions. That is, we first augment plusEmbed by giving it an instance of Coercible Int64# (SMT.BitVec 64), after which its type matches exactly with plusInt64#. We provide a data type TermEmbeddings that can be passed to SymFC as part of an Embedding.
1 data TermEmbedding = TermEmbedding 2 { originalTerm :: Var 3 , interpretationTerm :: Var 4 }
Runtime Representation. Haskell exposes the notion of runtime representations of types, which encodes how a type is represented at runtime. The runtime representation of a type is encoded in its kind. For example, the Int64# data type has kind TYPE Int64Rep, where TYPE is a kind constructor for inhabited types and Int64Rep is the runtime representation that says that its inhabitants are represented as a 64-bit integer. Almost all types, including SMT.BitVec64, have the kind TYPE LiftedRep, which says it is represented by a pointer to memory.
Haskell uses runtime representations during code generation: at runtime, code is specialized to work only on the expected runtime representation. Types with different runtime representations should not mix as this would cause undefined behavior. As such, Haskell enforces that any usage of Coercible has type arguments whose kinds match. An unfortunate consequence is that Haskell rejects the type signature of plusEmbed due to this restriction: the runtime representation Int64Rep is not equivalent to LiftedRep.
SymFC implements all types in a way that is closest to LiftedRep. We do not care about the same runtime representations during symbolic evaluation as during normal evaluation. Thus, it is sound to allow user defined coercions between types that have different runtime representations: under symbolic evaluation, their representation is equivalent.
The ideal solution would be to define a typeclass Embeddable that permits coercions between types with different kinds, together with an embed function that uses these coercions.
1 class a ~R b => Embeddable (a :: k1) (b :: k2)
2 embed :: forall (a :: TYPE r1) (b :: TYPE r2). Embeddable a b => a -> b
This does have a major downside: we do not get the typeclass instances of Coercible that Haskell normally defines for free. While we could implement a typechecker plugin that inserts these instances, we opted for a simpler approach in terms of implementation effort. We define a data type Embed that witnesses an equality between the kinds of its type arguments, together with the coercion between the two type arguments.
1 data Embed (a :: k1) (b :: k2) where
2 HCoerc :: forall k1 (a :: k1) (b :: k1). Coercible a b => Embed a b
The data constructor HCoerc limits the types a and b to have the same kind unlike its type definition. This definition compiles to a data constructor that additionally carries the coercion k1 ~N k2, which says that the kinds are nominally equivalent (i.e. are exactly the same). We can supply a white lie: a coercion that witnesses Int64Rep is the same type as LiftedRep. Using this, we can convince Haskell to use this coercion instance in the final embedding, where we pattern match on HCoerc to bring the heterogeneous coercion into scope.
1 plusEmbed :: Embed Int64# (SMT.BitVec 64) -> Int64# -> Int64# -> Int64#
2 plusEmbed HCoerc = coerce SMT.bvadd
Literals. As illustrated, SymFC permits Haskell primitive types such as Int64# to be embedded as any arbitrary type. This freedom makes the translation of literals in Haskell ambiguous. To illustrate, consider the following example where we define a constant of type Int64#.
1 four :: Int64#
2 four = 4#Int64
How should SymFC translate this primitive from GHC Core to SymCore? Of course, one might argue that it is straightforward given the embedding SMT.BitVec 64. This is not the only embedding possible. Another reasonable, though somewhat roundabout, embedding stores the high and low bytes of the value separately in a tuple (SMT.BitVec 32, SMT.BitVec 32). In general, there is no single way that this literal could be encoded into its embedded type. To solve this, we allow users to specify this translation instead. In the case of Int64#, a user may provide an embedding for the following function:
1 fromLitInt64# :: SMT.BitVec 64 -> Int64#
That is, we pick a lossless representation for each literal, in this case SMT.BitVec 64, from which a user can convert into their embedded type of choice. For illustrative purposes, we use embedding Int64# ↔ (SMT.BitVec 32, SMT.BitVec 32) in the following example.
1 fromLitInt64E :: Embed (SMT.BitVec 32, SMT.BitVec 32) Int64# 2 -> SMT.BitVec 64 -> Int64# 3 fromLitInt64E HCoerc bv = 4 let top = SMT.bvslice @63 @32 bv 5 bot = SMT.bvslice @31 @0 bv 6 in coerce (top, bot)
Of course, we expect almost all use cases to want to embed the sized integer and word primitives of Haskell to the bit vector of their respective size, e.g. Int64# ↔ SMT.BitVec 64. For this purpose, SymFC exposes a set of standard embeddings that do just this.
Type Instantiation and Subsumption. In our term embeddings, we often found we defined the same implementation under different types. For example, we provide standard embeddings for literal conversions for primitives Int8#, Int16#, Word8#, etc. All of which are an instance of the same function:
1 fromLitBV :: Embed a (SMT.BitVec n) -> SMT.BitVec n -> a 2 fromLitBV HCoerc bv = coerce bv
Without an implementation for type instantiation, we would have to define many stubs:
1 fromLitInt8 :: Embed Int8# (SMT.BitVec 8) -> SMT.BitVec 16 -> Int8# 2 fromLitInt8 = fromLitBV 3 4 fromLitInt16 :: Embed Int16# (SMT.BitVec 16) -> SMT.BitVec 16 -> Int16# 5 fromLitInt16 = fromLitBV 6 ... -- Int32#, Int64#, Word8#, etc.
To greatly reduce boilerplate, we implemented type instantiation and subsumption for term embeddings. For embedding fromLitInt8# with fromLitBV, only type instantiation is required: we can instantiate the type variable n with the type level natural 8. Apart from the right-hand side type requiring to match, the type and typeclass arguments of an interpretation need to match its original exactly. For example, the following two functions cannot be called in the same way:
1 orig :: forall a b. Show b => Eq a => a -> b -> b 2 interp :: forall b a. Eq a => a -> b -> b
That is, interp first expects an instance for type variable b to be provided while orig first expects type variable a. A similar problem arises with the typeclasses. Although in this case the interp does not require an instance for Show b. Of course, we can call interp wherever orig can be called, but it requires some reordering of the arguments of interp. This argument reordering is known as subsumption. Below, we sketch the algorithm for matching an interpretation to its original.
(1) Strip forall quantifiers and typeclass constraints from both the original and embedded term. Try to find a type instantiation of the interpretation that matches it to the original using the stripped types. Apply the type instantiation to the interpretation.
This includes arguments of type Embed, which we treat as a typeclass constraint in this algorithm.
(2) Try to instantiate all typeclass instances of the interpretation that do not occur in the original term. We use the existing typeclass instance environment, extended with the type embedding instances of Coercible for this instantiation.
(3) Close the interpretation such that its typeclass and type arguments match the original term. We report an error to the user whenever we try but fail to perform a step in the algorithm.
Overlapping Embeddings. Type embeddings can overlap. Consider the following embeddings:
1 instance Coercible [a] (SMT.Seq a) 2 instance Coercible [Char] (SMT.String)
Individually, these are perfectly reasonable embeddings: a list should be modeled as an SMT theory of sequences and a list of characters as the SMT theory of strings, respectively. Together however, these instances are overlapping: [Char] has an instance for both declarations. These instances allow multiple representations of [Char], which is disastrous as this enables us to write expressions with undefined behavior. To illustrate, we can coerce a value of type SMT.Seq Char to a value of type SMT.String, by first coercing to [Char] as an intermediate step.
1 overlapping :: SMT.Seq Char -> SMT.String 2 overlapping x = let y = coerce x :: [Char] in coerce y
SymFC would crash if we were to use this: SMT.Seq and SMT.String do not share the same representation! Worse, the reason why this crash occurs would be rather opaque as the cast itself is not what triggers an error, the type confusion that occurs from using the result would.
Luckily, this problem is not restricted to the setting of Coercible. That is, any typeclass can have overlapping instances and Haskell already provides the most straightforward solution to this problem: disallow it!² Haskell does not check overlaps between typeclass instances on definition. Instead, it is deferred to instance resolution. That is, if Haskell determines that multiple instances can be used to resolve a typeclass constraint at a call site, it will report an error. If no such errors occur, then we do not use any overlapping instance. This is safe even if the declared instances can exhibit overlapping instances.
In SymFC, we follow suit and report overlap on instance resolution only. That is, if any of the term embeddings require an instance of Coercible for which multiple instances exist, we can simply report an error. We reuse the instance resolution that is already provided by GHC for this purpose.
Term Coherence. In the translation of GHC Core to SymCORE, we need to be considerate of type embeddings. Type embeddings do not only introduce coercion witnesses, they also invalidate the original data constructors of the types they embed. We wish to stress the asymmetry here: constructors of the original type are invalidated while the target type retains its representation. Any occurrence of the original data constructor (or coercion instance for newtype definitions) will raise an error by default.
It is possible still to write an embedding for the data constructors of an embedded type. That is, the embedding would construct an instance of the interpretation type from the arguments of the original data constructor. Although unimplemented, SymFC could also accept a destructor, which should reconstruct the fields of its data constructor, as a way to permit pattern matching on an embedded data type using its original data constructors. We have found that these would not really see use however: if the embedding permits this implementation, then we could also not have used an embedding at all.
²Haskell weakens this restriction by allowing overlapping instances in a very controlled setting, this is never a good idea with instances of Coercible however.
Lightweight. The embedding functionality in SymFC is extremely lightweight. It is implemented in ~500 lines of Haskell code. This is because almost all functionality can reuse the existing GHC codebase for their implementation. Users do not need to learn a new language to write embeddings: instead their definition can even sit right next to the code they verify.
5 Case Study
Initially, the goal for embeddings as implemented in SymFC was to allow users to write embeddings directly in Haskell. That is, to not have a separate language for defining an interpretation for function definitions. Interestingly, the method turns out to be more universal: we can model any piece of Haskell code as another, usually one more scalable for symbolic execution.
5.1 ClambdaSH
ClambdaSH is a hardware description library that allows us to write circuits within Haskell. To support a translation from Haskell to other hardware description languages such as VHDL, Verilog or SystemVerilog, ClambdaSH exposes a few hardware level primitives. The most ubiquitous being the bit vector primitive Clash.BitVec n. To allow simulating circuits in Haskell, these bit vector types are implemented using the unbounded integer type Integer. If we were to run SymFC on these directly, it would not be able to support a large class of its operations: the SMT theory of integers does not support bitslicing or concatenation. Even for operations we can support in this way, it will be a lot slower than interpreting these as SMT.BitVec n directly. In this case study, we will show how to write bit vector embeddings for Clash.BitVec n. This requires a bit more work than one might suspect: SMT.BitVec n does not support zero-sized bit vectors, while Clash.BitVec n does.
Zero Sized Bit Vectors. The SMT theory of arrays does not support zero sized bit vectors. This constraint shows up in the type signature of SMT.BitVec operations as the typeclass .
1 SMT.bvadd :: 1 ≤ n => SMT.BitVec n -> SMT.BitVec n -> SMT.BitVec n
On the other hand, Clash.BitVec supports all bit vector sizes is evident by the lack of size constraints on its operation such as addition.
1 Clash.bvadd :: Clash.BitVec n -> Clash.BitVec n -> Clash.BitVec n
If we try to write this embedding as is, Haskell will complain about the missing instance .
1 bvaddE :: Coercible SMT.BitVec Clash.BitVec 2 => Clash.BitVec n -> Clash.BitVec n -> Clash.BitVec n 3 bvaddE = coerce SMT.bvadd 4 ^^^^^^^^^^ -- missing constraint 1 ≤ n
Indeed, we cannot guarantee that we did not receive a zero sized bitvector in this call. The rejection is proper: SymFC would crash upon reaching a zero sized addition, if this definition were accepted.
Wrapper Bit Vector. To overcome this, we define a wrapper bit vector data type Wrap.BitVec which is either a zero sized bit vector, or has a positive size and thus carries an SMT.BitVec.
1 data Wrap.BitVec n where 2 BitVecZ :: Wrap.BitVec 0 3 BitVecP :: 1 ≤ n => SMT.BitVec n -> Wrap.BitVec n
The instances of Wrap.BitVec are mutually exclusive. The data constructor BitVecZ carries coercion evidence , which says that n is exactly equivalent to . The data constructor BitVecP carries
We omit the KnownNat constraint on Clash.bvadd as it is unimportant with respect to the embedding.
the evidence that , together with a primitive SMT bit vector. We can define addition for this type without constraining the bit vector size.
1 Wrap.bvadd :: Wrap.BitVec n -> Wrap.BitVec n -> Wrap.BitVec n 2 Wrap.bvadd BitVecZ BitVecZ = BitVecZ 3 Wrap.bvadd (BitVecP lhs) (BitVecP rhs) = BitVecP (SMT.bvadd lhs rhs)
With this, we instead want to embed our original ClambdaSH type Clash.BitVec as the wrapped instance Wrap.BitVec. We can define the term embedding for Clash.bvadd using Wrap.BitVec.
1 bvaddE :: Coercible Wrap.BitVec Clash.BitVec 2 => Clash.BitVec n -> Clash.BitVec n -> Clash.BitVec n 3 bvaddE = coerce Wrap.bvadd
Embedding. We gather the embeddings in the data type Embedding which may be passed SymFC whenever it is invoked.
1 embeddingBitVec :: Embedding 2 embeddingBitVec = Embedding 3 { typeEmbeddings = [ Clash.BitVec ↔ Wrap.BitVec ] 4 , termEmbeddings = [ Clash.bvadd ↔ bvaddE, .. ] }
Of course, we need to extend the embedding with more bit vector operations, e.g. multiplication, concatenation, selects, shifts, etc. Luckily, these are rather straightforward to provide using the type Wrap.BitVec. With all of these operations embedded, we are able to symbolically evaluate ClambdaSH circuits.
5.2 Modeling IO
We can also use embeddings to model IO operations in SymFC. We discuss the embedding of IORef, which provides safe, mutable pointers in Haskell. Though IORef exposes only three primitive operations, this style of embedding can be used to embed other IO operations in the exact same way. Before we can discuss how we use embeddings to model lazy IO, we first need a deeper understanding of the implementation of the IO monad in Haskell.
Laziness and Impurity. Let us first discuss the problems that arise with naive impurity in a lazy language. Consider the function getChar, a staple function in eager, impure languages which fetches a character from the standard input stream of the program and is defined with the following type signature:
1 getChar :: Char
We define the following toy function to fetch a three character string from the input stream:
1 get3Char :: [Char] 2 get3Char = [getChar, getChar, getChar]
Let us run a few examples, all of which are run with the input string "abc" in our standard input stream. To start off, we will run get3Char as is.
1 > get3Char 2 $ ['a', 'b', 'c']
Perfect! Although, getting this result is a coincidence as we happened to evaluate the list in this order, while printing. Somewhat surprisingly, if we recompute get3Char, reverse its result and then print it, we get the same list as before.
1 > reverse get3Char 2 $ ['a', 'b', 'c']
This happens because we evaluate the last call to getChar in get3Char first when the expression is printed. Even more startling, Haskell may decide that calling getChar three times is obsolete: as an optimization, we can simply share the computation. This is reasonable in a pure language as the same computation run twice should always produce the same result in both evaluations. If we enable the common subexpression elimination optimization, the end result is counterintuitive at best.
1 > get3Char 2 $ ['a', 'a', 'a']
What's worse, we can argue for the correctness of all these results: the real culprit is this direct impurity in a lazy language.
IO Monad. As illustrated, the introduction of impurity in a lazy language in this way is undesirable. To avoid this issue, Haskell introduces the notion of RealWorld#: a simple unit data type of which only a single instance exists per execution. The idea is straightforward: an operation will only perform IO once it gets hold of this RealWorld# token. Once the operation is finished, it passes the token to the next operation, which will perform IO in its turn before passing the token, and so forth. We can use this idea to define an alternative version of getChar as follows.
1 getChar :: RealWorld# -> (RealWorld#, Char)
With this, we can define a clear, unambiguous ordering for our definition of get3Char.
1 get3Char :: RealWorld# -> (RealWorld#, [Char])
2 get3Char w0 = let (w1, c0) = getChar w0 ; let (w2, c1) = getChar w1
3 let (w3, c2) = getChar w2 in (w3, [c0, c1, c2])
Passing around the RealWorld# token gets old rather quick. Luckily, we solve this by abstracting the token passing in the IO monad.
1 newtype IO a = IO (RealWorld# -> (RealWorld#, a))
The monadic bind operation (>>=) performs the token passing as we did manually in get3Char.
Embed RealWorld#. Back to SymFC, our goal is to model impure computation during symbolic evaluation. The core idea is simple: we embed RealWorld# to contain the outside world that we model, defined as data type ModelWorld. The contents of ModelWorld follow from the IO operations we are trying to describe. For now, we will restrict ourselves to modeling the IORef data type and its operations, which is responsible for safe, mutable pointers in Haskell.
IORef. The IORef a data type is internally a pointer to the heap storing a value of type a. It supports three primitive operations which allows us to create, read from and write to an IORef, respectively:
1 newIORef :: a -> IO (IORef a)
2 readIORef :: IORef a -> IO a
3 writeIORef :: IORef a -> a -> IO ()
As Haskell retains getChar in constant applicative form (CAF), the list in the example would actually only contain the character 'a'. For illustrative purpose, we assume it does not memoize the result as a CAF.
We simplify the type slightly by not using an unboxed tuple: boxing is only used for performance.
Robin Webbers, Wind Wong, and Klaus von Gleissenthall
To illustrate its usage, here is a toy example where we initialize an IORef with an integer of value 5. We then read it, increment and store its value, and then re-read it.
main = do ref <- newIORef (5 :: Int) val0 <- readIORef ref -- val0 == 5 writeIORef ref (val0 + 1) val1 <- readIORef ref -- val1 == 6
Heap Model. To model IORef, we need to support allocations inside of ModelWorld. We can model this with an IntMap Any that tracks allocations i.e., a heap. To support heterogeneous allocations, we store the values as an Any type: an opaque type that may be coerced to from any other type. We coerce values of type Any back to their original type during reads of an IORef. Every allocation gets a new unique allocation identifier (i.e., a pointer) of type Int. We generate these identifiers by reading and incrementing the current size of the heap, in the style of a bump allocator. The identifiers as well as the heap itself remain concrete, which keeps the lookups fast.
newtype ModelWorld = ModelWorld (IntMap Any)
We embed the type IORef a as an Int: this is the pointer into our heap. With these type embeddings, we can implement the term embeddings for functions newIORef, readIORef and writeIORef.
Allocation. Let us start with newIORef. We fetch a unique identifier, which we obtain by taking the length of the current heap. Afterwards, we insert the initial element for this entry into the heap and return the updated world, together with the identifier that references the entry. Note that we erase the type of the initial value by coercing it using toAny. We define a function of type IntMap Any -> (IntMap Any, Int) which takes the current heap and produces a new heap and identifier. As both IO and ModelWorld are newtypes, we can coerce this expression directly to the required type IO (IORef a).
newIORefE :: Coercible (IORef a) Int => Embed RealWorld# ModelWorld -> a -> IO (IORef a) newIORefE HCoerc init = coerce \heap0 -> let ref = length heap0 heap1 = insert ref (toAny init) heap0 in (heap1, ref)
Read. Next, we will embed readIORef. To support reads, we will have to reify the type of a value in our heap. That is, our heap stores heterogeneous values of the opaque type Any, which is achieved by casting the original values to this type. This coercion is only safe because Any supports no operations. Coercing back to the original type however requires the usage of unsafeCoerce, which, as the name suggests, conjures an unsafe coercion witness to perform a cast. Fortunately, the type parameter on IORef a provides a safety mechanism: every IORef a allocates a value of type a. As such, this also holds true for the unique identifier Int as which an IORef a is embedded. With this, we can safely apply unsafeCoerce in our embedding of readIORef. The rest of the embedding is a basic lookup from the heap. The heap itself remains unchanged.
readIORefE :: Coercible (IORef a) Int => Embed RealWorld# ModelWorld -> IORef a -> IO a readIORefE HCoerc = coerce \ref heap -> let elem0 = lookup ref heap :: Any elem1 = unsafeCoerce elem0 :: a in (heap, elem1)
Write. Finally, the embedding for writeIORef is rather straightforward: it is only an update of the heap as we already showed in newIORefE.
writeIORefE :: Coercible (IORef a) Int => Embed RealWorld# ModelWorld -> IORef a -> a -> IO () writeIORefE HCoerc = coerce \ref value heap0 -> let heap1 = insert ref (toAny value) heap0 in (heap1,())
Embedding. All the embeddings we discussed need to be provided to an invocation of SymFC. The following Embedding data structure contains the embeddings required for IORef support, which also doubles as a summary of the case study.
embeddingIORef :: Embedding embeddingIORef = Embedding { typeEmbeddings = [ RealWorld# ↔ ModelWorld, IORef a ↔ Int] , termEmbeddings = [ newIORef ↔ newIORefE, readIORef ↔ readIORefE , writeIORef ↔ writeIORefE ] }
Interestingly, ModelWorld only contains the non-symbolic Haskell data type IntMap. This shows that embeddings are useful, not just for SMT Theories, but for any data type.
5.3 Raw Pointers
The IORef embedding models a single mutable cell: every read or write addresses the entire referenced value, and the reference itself carries no arithmetic. This is enough for IORef, but not for libraries like text and bytestring that are implemented directly on top of Ptr and ForeignPtr: raw, byte-addressable pointers that support arithmetic (e.g. plusPtr, minusPtr and castPtr) and single-byte access (e.g. peek and poke).
Instead, we model an array allocation as a tuple of its size and its content, respectively via the word-sized bitvector SMT.BitVec WordSize and the SMT array primitive SMT.Array (SMT.BitVec WordSize) (SMT.BitVec 8). Array allocations are unique and non-overlapping, just like the references built via our model of IORef. In fact, we will reuse the same ModelWorld for our allocations to build a disjointed map of symbolic arrays, similar to [3]. The Any contained in the heap of our world is coerced to an instance of the array tuple whenever a deference of Ptr Int8 occurs. As the array content itself is modeled via the SMT theory of arrays, we are permitted symbolic indexing: the alias analysis is performed by an SMT solver.
Pointer Representation. We embed Ptr a as a tuple of the allocation identifier into the ModelWorld that matches a symbolic array and an offset into the symbolic array itself.
data ModelPtr a = ModelPtr { ptrId :: Int , ptrOff :: SMT.BitVec WordSize }
We embed ForeignPtr a as just its ptrId. The offset is only assigned once withForeignPtr materializes a concrete Ptr at offset 0.
Allocation. Allocation follows exactly the same bump- allocator pattern as newIORefE: fetch a fresh id by taking the length of the current heap, and insert the new entry under that id. The only difference from newIORefE is what gets inserted: instead of the initial value coerced to Any, we insert a zero-initialized, constant SMT byte array, itself coerced to Any:
1 allocByteStringE :: Coercible (ForeignPtr a) (ModelForeignPtr a) 2 => Embed RealWorld# ModelWorld -> Int -> IO ( ForeignPtr a) 3 allocByteStringE HCoerc n = coerce \heap0 -> 4 let newId = length heap0 5 zeroArray :: SMT.Array (SMT.BitVec WordSize) (SMT.BitVec 8) 6 zeroArray = SMT.constArray 0 7 alloc = (n, zeroArray) 8 heap1 = insert newId (toAny alloc) heap0 9 in (heap1, ModelForeignPtr { ptrId = newId })
No separate allocator, counter, or heap type is needed to support pointers: an allocation is an Any in the same heap IORef already uses, and the only new ingredient is the SMT array stored inside.
Arithmetic. plusPtr, minusPtr, and castPtr never touch the heap at all: they are pure bit-vector operations on ptrOff, or, for castPtr, a pure retype with no runtime effect whatsoever.
1 plusPtrE :: Coercible (Ptr a) (ModelPtr a) 2 => Coercible Int (SMT.BitVec WordSize) 3 => Coercible (Ptr b) (ModelPtr b) => Ptr a -> Int -> Ptr b 4 plusPtrE = coerce \p n -> p { ptrOff = ptrOff p + n }
Because n may be symbolic, so is the resulting ptrOff: no concretization ever occurs, which is exactly what lets SymFC verify properties over symbolic offsets, such as that writes at two distinct symbolic offsets do not alias (§ 6).
Read and Write. peek and poke first lookup the allocation's byte array out of the heap by ptrId, just as readIORefE looks up its value, then unsafeCoerce the result back to an SMT array; only then do they SMT.select/ SMT.store the byte at ptrOff, and insert the updated array back under the same id:
1 peekByteE :: Coercible (Ptr Word8) (ModelPtr Word8) 2 => Embed RealWorld# ModelWorld -> Ptr Word8 -> IO Word8 3 peekByteE HCoerc = coerce \ heap -> 4 let (size, alloc) = lookup (ptrId p) heap 5 bytes :: SMT.Array (SMT.BitVec WordSize) (SMT.BitVec 8) 6 bytes = unsafeCoerce alloc 7 idx = ptrOff p 8 deref = if idx ≥ size then SymFC.UB else SMT.select bytes idx 9 in (heap, deref) 10 11 pokeByteE :: Coercible (Ptr Word8) (ModelPtr Word8) 12 => Embed RealWorld# ModelWorld -> Ptr Word8 -> Word8 -> IO () 13 pokeByteE HCoerc = coerce \p v heap0 -> 14 let (size, alloc) = lookup (ptrId p) heap 15 bytes0 :: SMT.Array (SMT.BitVec WordSize) (SMT.BitVec 8) 16 bytes0 = unsafeCoerce alloc 17 idx = ptrOff p 18 bytes1 = if idx ≥ size then SymFC.UB else SMT.store bytes0 idx v 19 heap1 = insert (ptrId p) (toAny bytes1) heap 20 in (heap1,())
As in readIORefE, the unsafeCoerce back to an SMT array is safe only because every id ever looked up here was inserted by mallocByteStringE, which always stores a value of that same array type: the same per-id type invariant that already justifies IORef's own usage of unsafeCoerce. The ptrOff may be symbolic here, so aliasing questions within a single allocation, such as whether a write through one pointer affects a read through another at a possibly-different offset, are answered by the SMT solver's own array axioms rather than by any logic in the embedding itself. If the pointer read or write is out of bounds of the allocation, we return SymFC.UB which models undefined behaviour as described in § 3. Aliasing across distinct allocations, meanwhile, is decided the same way it already was for IORef: two different, concrete ids name two different heap entries.
Embedding. To summarize, we need the following embeddings for allocations and dereferences.
embeddingPtr :: Embedding
embeddingPtr = Embedding
{
typeEmbeddings = [ Ptr a → ModelPtr a
, ForeignPtr a → ModelForeignPtr a ]
, termEmbeddings = [ plusPtr → plusPtrE
, allocForeignPtrBytes → allocByteStringE
, withForeignPtr → withForeignPtrE
, peekByte → peekByteE
, pokeByte → pokeByteE, ... ]
}
Unlike embeddingIORef, whose heap entries never contain anything the solver needs to look inside, embeddingPtr reuses that same heap outright and pushes only the contents of a pointer entry into SMT, not the heap itself. The price is a heavier per-allocation representation; the payoff is that pointer arithmetic and byte-level memory access compose under full symbolic reasoning exactly where it is needed, which is exactly the bit-level, pointer-aware modeling that libraries like text and bytestring require. This cost is easy to justify in practice, since raw pointer use in Haskell code is typically confined to a small, contained scope rather than pervasive throughout a codebase.
6 Evaluation
6.1 G2
We compare SymFC against G2 using the benchmarks from G2Q [16], the quasi quoter interface of G2. The G2 benchmark consists of four programs: an imperative arithmetic language, a program synthesizer for the lambda calculus, an n-queens solver and a solver to find matching strings of a regular expression. We additionally reproduce the results of Grisette [21] on the same benchmarks, as a baseline comparison. Grisette runs as a lightweight library in compiled Haskell; porting the benchmarks requires rewriting the benchmarks within the Grisette library, directly using its symbolic primitives like Union for representing case-splits. This port was already performed by the Grisette authors for their own benchmarks, so we reuse it. SymFC directly interprets the program as is, by compiling it to GHC core and interpreting the resulting expression symbolically. As SymFC uses Grisette internally, Grisette's performance quantifies the overhead of symbolically interpreting compiled GHC core. § 6.1 shows the performance of G2, SymFC and Grisette. We ran the benchmarks with a timeout cap of 90 seconds.
Search. G2 performs a breadth-first search over symbolic paths to find counterexamples. This allows them find counterexamples in programs with un-boundedly many paths. SymFC does not have this built-in search procedure, but we can replicate it via iterative deepening. Grisette's port of the benchmarks uses the same approach.
| Task | G2 (s) | SyMFC (s) | Grisette (s) |
|---|---|---|---|
| badEnvSearch prog | 59.32 | 0.09 | 0.02 |
| Search for non-zero Mul x y == Add x y | 0.56 | 0.21 | 0.10 |
| solveDeBruijn for id | 0.04 | 0.07 | 0.04 |
| solveDeBruijn for const | 1.06 | 0.08 | 0.02 |
| solveDeBruijn for NOT | Timeout | Timeout | Timeout |
| solveDeBruijn for OR | 86.22 | 0.27 | 0.03 |
| solveDeBruijn for AND | Timeout | 20.52 | 12.32 |
| solveQueens 4 | 0.36 | 0.08 | 0.03 |
| solveQueens 5 | 0.55 | 0.11 | 0.03 |
| solveQueens 6 | 0.90 | 0.12 | 0.03 |
| solveQueens 7 | 1.47 | 0.14 | 0.03 |
| solveQueens 8 | 2.30 | 0.16 | 0.04 |
| stringSearch for (a + b)*c(d + (ef)*) | 0.26 | 0.10 | 0.03 |
| stringSearch for abcdef | 4.23 | 0.12 | 0.12 |
| stringSearch for a + b + c + d + e + f | 0.05 | 0.09 | 0.04 |
| stringSearch for a*b*c*d*e*f* | 0.02 | 0.09 | 0.02 |
Fig. 4. G2Q Benchmarks.
Performance. SYMFC is faster than G2 on most benchmarks, with a geometric mean speedup of 6.25x. G2 outperforms SYMFC on benchmarks with very low runtime, such as solveDeBruijn. We suspect that most of the time spent by SYMFC goes to the preparation of embeddings.
Benchmark Difference. We note that the benchmark results of Grisette on solveDeBruijn differ from what is reported in the original paper. The artifact of Grisette restricted the symbolic value generation only to closed DeBruijn terms, which greatly reduces statespace. For a fair comparison with G2, we adjusted the benchmark to be more faithful to the original formulation.
6.2 Verified Properties
We evaluate SYMFC on a suite of 54 properties spanning primitive types, standard library data structures, real-world third-party libraries, and low-level pointer and memory operations. Each property is verified at compile time by the GHC plugin, which invokes Z3; the test suite checks the results at runtime. Of these, 13 are deliberately invalid (marked X in Table 1), spread across all type domains to exercise SYMFC's counterexample generation end-to-end. All experiments are run on an Apple M4 Pro with 24 GB of RAM. Table 1 lists all verified properties together with their SMT solve times as reported by Z3.
Primitive Types. We verify basic arithmetic properties over Bool, Integer, the fixed-width signed integers Int, Int8, Int16, Int32, Int64, and the unsigned types Word, Word8, and Word64. Properties include commutativity and identity of addition, self-subtraction to zero, commutativity of multiplication, bitwise-AND commutativity for Word, De Morgan's law for Bool, and the strict inequality for unbounded Integer. Invalid properties like are included for each type.
Data.Map.S strict and Data.Set. We verify 15 properties over Data.Map.S strict and Data.Set from the containers package, which ships with GHC and is one of the most widely depended-upon libraries in Haskell. The properties cover the core invariants of both structures: membership and lookup after construction via empty, singleton, insert, and delete; deleting the only key of a singleton yields a null map; a key distinct from the singleton key is not a member. The four invalid properties cover membership after self-deletion and lookup returning Nothing after an overwrite.
iproute. We verify 8 properties over IPv4 and IPv6 address and subnet arithmetic from the iproute library, an external package for IP address manipulation that is not part of the standard distribution.
Table 1. Properties verified by SymFC with Z3 solve times. ✓ = valid (no counterexample exists); X = invalid (counterexample found). Times shown are SMT solve times in milliseconds as reported by Z3.
| Property | Arguments | ms |
|---|---|---|
| Bool | ||
| De Morgan's law | Bool² | ✓ 25 |
| a ⇒ b is not a tautology | Bool² | ✗ 8 |
| Integer (unbounded) | ||
| x + y = y + x | Integer² | ✓ 5 |
| x < x + 1 | Integer | ✓ 6 |
| Int, Int8, Int16, Int32, Int64 | ||
| x + y = y + x (one property per type) | 2 args | ✓ 5–10 |
| x + 0 = x | Int | ✓ 5 |
| x - x = 0 | Int | ✓ 6 |
| x × y = y × x | Int² | ✓ 5 |
| x < x is always false (one property per type) | 1 arg | ✗ 5–6 |
| Word, Word8, Word64 | ||
| x + y = y + x (one property per type) | 2 args | ✓ 6–8 |
| x + 0 = x | Word | ✓ 9 |
| x & y = y & x | Word² | ✓ 5 |
| x < x is always false (one property per type) | 1 arg | ✗ 5–6 |
| containers (Data.MapStrict) | ||
| member k empty = False | Int | ✓ 12 |
| member k (singleton k v) = True | Int² | ✓ 5 |
| lookup k (singleton k v) = Just v | Int² | ✓ 5 |
| member k (insert k v empty) = True | Int² | ✓ 9 |
| lookup k (insert k v empty) = Just v | Int² | ✓ 5 |
| null (delete k (singleton k v)) = True | Int² | ✓ 5 |
| k₁ ≠ k₂ ⇒ lookup k₁ (singleton k₂ v) = Nothing | Int³ | ✓ 5 |
| member k₁ (singleton k₂ v) without k₁ = k₂ precondition | Int³ | ✗ 5 |
| member k (delete k (singleton k v)) | Int² | ✗ 10 |
| lookup k (insert k v₁ (singleton k v₂)) = Nothing | Int³ | ✗ 5 |
| containers (Data.Set) | ||
| member k empty = False | Int | ✓ 5 |
| member k (singleton k) = True | Int | ✓ 5 |
| member k (insert k empty) = True | Int | ✓ 5 |
| ¬member k (delete k (singleton k)) | Int | ✓ 4 |
| member k (delete k (singleton k)) | Int | ✗ 5 |
| iproute (Data.IP) | ||
| fixByteOrder (fixByteOrder w) = w | Word32 | ✓ 17 |
| IPv4: a ∈ makeAddrRange a l | Word32, Int | ✓ 10 |
| IPv4: r >> r | Word32, Int | ✓ 5 |
| IPv4: r₁ >> r₂ ∧ r₂ >> r₁ >> r₃ | Word32³, Int³ | ✓ 14 |
| IPv6: a ∈ makeAddrRange a l | Word32⁴, Word8 | ✓ 17 |
| IPv6: r >> r | Word32⁴, Word8 | ✓ 6 |
| IPv4-mapped address is in lifted IPv6 range | Word32, Word8 | ✓ 6 |
| IORef | ||
| Write then read returns the same value | Int | ✓ 7 |
| Ptr / ForeignPtr | ||
| For fresh p: peekByte p = 0 | — | ✓ 6 |
| For fresh p: m ≠ n ⇒ pokeByte (plusPtr p m) v ; | Int², Word8 | ✓ 7 |
| peekByte (plusPtr p n) = 0 | ||
| pokeByte p v₁ ; pokeByte p v₂ ; peekByte p = v₂ | Word8² | ✓ 7 |
| pokeByte (plusPtr (plusPtr p m) n) v;peekByte (plusPtr p (m+n)) = v | Int², Word8 | ✓ 7 |
| pokeByte p v ; peekByte (castPtr (castPtr p)) = v | Word8 | ✓ 7 |
| pokeByte (plusPtr p₁ k) v ; peekByte (plusPtr p₂ k) = 0 | Int, Word8 | ✓ 7 |
| Total (54 properties) | 413, 137 | 389 |
The properties verified include: that an internal byte-swap helper (fixByteOrder) is an involution;
that makeAddrRange always contains its own base address, for both IPv4 and IPv6; that subnet containment (::) is reflexive for both address families; that IPv4 subnet containment is transitive; and that an IPv4 address contained in a range is also contained in the corresponding IPv4-mapped IPv6 range. The transitivity property is the most demanding: it is a 6-argument formula with a non-trivial precondition requiring mask lengths to lie in [0, 32], exercising the solver on a formula with many symbolic variables. We note that the library contains a latent bug in maskIPv6: passing minBound :: Int as the mask length causes negate minBound to overflow back to minBound, which is then forwarded as a negative shift count to the safe shiftR, triggering an arithmetic overflow at runtime. We discovered this during verification and worked around it by using Word8, instead.
IORef. We verify one property over IORef: that a value written to a reference and immediately read back is equal to the original. This validates the IO embedding described in § 5.
Ptr / ForeignPtr. We verify 6 properties over Ptr and ForeignPtr against the underlying byte-addressable symbolic heap, covering raw, unsafe memory access rather than the GC-managed, whole-value references of IORef. A fresh allocation reads as zero-initialized; a write at one symbolic offset does not alias a read at a distinct symbolic offset; a second write overwrites the first; a write reached through nested pointer arithmetic is observed at the equivalent flat offset; and a write to one allocation does not alias a read from another allocation entirely, which exercises separation across allocation identities rather than just within a single buffer. We also check that a write is still observed after the pointer is cast to a different element type and back, matching how castPtr is used in practice to reinterpret buffers, e.g. in bytesting internals.
ClambdaSH/ AIMCore. Prior work [30] applied symbolic execution at scale using an early version of the ClambdaSH embeddings, to verify the leakage description of AIMCore, a 5-stage in-order RISC-V processor implemented in approximately 800 lines of ClambdaSH. Running SymFC on the artifact takes 45 s on our machine; this demonstrates that the ClambdaSH embedding scales to a realistic hardware design.
7 Limitations
Inlining. SymFC is unaware of inlining performed by GHC before symbolic evaluation. If GHC inlined a function that has an embedding, then SymFC will evaluate the original function: there is no way of knowing the original call existed. As such, SymFC is fragile with respect to inlining performed by GHC. Of course, the embeddings, and thus the functions for which to avoid inlining, can change for every invocation. The only realistic solution is to disable inlining everywhere, which in GHC can only be done by fully disabling optimizations with the compilation -O0.
This in itself is tolerable, though perhaps exacerbated by the applicability of our embeddings. The real problem presents itself with base, the Haskell standard library. Unlike any other library in Haskell, base comes pre-packaged with the GHC compiler. You cannot use another version of base without using another GHC compiler version. Within SymFC, we would need a custom GHC compiler which has base compiled with optimization level -O0. This has been a limiting factor in our attempts to use SymFC to check correctness of libraries that use low-level Haskell features, such as text and bytesting. Fortunately, GHC 10.2.0 is set to separate base from GHC.
Primitive Containers. SMT exposed container types like SMT.Array can only reason about other SMT primitives that it contains. For example, we can reason about SMT_Integer as both an index or an element of an SMT_Array. SMT containers do not however permit arbitrary types. This is not a problem if the contained type is known: we can write a custom encoding of our data type expressed in SMT primitives. A more problematic case is when we wish to have an embedding of a Haskell container, e.g. Map k vmap SMT_Array k v. As the function Map.insert would be polymorphic over its key and value, there is no general translation from the key and value type into SMT primitives.
We also cannot constrain the inputs to include only types that are convertible to SMT, as this would violate the subsumption requirement of the term embedding. As of writing, we do not have a satisfying way to support SMT container embeddings over unrestricted, polymorphic elements.
8 Related Work
QuickCheck [9] allows users to specify function properties directly in code, via Boolean functions, and randomly generates inputs to check whether the properties hold for arbitrary inputs. QuickCheck has proven to be extremely successful (not least due to its ease of use and good counterexamples). Our aim is to pair the ease of use of QuickCheck – namely the ability to express program properties directly in code via arbitrary Boolean valued function – with the benefits of all paths symbolic execution. In particular, unlike QuickCheck, symbolic execution allows us to prove correctness of properties that only depend on bounded recursion.
Rosette [28] exposes a restricted subset of primitives in the host language (Racket) to allow building symbolic execution tools for DSLs embedded in the language. This has been dubbed solver-aided programming. Like Rosette [28], we perform all-paths symbolic execution which allows balancing concretization (e.g., evaluating concrete values, wherever possible) with outsourcing reasoning about branches to the solver [1, 19]. Unlike Rosette whose goal it is to make it easier to implement custom symbolic execution engines for DSLs, we want to symbolically execute the host language itself. This requires us to symbolically represent arbitrary values and types in the language, which we achieve with our symbolic calculus, and our notion of embeddings.
Grisette [21] is a Haskell library for building symbolic execution tools. Grisette internally uses the SBV library [11], which exposes primitive SMT operations. Our implementation builds on Grisette for its ordered guard representation for merging symbolic values. Unlike Grisette [21], SymFC directly symbolically executes GHC core and can build symbolic representation for arbitrary values and types, allowing us to symbolically execute native Haskell code.
Hs-to-coq [5] translates Haskell into the Rocq proof assistant [27] to perform foundational proofs (among others, about the container library). By contrast, we target lightweight formal methods via a direct SMT encoding, and by specifying verification conditions in code.
Liquid Haskell [29] is a lightweight verification tool for Haskell that builds on refinement types. Flux [20] brings a similar refinement-typing approach to Rust, it attaches quantifier-free predicates to types and relies on liquid inference. Stainless [17] verifies function contracts for Scala, encoding verification conditions and higher order functions into SMT. Unlike SymFC, these methods build dedicated verification techniques that can verify per-module contracts of functional programs involving arbitrary recursion. Instead, our aim is to encode simple checks about bounded unrollings of Haskell programs directly into the language, allowing a QuickCheck-like interface with the benefits of all-paths symbolic execution.
G2 [15] performs symbolic execution in Haskell. G2 offers counterfactual symbolic execution which allows detecting errors that do not correspond to concrete property violations, but rather, stem from imprecision of the type system. Unlike SymFC, G2 performs King-style symbolic execution [18] by symbolically evaluating individual paths guarded by a path-condition. By contrast, we perform all-paths symbolic execution which allows us to perform state merging, which can benefit speed. Unlike SymFC, G2 does not directly represent arbitrary System FC conditions symbolically, and cannot model arbitrary functions as other Haskell functions and SMT primitives via embeddings.
Crux-MIR [22] is closer to SymFC. Properties are stated as ordinary Rust functions over symbolic values, checked as unit tests via cargo, and its underlying engine, Crucible, performs all-paths symbolic execution via state merging. However, extending Crucible with a new primitive types requires writing a language extension to the engine itself. Crux-MIR closes the gap to real Rust code with a fixed set of developer-curated standard-library overrides, whereas SymFC exposes
Robin Webbers, Wind Wong, and Klaus von Gleissenthall
embeddings directly to property authors, who may choose a different representation per-property without modifying SyMFC.
Memory modeling is a well-studied area of symbolic execution in its own right; we refer to Baldoni et al. [3] for a survey. At one end, tools such as EXE [7], KLEE [6], and SAGE [13] encode memory as fully symbolic, using an SMT theory of arrays so that both the address and the value of a memory access can remain symbolic. At the other end, tools trade this precision for scalability: address concretization (as in DART [12] and CUTE [24]) collapses a symbolic pointer to a single concrete address, while partial memory models (as in Mayhem [8] and angr [25]) concretize writes and only keep reads symbolic within a small bounded range. Our Ptr/ForeignPtr embedding (§ 5) falls into the first category: each allocation is a genuinely symbolic SMT array, so the byte offset within it, as well as the value read or written there, can stay symbolic. Unlike the listed tools, this mechanism is not built into SyMFC's engine; it is an ordinary embedding, written the same way a user would write any other embedding, and a property author who instead needs concretization or a partial memory model for scalability is free to write that embedding themselves.
References
[1] Thanassis Avgerinos, Alexandre Rebert, Sang Kil Cha, and David Brumley. 2016. Enhancing symbolic execution with veritesting. Commun. ACM 59, 6 (May 2016), 93–100. doi:10.1145/2927924
[2] C. Baaij. 2009. CAsH : from Haskell to hardware. Thesis. University of Twente, Enschede. https://purl.utwente.nl/essays/59482
[3] Roberto Baldoni, Emilio Coppa, Daniele Cono D'Elia, Camil Demetrescu, and Irene Finocchi. 2018. A Survey of Symbolic Execution Techniques. ACM Comput. Surv. 51, 3, Article 50 (2018).
[4] JOACHIM BREITNER, RICHARD A. EISENBERG, SIMON PEYTON JONES, and STEPHANIE WEIRICH. 2016. Safe zero-cost coercions for Haskell. Journal of Functional Programming 26 (2016), e15. doi:10.1017/S0956796816000150
[5] Joachim Breitner, Antal Spector-Zabusky, Yao Li, Christine Rizkallah, John Wiegley, and Stephanie Weirich. 2018. Ready, set, verify! applying hs-to-coq to real-world Haskell code (experience report). Proc. ACM Program. Lang. 2, ICP, Article 89 (July 2018), 16 pages. doi:10.1145/3236784
[6] Cristian Cadar, Daniel Dunbar, and Dawson Engler. 2008. KLEE: unassisted and automatic generation of high-coverage tests for complex systems programs. In Proceedings of the 8th USENIX Conference on Operating Systems Design and Implementation (San Diego, California) (OSDI'08). USENIX Association, USA, 209–224.
[7] Cristian Cadar, Vijay Ganesh, Peter M. Pawlowski, David L. Dill, and Dawson R. Engler. 2008. EXE: Automatically Generating Inputs of Death. ACM Trans. Inf. Syst. Secur. 12, 2, Article 10 (Dec. 2008), 38 pages. doi:10.1145/1455518.1455522
[8] Sang Kil Cha, Thanassis Avgerinos, Alexandre Rebert, and David Brumley. 2012. Unleashing Mayhem on Binary Code. In 2012 IEEE Symposium on Security and Privacy. 380–394. doi:10.1109/SP.2012.31
[9] Koen Claessen and John Hughes. 2011. QuickCheck: a lightweight tool for random testing of Haskell programs. SIGPLAN Not. 46, 4 (May 2011), 53–64. doi:10.1145/1988042.1988046
[10] Leonardo de Moura and Nikolaj Bjørner. 2008. Z3: An Efficient SMT Solver. In Tools and Algorithms for the Construction and Analysis of Systems, C. R. Ramakrishnan and Jakob Rehof (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 337–340.
[11] Levent Erkok. [n.d.]. SBV Haskell Library. https://hackage.haskell.org/package/sbv-2.0
[12] Patrice Godefroid, Nils Klarlund, and Koushik Sen. 2005. DART: directed automated random testing. In Proceedings of the 2005 ACM SIGPLAN Conference on Programming Language Design and Implementation (Chicago, IL, USA) (PLDI '05). Association for Computing Machinery, New York, NY, USA, 213–223. doi:10.1145/1065010.1065036
[13] Patrice Godefroid, Michael Y. Levin, and David A. Molnar. 2008. Automated Whitebox Fuzz Testing. In Network and Distributed System Security Symposium. https://api.semanticscholar.org/CorpusID:1296783
[14] Harrison Goldstein, Joseph W. Cutler, Daniel Dickstein, Benjamin C. Pierce, and Andrew Head. 2024. Property-Based Testing in Practice. In Proceedings of the IEEE/ACM 46th International Conference on Software Engineering (Lisbon, Portugal) (ICSE '24). Association for Computing Machinery, New York, NY, USA, Article 187, 13 pages. doi:10.1145/3597503.3639581
[15] William T. Hallahan, Anton Xue, Maxwell Troy Bland, Ranjit Jhala, and Ruzica Piskac. 2019. Lazy counterfactual symbolic execution. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation (Phoenix, AZ, USA) (PLDI 2019). Association for Computing Machinery, New York, NY, USA, 411–424. doi:10.1145/3314221.3314618
[16] William T. Hallahan, Anton Xue, and Ruzica Piskac. 2019. G2Q: Haskell constraint solving. In Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell (Berlin, Germany) (Haskell 2019). Association for Computing Machinery, New York, NY, USA, 44–57. doi:10.1145/3331545.3342590
[17] Jad Hamza, Nicolas Voiroi, and Viktor Kunčak. 2019. System FR: formalized foundations for the stainless verifier. Proc. ACM Program. Lang. 3, OOPSLA, Article 166 (Oct. 2019), 30 pages. doi:10.1145/3360592
[18] James C. King. 1976. Symbolic execution and program testing. Commun. ACM 19, 7 (July 1976), 385–394. doi:10.1145/360248.360252
[19] Volodymyr Kuznetsov, Johannes Kinder, Stefan Bucur, and George Candea. 2012. Efficient state merging in symbolic execution. SIGPLAN Not. 47, 6 (June 2012), 193–204. doi:10.1145/2345156.2254088
[20] Nico Lehmann, Adam T. Geller, Niki Vazou, and Ranjit Jhala. 2023. Flux: Liquid Types for Rust. Proc. ACM Program. Lang. 7, PLDI, Article 169 (June 2023), 25 pages. doi:10.1145/3591283
[21] Sirui Lu and Rastislav Bod{jk. 2023. Grisette: Symbolic Compilation as a Functional Programming Library. Proc. ACM Program. Lang. 7, POPL, Article 16 (Jan. 2023), 33 pages. doi:10.1145/3571209
[22] Stuart Pernsteiner, Iavor S. Diatchki, Robert Dockins, Mike Dodds, Joe Hendrix, Tristan Ravich, Patrick Redmond, Ryan Scott, and Aaron Tomb. 2024. Crux, a Precise Verifier for Rust and Other Languages. arXiv:2410.18280 [cs.PL] https://arxiv.org/abs/2410.18280
[23] Simon Peyton Jones. 1996. Compiling Haskell by Program Transformation: A Report from the Trenches. Vol. 1058. Springer. https://www.microsoft.com/en-us/research/publication/compiling-haskell-by-program-transformation-a-report-from-the-trenches/
[24] Koushik Sen, Darko Marinov, and Gul Agha. 2005. CUTE: a concolic unit testing engine for C. In Proceedings of the 10th European Software Engineering Conference Held Jointly with 13th ACM SIGSOFT International Symposium on Foundations of Software Engineering (Lisbon, Portugal) (ESEC/FSE-13). Association for Computing Machinery, New York, NY, USA, 263–272. doi:10.1145/1081706.1081750
[25] Yan Shoshitaishvili, Ruoyu Wang, Christopher Salls, Nick Stephens, Mario Polino, Andrew Dutcher, John Grosen, Siji Feng, Christophe Hauser, Christopher Kruegel, and Giovanni Vigna. 2016. SOK: (State of) The Art of War: Offensive Techniques in Binary Analysis. In 2016 IEEE Symposium on Security and Privacy (SP). 138–157. doi:10.1109/SP.2016.17
[26] Martin Sulzmann, Manuel MT Chakravarty, Simon Peyton Jones, and Kevin Donnelly. 2007. System F with type equality coercions. In Proceedings of the 2007 ACM SIGPLAN international workshop on Types in languages design and implementation. 53–66.
[27] The Rocq Development Team. 2026. The Rocq Prover, Version 9.2. https://rocq-prover.org
[28] Emina Torlak and Rastislav Bodik. 2014. A lightweight symbolic virtual machine for solver-aided host languages. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation (Edinburgh, United Kingdom) (PLDI '14). Association for Computing Machinery, New York, NY, USA, 530–541. doi:10.1145/2594291.2594340
[29] Niki Vazou, Eric L. Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon Peyton-Jones. 2014. Refinement types for Haskell. In Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming (Gothenburg, Sweden) (ICFP '14). Association for Computing Machinery, New York, NY, USA, 269–282. doi:10.1145/2628136.2628161
[30] Robin Webbers, Robert Schenck, Wind Wong, Kristina Sojakova, and Klaus von Gleissenthal. 2026. Pantomime: Constructive Leakage Proofs via Simulation. Proc. ACM Program. Lang. 10, PLDI, Article 262 (June 2026), 26 pages. doi:10.1145/3808340