Manuscript Offprint
arXiv:2611.00185Blazing-Fast SMT-LIB Parsing for Rust and Lean
Jan Onderka¹, Armin Biere¹, and Henrik Böving²
¹ University of Freiburg, Germany {onderka,biere}@cs.uni-freiburg.de ² Lean FRO, Germany henrik@lean-fro.org
Abstract. SMT-LIB is a standard input format for Satisfiability Modulo Theories (SMT) solvers. However, parsing the format is non-trivial and can become a bottleneck, e.g. when retrieving benchmark metadata or normalising the input for solvers. We introduce blazing-smtlib, a Rust parsing library for SMT-LIB, and BSmtLib, its port to Lean. We outline the library API we designed for composability and extensibility (including non-standard SMT-LIB commands), and discuss our implementation decisions for fast lexing and parsing. We proved that our lexing and parsing with Lean-specific optimisations match our formalised reading of the SMT-LIB syntax. We measured performance on a representative sample from the 2025 SMT-LIB corpus and found that blazing-smtlib is more than 6 times faster on the geometric mean than previous parsing libraries and BSmtLib is faster or comparable to them.
Keywords: Satisfiability Modulo Theories · Interactive Theorem Proving · composable parser library · push-style zero-copy parsing
1 Introduction
Satisfiability Modulo Theories (SMT) solving is an important and rich topic in verification and automated reasoning. The almost universal input format for SMT solvers is SMT-LIB 2 [8], with a wide corpus of SMT benchmarks [42, 43] that can be used to test the solvers and is used to compare their performance in the annual SMT solver competition (SMT-COMP) [50].
While SMT-LIB 2 is human-readable and it is fairly easy to implement a parser that reads the standard benchmarks, writing a specification-compliant parser that covers all syntactic constructs is hard. There are SMT-LIB parsing libraries available for some programming languages but they tend to lack extensibility for non-standard commands that solvers with custom parsers can support and are not thoroughly optimised for performance.
We present blazing-smtlib, a high-performance SMT-LIB parsing library written in the programming language Rust, and its port BSmtLib in the Interactive Theorem Prover (ITP) language Lean [31].
Both libraries are composable and extensible, allowing implementation of solvers with non-standard commands, reparsers, pretty-printers, response parsers etc. They are zero-dependency (only using the standard library of Rust / Lean), contain no unsafe code, and are tested on a variety of valid and invalid inputs and the 2025 SMT-LIB corpus. BSmtLib lexing and parsing is additionally proven to match our reading of the SMT-LIB syntax formalised in Lean. On a geometric mean over a representative sample from the 2025 SMT-LIB corpus, blazing-smtlib is more than 6 times faster than previous parsing libraries and BSmtLib is faster or comparable to them.
While the SMT-LIB 2 format is human-readable and can be written fairly easily by hand or a tool, parsing it is a challenge. When introducing the solver cvc5, the authors recognised the need for a faster parser to replace the one inherited from CVC4 [4, sec. 5]. In recent work on SMT-LIB input normalisation, the used parser timed out in 1 minute on 58 benchmarks [1, sec. 5]. A database containing SMT-LIB corpus metadata from benchmark files has been created [47], the metadata retrieval described as the most time-consuming stage [47, sec. 4].
It is common to run parallel solver portfolios [46]. A portfolio of same-solver instances can run parsing once [51] or multiple times [4]. Using multiple different solvers in parallel [2] or selecting the solver based on the input [41, 48] requires multiple parsing passes (for each solver or the selector and solver) when using SMT-LIB scripts. In multi-solver tools, the I/O cost of the parsing led to the creation [40] and use [39, 40] of frontend APIs that bypass the format.
Many SMT-LIB parsing libraries exist for a variety of programming languages [10, 14, 19, 21, 22, 24, 45]. Notably, Dolmen [17] allows lexing, parsing, and well-formedness checking of SMT-LIB scripts. It is written in OCaml, considered the reference parser and type-checker for SMT-LIB [47], and used as the model validator for the SMT solver competition [49].
Mainline SMT solvers in SMT-COMP, including cvc5 [4], Z3 [30], Yices [20], and Bitwuzla [32], all employ custom parsers. Custom parsers can be extended to support non-standard commands such as ‘minimize’ and ‘maximize’ provided by Z3 [12] or those added in SV-LIB, a standard exchange format for software verification that extends SMT-LIB 2.7 [11]. Unfortunately, extensibility of parsing libraries to non-standard commands has been limited: Dolmen and language-smtlib [45] can only process non-standard arguments as untyped expressions, pySMT [21] can only be extended by an internal table, and most other libraries cannot be extended at all.
Another area of potential use of SMT-LIB is within Interactive Theorem Provers (ITPs), where an SMT solver is used as a hammer [13, 28] and the result of its run on an SMT-LIB script is verified against a trusted specification. SMT-LIB benchmarks could for instance also be used during development of new ITP tactics for testing. Cursory unverified parsers have been implemented in Lean as a part of lean-auto [44], lean-smt [29] and the Leanwuzla [15] entry point for the bv_decide tactic [16]. Major hurdles along this line of work include the lack of an official SMT-LIB formalisation and the fact that ITP programs can easily be an order of magnitude slower than their counterparts in languages such as C, C++, or Rust, especially in low-level code such as parsing.
This work was motivated by us encountering the aforementioned problems while developing our twin tools Roole (an unverified solver written in Rust) and Roolean (a verified proof checker written in Lean) [36–38]. Due to the lack of Lean libraries for SMT-LIB parsing, we implemented an SMT-LIB parser of our own. In Roole 0.1.1, we switched the used parser from aws-smt-ir [23] to a port of the Roolean parser. Witnessing the value of a fast, extensible, and composable parsing library, we started development of blazing-smtlib from the Roole 0.1.1 parser. We then ported blazing-smtlib back to Lean under the name BSmtLib and optimised it specifically for Lean, minimising the potential for optimisation-related bugs through testing and proving it correct against our formalised reading of SMT-LIB syntax.
Overview. As blazing-smtlib and BSmtLib are based on the same concepts with language-specific differences, we discuss the API of blazing-smtlib in Section 3, its speed-optimised implementation in Section 4, and the BSmtLib port in Section 5. Finally, we evaluate their performance in Section 6.
3 Library Interface
There are two main types of parsing libraries: those that build a syntax tree, usually an abstract syntax tree (AST), and those that run over the stream of bytes and call a given handler on each syntax node (event-based API). The former are a good fit for languages with complicated parsing and small files, the latter for languages with simpler parsing but large files. SMT-LIB 2 fits the latter: it has Lisp-like syntax and the largest file in the corpus is approx. 2 GB. AST-building libraries are forced to retain the whole tree in memory.
Our library blazing-smtlib is a push-style streaming library in the style of Simple API for XML (SAX) [27], with focus on speed and composability. A properly composable library is difficult to implement but can fulfil the needs of more users, and testing and reasoning (e.g. when proving Lean theorems) are simplified due to the decreased coupling.
Figure 1 shows the basic types and interfaces provided by blazing-smtlib. Our library is push-style (data flows into the later stages), so the arrows describe the dataflow: a driver hands data to SmtLexer, which calls an instance of a SmtConsume. This instance might be e.g. SmtParseAdapter, which calls an instance of a SmtParse, and so on. This gives the user five entry points into the

Fig. 1: Simplified dataflow of the building blocks and user entry points in blazing-smtlib, without the Smt prefix for better readability. The user can provide the input as a file or stream of bytes (driver) or as a stream of tokens (token provider). The user can implement interfaces to process tokens (token consumer), parse tokens (custom parser), and handle parsed SMT-LIB categories and commands (user handler). A custom parser can be composed of provided category parsers and combinators, and the user handler can select a parser for parsing non-standard commands.
library instead of the usual two (bytestream/file input and parsed categories/-commands) or three (token consumption, if the lexer can be used separately). In addition to e.g. token-category counting or token-level pretty-printing usable through a separate lexer, the user can write their custom token provider (e.g. translating a problem written in another language without the need to go to text level or lexing a custom SMT-LIB-like binary format), and add new parsers, composable out of standard ones (for processing non-standard commands, reading non-script files such as solver responses, etc.).
Still, the typical usage scenario is writing an SMT-LIB solver. This can be done in a few simple steps. First, the user implements SmtHandler, setting the handler error type, the types that will be returned after handling, a binder scope type, and functions to handle each occurrence of a syntactic category:
impl SmtHandler for UserHandler { type Error = UserError;
type SExpr = UserExpr; type Attribute = UserAttribute; type Sort = UserSort; type Term = UserTerm;
type Scope = UserScope;
fn set_version(&mut self, version: SmtVersion) { /* implement */ }
fn handle_sort(&mut self, sort: SmtSort<'_, Self>) -> Result<UserSort, UserError> { /* implement */ }
fn handle_term(&mut self, term: SmtTerm<'_, Self>) -> Result<UserTerm, UserError> { /* implement */ }
fn start_let(&mut self, bindings: SmtBindings<'_, UserTerm>) -> Result<UserScope, UserError> { /* implement */ }
fn end_let(&mut self, scope: UserScope, body: UserTerm) -> Result<UserTerm, UserError> { /* implement */ }
// handlers for other syntactic categories (...) }
The parsers send events corresponding to post-order AST traversal to the handler, meaning that parsing ‘(add a b)’ will result in a call to handle_term with the term parameter containing the symbol ‘a’, then in a call with ‘b’. Typically, the user will find and return the unique identifiers a and b (values of UserTerm) that correspond to the symbols in a map of definitions. After all of the parameters are processed, handle_term will be called for ‘(add a b)’ itself, with the function name add and a parameter array composed of a and b.
Let expressions, quantifiers and lambdas are slightly more involved: given ‘(let ((x a) (y b)) x)’, the term parser first collects the binding term values a and b by calling handle_term, then lets the user introduce a let scope by calling start_let with the collected bindings [(‘x’, a), ('y’, b)]. The user can use the custom UserScope type to store information that will be used when closing the scope using end_let. Using a map of definitions, the user can replace the previous mapping, store it in UserScope, and restore it at end_let without needing to keep a custom stack of scopes. The user can also use a zero-sized scope type, avoiding any performance penalty when managing scopes manually.
After implementing the category handler, the user implements a command handler, deciding what should be done when commands are issued:
impl SmtCommandHandler for UserHandler {
type NonstandardParser = UserParser;
fn command_assert(&mut self, term: UserTerm)
-> Result<(), UserError> {
/* implement */
}
// handlers for other commands
(...)
fn nonstandard_command(
&mut self,
name: SmtSymbol<'>,
) -> Result<UserParser, UserError> {
Ok(UserParser::new())
}
}
}
The standard commands can be implemented similarly to categories, with e.g. command_assert adding the given term to current assertions. On success, they return no data, as they are used to change the current semantic state carried in the handler or produce other effects, e.g. print some output. A handler implementation that does not interact with the global state (e.g. with output streams adjustable on construction) could also be used through the API alone by tools such as portfolio runners, as the types such as SmtTerm or SmtBindings can be constructed outside of our library.
The special nonstandard_command method is called when a command with a non-standard name is encountered. The user can either reject the command or return a parser that will parse the rest of it. The parser can be a standard parser, a composition of standard parsers or a user-written parser that can process tokens specially and/or call standard parsers itself. As standard category parsers return a properly typed value once they have finished processing it (e.g. SmtTermParser returns a UserTerm), it is easy to extend a solver with extensions such as ('maximize t'), where t stands for an arbitrary term.
While the composability can be used for maximum control, we care about simple usage in usual scenarios. For the caller, we provide SmtReader that directly connects the driver with the handler, combining lexing and parsing. A step further, reading SMT-LIB files can be as easy as implementing a command handler and writing
read_smt_file(&mut user_handler, file_path)
which reads the SMT-LIB file and calls the handler with the appropriate categories and commands to handle.
Whitespace. We provide an option for the token consumers to request whitespace and comments to be emitted as tokens, which allows printing while preserving some parts of the layout, up to 1:1 reconstruction of input files³.
³ With a single exception of SMT-LIB 2.0 files containing occurrences of non-escaped backslashes in strings, which tokenise to the same content as properly escaped backslashes. Files for SMT-LIB versions 2.5+ can be reconstructed exactly.
Continuation and errors. Our parsers and parser adapter are designed to reset on producing a result, ready to process another piece of the same data (self-reset). On encountering an error, we implement fail-fast behaviour, where processing is stopped in an unspecified state and continuing to process is not allowed. We have done a preliminary exploration of error recovery allowed by the standard, but it leads to ambiguity. For example, in '|\x', it is unclear if the disallowed backslash was written instead of the closing pipe of the quoted symbol by mistake, or if it is spurious and the quoted token should continue. As such, we currently do not provide an option for recovery. For the usual case of generated SMT-LIB files, an error is a sign that something is wrong with the generator or the data stream, and error recovery should not be performed.
Locations. The token provider hands over cursors over tokens that implement a token interface to token consumers, and can add additional information that can be used non-generically. Our lexer adds offset/line/column token span, and returns or wraps errors with the span of the token where the error occurred. Generic parsers do not interact with location or other information in tokens, and it is not passed to the handlers to simplify signatures and increase speed.
A parser adapter specific to our lexer could be used to use the location information more extensively, for example by tracking parentheses and delaying an error to provide the full command or term location where the error occurred. We did not add such constructions to the library to keep it simple and avoid adding code that would not be used by most users.
4 Rust Implementation
The SMT-LIB 2 language is a Lisp-like language with a separate lexicon over 8-bit bytes (US-ASCII with the encoding of higher bytes unspecified) and a grammar over the lexical tokens, read in a streaming fashion in a Read-Eval-Print loop (REPL). It is unusual in that it can be considered a programming language (semantically expressing program or system behaviour) or a data interchange language (as the major use is running automatic tools that receive automatically generated files). For lexer or parser construction, it is more useful to consider it a data interchange format and apply standard techniques. Our lexer and parsers are fairly standard constructions with two crucial speed-improving techniques:
-
Batch processing. The token consumers / parsers receive a cursor from which they consume tokens. The lexer is given a slice of bytes in one call, creates the tokens and puts them into a batch, then calls the consumer with a cursor into the batch, minimising the token handover work. Batch processing is intentionally not used for handlers for a cleaner, easy-to-use API, with the potential speed benefits lower in the later stage.
-
Zero-copy dispatch. When possible, the lexer produces token batches that only reference data (symbol names, literal values, etc.) through a slice into the input byte buffer without any copying, and highly-used parsers do not copy when it is possible to call the handler with the reference.

Categories of bytes in files
Fig. 2: Shares of bytes and tokens per category on 2025 SMT-LIB corpus files, as seen by our lexer on its input and its dispatch arms. Reserved words are lexed the same as simple symbols, with a reserved-word lookup afterwards; we move the lookup to the parser side for easier reconstruction. Even if whitespace and comments are not emitted, they must be processed by the lexer. Whitespace, parentheses, and symbols dominate and must be processed quickly. Long comments comprise a large part of some small files. The other categories are less relevant for lexer speed. The shares of token categories are regular due to the S-expression shape, e.g. a 2-argument function application ‘(bvadd a b)’ consists of 2 parentheses, 3 simple symbols, and 2 whitespaces.
4.1 Lexing
Our lexer is a simple iterative state-machine lexer with additional machinery. The speed is achieved by a single eager zero-copy dispatch loop in the normal lexer state. When the token content is a slice of the input buffer, the token is added to the current batch of tokens and the loop continues. The loop is terminated and the batch handed over to the consumer only when adding another token becomes impossible (e.g. a string contains an escape or lexing needs to continue past the buffer end). In practice, over 99.99% of tokens are produced in the loop, so it is the only place requiring heavy optimisation. Due to the unequal shares of lexical categories shown in Figure 2, they are tested in a preferential order:
- closing parenthesis,
- opening parenthesis,
- symbol (simple, reserved word, quoted) or whitespace,
- everything else.
The closing parenthesis is tested first as there are long runs (successive occurrences) of closing parentheses, compared to opening parentheses where there are no non-trivial runs ⁴. A long run of closing parentheses is then processed as fast as possible, running through the fastest path with accurate branch prediction.
Non-parenthesis tokens can be arbitrarily large, so it is necessary to move after the run of bytes allowed in them as fast as possible for good byte-dispatch performance. Specialised techniques have been devised for this problem that allow extremely fast dispatch of long runs using SIMD and bitwise parallelism [18,25,26]. However, including whitespace and comments that must be processed by the lexer (but not necessarily emitted), non-parenthesis tokens are on average approx. 4 bytes long in the 2025 SMT-LIB corpus, so it is necessary to optimise for short tokens instead. As we limit blazing-smtlib to safe Rust only, we dispatch a byte of the run by using it as an index into a 256-entry table, where a byte value masked with the run flag determines if the run is continuing. We loop this byte dispatch until the run ends, unrolling the loop 4 times. Our experiments showed that this is on average comparable performance-wise with less portable SIMD designs and superior to portable bitwise-parallel techniques due to the short token lengths. For long tokens (relevant especially to the theory of strings), switching to SIMD and long-token techniques at a certain point would presumably be a faster but less portable alternative.
The category tests are also performed using a 256-entry table indexed by the current byte. If the token cannot be processed by the eager dispatch loop, the lexer flushes the token batch to the consumer and gracefully falls back to state-machine processing. This can occur e.g. due to consuming all bytes in the provided byte slice or an unexpected byte at the end of the run that will make the state-machine path produce an error.
We were not limited by stable Rust without unsafe constructs except for the aforementioned inability to use SIMD explicitly and one lifetime restriction:
⁴ Appendix A contains additional figures for token prevalence, length, and runs.
since a zero-copy batch references the input bytes and the lexer loses control over them when it returns, it must either reassign the batch references or drop the batch structure and create a new batch in the next call.
4.2 Parsing
Token consumers are provided a cursor through which they can peek and consume the next token or attempt to consume multiple tokens at the same time. As the token provider is not required to produce multiple tokens per batch, the attempts must fall back gracefully, so they are only used in the library for the most likely and time-critical paths when parsing terms. The consumers are required to consume at least one token per call so that parsing terminates.
For fast parsing, the parser adapter constructs resources for standard parsers, which contain a state slot for every standard category, as well as typed arenas (dynamic arrays of types that are pushed on the stack during processing). This means that the constructed instances of e.g. SmtTermParser are zero-sized types with no information, sharing a state slot and dynamic arrays so that already allocated memory can be reused as much as possible.
User parsers cannot use our arenas except through a standard parser, but a custom user arena could be threaded in via the handler at the cost of losing genericity. To avoid inadvertent corruption of parser state through resource reuse, the contract requires continuing to call parsers once they have started processing: for example, it is forbidden to construct two instances of SmtTermParser and call them alternately.
Most SMT-LIB constructs are easy to parse but there are two difficult types:
-
Bindings. Binders 'let', 'forall', 'exists', and 'lambda' open a new semantic scope⁵, and it is natural to provide the name-term bindings in a single call such as start_let that will be followed by end_let. For this, the bindings must be remembered during processing (we currently do not perform zero-copy binding dispatch for simplicity). Similar processing applies to binder-like commands such as 'define-fun'.
-
Recursion. No standard SMT-LIB construct can alternate between different constructs recursively, but sorts, terms, and general S-expressions may self-recurse. The main implementation concept is keeping a stack of unclosed values and a parser state for parsing the current value at the top.
The term parser is the most difficult part of the parser implementation as it uses both types of constructs and terms (especially symbol terms and applications) are the most common nodes in SMT-LIB files, as shown in Figure 3. We do not use any techniques other than careful choices of data structures and cursor attempts for a consistent but only small speed benefit.
⁵ The binder 'match' functions similarly but opens scopes at its match cases instead.

Fig. 3: Shares of category and command nodes on 2025 SMT-LIB corpus files. Terms are dominant, especially as the file size increases. Symbol and constant terms can be dispatched to the handler immediately. Applications and indexed identifiers are common, but simple in nature. Binders are the most challenging because of their shape, need to remember the bindings, and uncommon occurrence that complicates branch prediction.
4.3 Switching Lexical Modes
SMT-LIB allows a clean split into a lexing and a parsing pass, with two notable exceptions:
- Exit command. The
(exit)command forces the reader to immediately stop reading the SMT-LIB script. - Version switch. The version under which an SMT-LIB file should be parsed can be given by the command
(set-info :smt-lib-version <version>). The legacy version 2.0 used a different escape format for string literals than the current versions from 2.5 onward. As the version is declared inside the script file, and it is read in a streaming fashion, the command switches not just the grammar and semantics, but the lexicon itself.
Parsing these constructs interacts with lexing, as errors and tokens produced eagerly by the lexer may no longer be applicable after they are processed. We resolve them carefully by allowing the consumer to request the new version or discard mode through the token cursor, which will occur after the last consumed token. The version switching from/to 2.0 in particular forces our lexer to be speculative: after such a switch, it discards the tokens it already produced and starts lexing again from the end of the last consumed token. This is possible since all tokens in the current batch correspond to the bytes in the byte buffer provided to the lexer as the input, which are still available to the lexer.
5 Lean Port
We ported blazing-smtlib into Lean as BSmtLib. Like the Rust version, it has no dependencies (except for Lean itself) and contains no unsafe code. Additionally, it is panic-free: all contract violations that result in a panic in Rust are impossible by construction as the contract is formalised and adherence to it must be proven. All proofs in the library use only the three usual Lean axioms (classical choice, propositional extensionality, and the quotient axiom), and adherence to these properties is checked by an automatic audit tool that also runs leanchecker and nanoda [3] for additional sanity checking.
Porting blazing-smtlib to Lean was not trivial. Despite the fact that both languages are influenced by the language ML, their main intended use is different: Rust is a systems programming language with focus on speed and avoidance of memory manipulation bugs, while Lean is a language with focus on theorem proving. Their type systems thus excel at different tasks over a classic typed language. Rust allows precisely controlling memory ownership and borrowing, while Lean allows precisely controlling contract requirements and guarantees as well as proving propositions about behaviour.
During porting, we discovered that most Rust constructs we use map into Lean fairly well. However, since Lean does not offer precise control over memory and mutation, it is difficult to write highly performant code as the decisions on memory layout, allocations, and mutable assignments are made by the compiler. As an unfortunate allocation on a hot path can decrease the performance drastically when performed for each byte or token, fine-tuned optimisations were much more crucial than in the case of Rust.
Even with proper inlining directives, we found our ported code to be slower than desirable , so we wanted to optimise it through rewriting without impacting correctness. Fortunately, this is a speciality of Lean: it is possible to write theorems about expected behaviour of e.g. a lexer and prove that both the ported and the optimised version fulfill the contract, avoiding bugs as long as the theorems are stated correctly and fully describe the expected behaviour.
In addition to running Lean lexers and parsers through the Rust tests we use to pin the behaviour of blazing-smtlib, we formalised our reading of the SMT-LIB syntax as described in the specification documents in Lean, and proved that the lexers, parsers, and reader correspond to the expected behaviour with handlers that reject non-standard commands. We visualise how we detect inconsistencies between our lexers, parsers, and their formalisms in Figure 4. Every
We show the measurements of ported and optimised versions in Figure 5.

Fig. 4: How the library components are checked against each other for consistency. Tests may not catch all bugs, and proving that the behaviour of lexers and parsers follows their formalisms adds an additional assurance.
inconsistency detected while working on optimising is then a problem that triggers an investigation, minimising the potential for uncaught bugs.
The lexer proofs were done successively through these links:
- The lexer formalism.
- A naïve lexer that steps through the input slices byte by byte, performing no batching.
- A faithful Rust port, using runs, batches and eager zero-copy dispatch, throwing away batches when each lexer call ends (discussed in Subsection 4.1).
- An improved lexer that avoids throwing away batches and just clears their length (unlike Rust, this poses no problems in Lean).
- The optimised lexer that turns the Nat (big integer) types inside the hot path into USize (machine-sized type) where possible in correspondence to Rust usize. As the natural way to work with numbers (including indexes) in Lean is by using big integers, USize handling is tricky and requires careful changes. This lexer is exposed to the users as it is the fastest.
The parser proofs were done successively through these links:
- The formalisms of all parsers.
- A faithful Lean port of all parsers. We did not port token-consuming attempts for simplicity.
- A fused script parser. It walks the buffer of tokens itself instead of using peek/next on the batch cursor for maximum performance, and reduces the number of functions by essentially manual inlining.
While our formalisation and proof effort found no faults with reading SMT-LIB files, we found two places in our combinators where they called an inner parser with an empty cursor, in violation of the parser contract. It also prompted us to rethink our mechanisms of lexer-mode changes and locations where a handler should be called (e.g. always on the closing parenthesis for command ends), ultimately leading to a cleaner and more consistent API.
API and Naming. Some differences are forced by the languages' import and naming discipline. In Rust, we keep every public item prefixed Smt, as library types such as Symbol or Term could collide with the user types for these concepts, cluttering autocompletion. In Lean, it is more usual to refer to types prefixed by the namespace, so this problem disappears. However, there are many places where the namespace name must be written. As BlazingSmtlib would be cumbersome to type, we opted for BSmtLib in the Lean port.
6 Evaluation
We have evaluated the performance of our library on 9,201 files from the 2025 SMT-LIB corpus against comparable tools: publicly available SMT-LIB parsers and solvers. Our evaluation compared lexer performance, full-parse performance (checking for syntactic but not semantic errors), and semantic performance (checking for both syntactic and semantic errors).
Tool search. We performed a search of SMT-LIB parsers and tools and rejected those that are not production-viable due to commonly encountered stack overflows, timeouts under generous conditions, etc. We also excluded aws-smt-ir, as its lexing and parsing results are almost exactly the same as the much more popular smt2parser, which it is based on.
Benchmark selection. For benchmarks, we applied the SMT-COMP 2026 rule 4 [49] to reduce the weight of overrepresented benchmarks in the corpus and speed up the measurement. After selecting one file per family, we have drawn the others via sorting them by the SHA-256 hash of their file paths. This resulted in selection of 78,010 files. We excluded 57 files over 200 MB from evaluation due memory and time limits and 68,752 files under 200 kB as unsuitable for evaluation as their startup time significantly impacts the data⁷. As such, we used 5,629 non-incremental and 3,572 incremental files for the plots and evaluation.
Lexing and parsing. For parsers, we wrote probes that apply the most similar conditions to all parsers: the file is loaded into memory, the in-process measurement is started, its bytes are fed to the parser (as a batch if possible), and the measurement is ended once processing is done. A handler that counts commands is used, and we print the success/error result and count afterwards to make sure the parser checks the syntax. We also measured lexing performance
⁷ We show the data for our decision in Figure 10 in Appendix B for parsers where the lexers are separable from parsers, using the same probe but only running the lexer. For a sanity check, we ran the probes for our tools and the Dolmen probe in a hash-building mode, and they agreed on all corpus files except two where '(exit)(exit)' appears. In parsing mode, Dolmen continues after the first '(exit)' while our parsing stops.
Well-formedness. As we wanted to show the real-life performance a user may expect when using our library, we wrote a toy well-formedness checker that accepts or rejects in accordance with SMT-LIB semantics; this requires keeping bindings, operations, etc. in memory similarly to a solver. After a preliminary comparison with strict Dolmen type-checker, we adjusted the checker behaviour on some constructs so it agrees with Dolmen on acceptance of files in the corpus. We then measured against Dolmen, our solver Roole, and other well-known solvers on non-incremental files stripped of commands such as (check-sat). While we tried to make the measurement as fair as possible, it represents an unusual mode of operation for solvers: they may use techniques such as term sharing that decrease command-processing performance in favour of faster solving. The measurements do not suggest anything about solving performance.
Measurement setup. We ran our measurements on an x86_64 AMD Ryzen 9950X3D machine running under Windows WSL2 with a 78 GB memory limit. We measured in parallel on 16 cores, with a 60 second timeout per run. The first run decided acceptance and was timed, then repeated up to 9 more times if running under a 100 millisecond budget. For the final results, we chose the fastest run. We only used files accepted by the tools (not errors or timeouts) for visualisation and computation of geometric mean.
6.1 Measurement Results
Our lexer and parsers have accepted all of the measured files, with reported token/command counts equal to those reported for other lexers/parsers that accepted the file. Our well-formedness checker matched Dolmen in acceptance where Dolmen reached a verdict.
We show our cleaned measurement results in Figure 5, and the speedup ratios of blazing-smtlib and BSmtLib in Figure 6. blazing-smtlib is at least 2.5× faster than the best competitor on every file, and more than 6× on a geometric mean of files. BSmtLib is more than 1.5× faster than the fastest competitor on a geometric mean of files, although only 0.5× as fast on worst-case files.
In well-formedness checking, our Rust well-formedness checker outperforms all other tools on geometric mean, but loses to Yices 2.7.0 on 10 files and to MathSAT 5.6.18 on 1. The Lean well-formedness checker holds its ground to most competitors on geometric mean, but Yices is faster, even 200× faster in the worst case. We investigated the Yices source code; its lexer and parser are written very efficiently, allowing it to reach this level of performance despite the additional burden of performing term sharing.

Lexers (9201 files)
Parsers (9201 files)
Well-formedness checking (5629 files, non-incremental)
Fig. 5: Measurements of our tools against other lexers, parsers, and executable tools that can be used to check well-formedness of SMT-LIB scripts. The left column shows the geometric-mean throughput. The right column shows the percentage of files that are processed with at least the given throughput, with time-axis differences corresponding to a speedup/slowdown by a ratio. Most tools have a highly consistent shape; some solvers perform noticeably slower processing on certain files, which lowers their mean but may be desirable to speed up solving.

Fig. 6: Ratio of time taken by blazing-smtlib, BSmtLib, and the well-formedness checkers against other lexers, parsers, and executable tools. Each file/solver combination is shown separately. The files are sorted by the average number of bytes per token. Speedups tend to be consistent, longer tokens exhibiting slight trends in some comparisons. On files with very long tokens, some tools become slower relatively to ours due to their higher per-byte work.
7 Conclusion & Future Work
We presented new parsing libraries for SMT-LIB 2, blazing-smtlib written in Rust and its port BSmtLib written in Lean. We discussed their composable API which allows extension to non-standard SMT-LIB commands, the implementation in Rust with the major speed-related decisions, its port with Lean-specific optimisations (the potential for bugs minimised by testing and correspondence to our formalised reading of SMT-LIB syntax), and evaluated their performance. On a representative sample of the 2025 SMT-LIB corpus, blazing-smtlib was more than 6 times faster than previous parsing libraries on the geometric mean, and BSmtLib was faster or comparable to them. Our libraries can ease the development of SMT-LIB solvers and proof-checkers, metadata summarisers, and even tools requiring extensions such as optimisation solvers and SV-LIB verifiers. Lean users can now also easily use the SMT-LIB corpus for tasks such as optimising automated tactics. In general, our libraries let users care less about the SMT-LIB parsing and its performance and focus on their core tasks.
In the next release of our tools Roole and Roolean, we plan to switch the used parsers to blazing-smtlib and BSmtLib, respectively. Since the parser is a part of the trusted codebase in Roolean [38], adding a formalisation of SMT-LIB semantics built on our formalised reading of SMT-LIB syntax would allow even greater trust in the proof-checker result.
Acknowledgments. This work was partially funded by a gift from Amazon.
Disclosure of Interests. The authors declare that there is no other competing interest besides the acknowledged funding and the support through their affiliations.
AI Declaration. We used Claude Code (mainly the models Fable 5.1 and Opus 5.5) for development of the library and the artefacts supporting this paper, including those used to generate figures. This paper is completely human-written, with Claude Code used only in a helper role, especially for finding references and checking consistency. AI-generated code is reviewed with scrutiny corresponding to its importance.
In the Rust version of blazing-smtlib, AI is used only for experiments and carefully reviewed changes where the semantic shape is clear but manual implementation cumbersome, with the API shape of the library decided by the maintainer (first author).
The Lean version, a port from Rust with Lean-specific changes, is written and managed by AI under human guidance, including proofs. Our formalised reading of SMT-LIB syntax was generated by AI, reviewed by the maintainer and iterated upon.
The tests, written in Rust and used to test both versions of the library, are managed by AI under human guidance. The 2025 SMT-LIB corpus is used as an additional test.
Data Availability Statement. blazing-smtlib and BSmtLib are available in a single GitHub repository [35]. Additionally, blazing-smtlib is published on the persistent Rust package repository crates.io [34]. The artefact to this paper that contains tools for reproduction of measurements and figures is available at https://doi.org/10.5281/zenodo.23362806 [33].
References
-
Amrollahi, D., Preiner, M., Niemetz, A., Reynolds, A., Charikar, M., Tinelli, C., Barrett, C.W.: Towards SMT solver stability via input normalization. In: Irfan, A., Kaufmann, D. (eds.) Proceedings of the 25th Conference on Formal Methods in Computer-Aided Design, FMCAD 2025, Menlo Park, CA, USA, October 6-10, 2025. TU Wien Academic Press (2025). https://doi.org/10.34727/2025/ISBN.978-3-85448-084-6_14
-
Backes, J., Bolignano, P., Cook, B., Dodge, C., Gacek, A., Luckow, K., Rungta, N., Tkachuk, O., Varming, C.: Semantic-based automated reasoning for AWS access policies using SMT. In: 2018 Formal Methods in Computer Aided Design (FMCAD). pp. 1–9 (2018). https://doi.org/10.23919/FMCAD.2018.8602994
-
Bailey, C.: GitHub - nanoda. https://github.com/ammkrn/nanoda_lib (2026), our audit was performed using version 0.4.23.
-
Barbosa, H., Barrett, C.W., Brain, M., Kremer, G., Lachnitt, H., Mann, M., Mohamed, A., Mohamed, M., Niemetz, A., Nötzli, A., Ozdemir, A., Preiner, M., Reynolds, A., Sheng, Y., Tinelli, C., Zohar, Y.: cvc5: A versatile and industrial-strength SMT solver. In: Fisman, D., Rosu, G. (eds.) Tools and Algorithms for the Construction and Analysis of Systems - 28th International Conference, TACAS 2022, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2022, Munich, Germany, April 2-7, 2022, Proceedings, Part I. Lecture Notes in Computer Science, vol. 13243, pp. 415-442. Springer (2022). https://doi.org/10.1007/978-3-030-99524-9_24
-
Barrett, C., Fontaine, P., Tinelli, C.: The SMT-LIB standard version 2.5 (release 2015-06-28). Tech. rep., Department of Computer Science, The University of Iowa (Jun 2015), https://smt-lib.org/papers/smt-lib-reference-v2.5-r2015-06-28.pdf, SMT-LIB 2.5 specification document, latest revision as of writing
-
Barrett, C., Fontaine, P., Tinelli, C.: The SMT-LIB standard version 2.6 (release 2024-09-20). Tech. rep., Department of Computer Science, The University of Iowa (Sep 2024), https://smt-lib.org/papers/smt-lib-reference-v2.6-r2024-09-20.pdf, SMT-LIB 2.6 specification document, latest revision as of writing
-
Barrett, C., Fontaine, P., Tinelli, C.: The SMT-LIB standard version 2.7 (release 2026-09-09). Tech. rep., Department of Computer Science, The University of Iowa (Sep 2026), https://smt-lib.org/papers/smt-lib-reference-v2.7-r2026-09-09.pdf, SMT-LIB 2.7 specification document, latest SMT-LIB 2 revision as of writing
-
Barrett, C., Stump, A., Tinelli, C.: The SMT-LIB standard – version 2.0. In: Proceedings of the 8th International Workshop on Satisfiability Modulo Theories (SMT 2010), Edinburgh, Scotland (Jul 2010), http://theory.stanford.edu/~barrett/pubs/BST10.pdf, a workshop paper on the standard
-
Barrett, C., Stump, A., Tinelli, C.: The SMT-LIB standard version 2.0 (release 2012-09-09). Tech. rep., Department of Computer Science, The University of Iowa (Sep 2012), https://smt-lib.org/papers/smt-lib-reference-v2.0-r12.09.09.pdf, SMT-LIB 2.0 specification document, latest revision as of writing
-
Baudet, M.: smt2parser - crates.io: Rust package registry. https://crates.io/crates/smt2parser/0.6.1 (2021)
-
Beyer, D., Ernst, G., Jonáš, M., Lingsch-Rosenfeld, M.: SV-LIB 1.0: A standard exchange format for software-verification tasks (2025), https://arxiv.org/abs/2511.21509
-
Bjørner, N., Phan, A.D., Fleckenstein, L.: νZ - an optimizing SMT solver. In: Baier, C., Tinelli, C. (eds.) Tools and Algorithms for the Construction and Analysis of Systems. pp. 194–199. Springer Berlin Heidelberg, Berlin, Heidelberg (2015)
-
Blanchette, J.C., Böhme, S., Paulson, L.C.: Extending Sledgehammer with SMT solvers. In: Bjørner, N.S., Sofronie-Stokkermans, V. (eds.) Automated Deduction - CADE-23 - 23rd International Conference on Automated Deduction, Wrocław, Poland, July 31 - August 5, 2011. Proceedings. Lecture Notes in Computer Science, vol. 6803, pp. 116–130. Springer (2011). https://doi.org/10.1007/978-3-642-22438-6_11
-
Bonichon, R., Déharbe, D., Dobal, P., Tavares, C.: SMTpp: preprocessors and analyzers for SMT-LIB. In: Proceedings of the 13th International Workshop on Satisfiability Modulo Theories (SMT 2015) (2015), https://rbonichon.github.io/papers/smtpp-smt15.pdf
-
Böving, H.: GitHub - Leanwuzla. https://github.com/hargoniX/Leanwuzla (2026)
-
Böving, H., Bhat, S., Cicolini, L., Keizer, A.C., Frénot, L., Mohamed, A., Stefanesco, L., Khan, H., Clune, J., Barrett, C.W., Grosser, T.: Interactive bitvector reasoning using verified bit-blasting. Proc. ACM Program. Lang. 9(OOPSLA2), 3259–3285 (2025). https://doi.org/10.1145/3763167
-
Bury, G.: Dolmen: A validator for SMT-LIB and much more. In: Nadel, A., Niemetz, A. (eds.) Proceedings of the 19th International Workshop on Satisfiability Modulo Theories co-located with 33rd International Conference on Computer Aided Verification (CAV 2021), Online (initially located in Los Angeles, USA), July 18-19, 2021. CEUR Workshop Proceedings, vol. 2908, pp. 32-39. CEUR-WS.org (2021), https://ceur-ws.org/Vol-2908/short4.pdf
-
Cameron, R.D., Herdy, K.S., Lin, D.: High performance XML parsing using parallel bit stream technology. In: Chechik, M., Vigder, M.R., Stewart, D.A. (eds.) Proceedings of the 2008 conference of the Centre for Advanced Studies on Collaborative Research, October 27-30, 2008, Richmond Hill, Ontario, Canada. pp. 222-235. IBM (2008). https://doi.org/10.1145/1463788.1463811
-
Cruanes, S.: GitHub - smtlib-utils. https://github.com/c-cube/smtlib-utils/tree/v0.5 (2024)
-
Dutertre, B.: Yices 2.2. In: Biere, A., Bloem, R. (eds.) Computer Aided Verification - 26th International Conference, CAV 2014, Held as Part of the Vienna Summer of Logic, VSL 2014, Vienna, Austria, July 18-22, 2014. Proceedings. Lecture Notes in Computer Science, vol. 8559, pp. 737-744. Springer (2014). https://doi.org/10.1007/978-3-319-08867-9_49
-
Gario, M., Micheli, A.: PySMT: a solver-agnostic library for fast prototyping of SMT-based algorithms. In: Proceedings of the 13th International Workshop on Satisfiability Modulo Theories (SMT 2015) (2015), https://andrea.micheli.website/papers/pysmt.pdf
-
Griggio, A.: smtlib2parser: A generic parser for SMT-LIB v2. https://es-static.fbk.eu/people/griggio/misc/smtlib2parser.html (2013)
-
Heller, M., Whalen, M., Dutertre, B.: aws-smt-ir - crates.io: Rust package registry. https://crates.io/crates/aws-smt-ir/0.3.0 (2023)
-
Hu, J.: yaspar - crates.io: Rust package registry. https://crates.io/crates/yaspar/2.7.2 (2026)
-
Langdale, G., Lemire, D.: Parsing gigabytes of JSON per second. VLDB J. 28(6), 941-960 (2019). https://doi.org/10.1007/S00778-019-00578-5
-
Li, Y., Katsipoulakis, N.R., Chandramouli, B., Goldstein, J., Kossmann, D.: Mison: A fast JSON parser for data analytics. Proc. VLDB Endow. 10(10), 1118–1129 (2017). https://doi.org/10.14778/3115404.3115416, http://www.vldb.org/pvldb/vol10/p1118-li.pdf
-
Megginson, D.: Simple API for XML. http://www.saxproject.org/ (2004)
-
Meng, J., Quigley, C., Paulson, L.C.: Automation for interactive proof: First prototype. Inf. Comput. 204(10), 1575–1596 (2006). https://doi.org/10.1016/J.IC.2005.05.010
-
Mohamed, A., Mascarenhas, T., Khan, H., Barbosa, H., Reynolds, A., Qian, Y., Tinelli, C., Barrett, C.: lean-smt: An SMT tactic for discharging proof goals in Lean. In: Piskac, R., Rakamarić, Z. (eds.) Computer Aided Verification. pp. 197–212. Springer Nature Switzerland, Cham (2025)
-
de Moura, L., Bjørner, N.: Z3: An efficient SMT solver. In: Ramakrishnan, C.R., Rehof, J. (eds.) Tools and Algorithms for the Construction and Analysis of Systems. pp. 337–340. Springer Berlin Heidelberg, Berlin, Heidelberg (2008)
-
de Moura, L., Ullrich, S.: The Lean 4 theorem prover and programming language. In: Automated Deduction – CADE 28: 28th International Conference on Automated Deduction, Virtual Event, July 12–15, 2021, Proceedings. p. 625–635. Springer-Verlag, Berlin, Heidelberg (2021). https://doi.org/10.1007/978-3-030-79876-5_37
-
Niemetz, A., Preiner, M.: Bitwuzla. In: Enea, C., Lal, A. (eds.) Computer Aided Verification - 35th International Conference, CAV 2023, Paris, France, July 17-22, 2023, Proceedings, Part II. Lecture Notes in Computer Science, vol. 13965, pp. 3–17. Springer (2023). https://doi.org/10.1007/978-3-031-37703-7_1
-
Onderka, J.: Artefact for the paper “Blazing-Fast SMT-LIB Parsing for Rust and Lean” (2026). https://doi.org/10.5281/zenodo.23362806
-
Onderka, J.: blazing-smtlib - crates.io: Rust package registry. https://crates.io/crates/blazing-smtlib (2026), version 0.1.0 is discussed in this paper.
-
Onderka, J.: GitHub - blazing-smtlib. https://github.com/onderjan/blazing-smtlib (2026), the repository also contains the Lean port BSmtLib. Version 0.1.0 is discussed in this paper.
-
Onderka, J.: GitHub - Roole. https://github.com/onderjan/roole (2026)
-
Onderka, J.: GitHub - Roolean. https://github.com/onderjan/roolean (2026)
-
Onderka, J., Biere, A., Fleury, M.: Lean certified bitvector solving without bitblasting. In: Dutertre, B., Könighofer, B. (eds.) Proceedings of the 26th Conference on Formal Methods in Computer-Aided Design (FMCAD 2026). pp. 147–154. Conference Series: Formal Methods in Computer-Aided Design, TU Wien (2026). https://doi.org/10.34727/2026/isbn.978-3-85448-093-8_20
-
Palikareva, H., Cadar, C.: Multi-solver support in symbolic execution. In: Sharygina, N., Veith, H. (eds.) Computer Aided Verification. pp. 53–68. Springer Berlin Heidelberg, Berlin, Heidelberg (2013)
-
Pereira, J.M., Marques, F., Adão, P., Ait-El-Hara, H.R., Andrès, L., Carcano, A., Chambart, P., Maksimović, P., Santos, N., Santos, J.F.: Smt.ml: A multi-backend frontend for SMT solvers in OCaml. In: Junges, S., Katz, G. (eds.) Tools and Algorithms for the Construction and Analysis of Systems. pp. 23–44. Springer Nature Switzerland, Cham (2026)
-
Pimpalkhare, N., Mora, F., Polgreen, E., Seshia, S.A.: MedleySolver: Online SMT algorithm selection. In: Li, C.M., Manyà, F. (eds.) Theory and Applications of Satisfiability Testing – SAT 2021. pp. 453–470. Springer International Publishing, Cham (2021)
-
Preiner, M., Schurr, H., Barrett, C.W., Fontaine, P., Niemetz, A., Tinelli, C.: SMT-LIB release 2025 (incremental benchmarks) (version 2025.05.22) (May 2025). https://doi.org/10.5281/ZENODO.15493096
-
Preiner, M., Schurr, H., Barrett, C.W., Fontaine, P., Niemetz, A., Tinelli, C.: SMT-LIB release 2025 (non-incremental benchmarks) (version 2025.08.04) (Aug 2025). https://doi.org/10.5281/ZENODO.16740866
-
Qian, Y., Clune, J., Barrett, C., Avigad, J.: Lean-Auto: An interface between Lean 4 and automated theorem provers. In: Piskac, R., Rakamarić, Z. (eds.) Computer Aided Verification. pp. 175–196. Springer Nature Switzerland, Cham (2025)
-
Sakai, M.: language-smtlib - Hackage: The Haskell package registry. https://hackage.haskell.org/package/language-smtlib-0.2.0.0 (2026)
-
Schreiber, D., Niemetz, A., Preiner, M.: Massively parallel bit-precise verification with Bitwuzla and Mallob. In: Junges, S., Katz, G. (eds.) Tools and Algorithms for the Construction and Analysis of Systems. pp. 170–191. Springer Nature Switzerland, Cham (2026)
-
Schurr, H.J., Bobot, F., Preiner, M., Niemetz, A., Barrett, C., Fontaine, P., Tinelli, C.: Exploring the SMT-LIB benchmark library. In: Junges, S., Katz, G. (eds.) Tools and Algorithms for the Construction and Analysis of Systems. pp. 150–169. Springer Nature Switzerland, Cham (2026)
-
Scott, J., Niemetz, A., Preiner, M., Nejati, S., Ganesh, V.: MachSMT: A machine learning-based algorithm selector for SMT solvers. In: Groote, J.F., Larsen, K.G. (eds.) Tools and Algorithms for the Construction and Analysis of Systems. pp. 303–325. Springer International Publishing, Cham (2021)
-
Winterer, D., Jonás, M., Kolárik, T.: 21st International Satisfiability Modulo Theories Competition (SMT-COMP 2026): Rules and procedures. https://smt-comp.github.io/2026/rules.pdf (2026)
-
Winterer, D., Jonás, M., Kolárik, T.: The SMT competition 2026 (SMT-COMP 2026). https://smt-comp.github.io/2026/ (2026), the 2026 competition has used the 2025 SMT-LIB benchmark corpus for evaluation.
-
Wintersteiger, C.M., Hamadi, Y., de Moura, L.: A concurrent portfolio approach to SMT solving. In: Bouajjani, A., Maler, O. (eds.) Computer Aided Verification. pp. 715–720. Springer Berlin Heidelberg, Berlin, Heidelberg (2009)
A Additional Corpus Data for Lexer Choices

share of tokens

share of files with the category

Fig. 7: Share of bytes and tokens in the whole 2025 SMT-LIB corpus when considering layout (whitespace and comments). Symbols, whitespace, and parentheses dominate both in bytes and token counts, with over half of bytes being symbols.

longest run: 1 of all tokens, 3.52 M without layout
longest run: 1 of all tokens, 483 without layout
longest run: 26 of all tokens, none without layout
longest run: 1 of all tokens, 2.05 k without layout

longest run: 1 of all tokens, 2 without layout
longest run: 1 of all tokens, 400 without layout

longest run: 1 of all tokens, 3 without layout
longest run: 1 of all tokens, 4 without layout

Fig. 8: Token runs in the whole 2025 SMT-LIB corpus, when excluding layout (whitespace and comments) and considering it either end the run or continue. There are almost no runs except for heavy runs of the closing parenthesis in some files and runs interrupted by whitespace for symbols. This is the reason for the preference of the closing parenthesis in Subsection 4.1.

Fig.9: Token lengths in the whole 2025 SMT-LIB corpus, including layout (whitespace and comments). Overall, the token lengths are usually short, under 10 bytes, usually making long-run techniques unnecessary. The major exception to this are comments and quoted symbols, which are however not represented in the corpus enough to matter much. The jump in comment size is due to the comments ‘; success’ (10 bytes including its semicolon and line terminator). The longest string in the corpus is a generated adversarial input. Its content without the enclosing double quotes is 1 MB.
B Additional Measurement Data

Well-formedness checking (65239 files 1.2 MB, non-incremental)

Fig. 10: The reason for our decision to remove files under 200 kB from evaluation. The plot is linear over ns/byte and file size (i.e. lesser is better), zoomed in to show the startup behaviour. The startup impact is significant for small files even when performing in-probe measurement, as we do on the lexers and parsers. We consider 200 kB to be a reasonable choice that mostly sanitises the startup effect and keeps enough benchmarks for measurement.

Fig. 11: How much work is spent lexing in comparison to the full lexer-parser pipeline. Most parser libraries spend around 50%, suggesting the lexing side and the parsing side are balanced and it is not easy to improve the combined performance by only speeding up one of them. Dolmen is a notable exception.