Bitvector Theory (SMT-LIB)
The bitvector theory is one of the standard theories supported by SMT solvers, alongside arrays, integer and floating-point arithmetic, uninterpreted functions, and algebraic data types. In an SMT formulation, a theory T assigns meaning to theory-specific symbols by fixing a class of allowable interpretations. The satisfiability problem for bitvector logic then asks, for a given formula, whether it is satisfied by some bitvector interpretation (T-satisfiable), by none (T-unsatisfiable), or by all (T-valid) [1].
Core notation
The notation used in SMT formulations of bitvector logic is summarized in Table I of the source paper and includes the following [1]:
BV[n]— the sort for bitvectors of lengthn(e.g.,BV[8]denotes 8-bit bitvectors).+[n],−[n],×[n],÷[n]— arithmetic operations performed modulo2^n.x ++ y— bitvector concatenation ofxandy.x[msb : lsb]— bitvector extraction over the indicated bit range.ite(c, x, y)— an if-then-else operator with the same meaning asxin an interpretation I whereI ⊨ c, andyotherwise.
The sort BV[8] is used explicitly in the paper's running example, where an architecture Arch is modeled as a term taking bitvector inputs and producing a bitvector output through nested ite expressions [1].
Role in hardware verification and synthesis
Bitvector theory is the semantic backbone for formal reasoning about fixed-width hardware. The hwtypes Python library, which is the formal-analysis companion of the Magma hardware description language, is explicitly described as having semantics that match those of the SMT-LIB theory of bitvectors [2]. This alignment allows circuits written in Magma to be encoded directly as SMT formulas over bitvectors by tracing the inputs of a circuit and the outputs of its architectural state to the outputs of the circuit and the inputs of its architectural state [2].
Solvers and tooling
Boolector is used as the SMT solver for bitvector (and related) queries in the source work [2]. Intermediate representations (IRs) are specified directly in SMT using the pysmt library, and the synthesized rewrite-rule synthesis tool relies on the bitvector theory to determine both the existence of rewrite rules (UNSAT results, indicating no valid rewrite) and the construction of concrete rules (SAT results) [2].
Practical use: instruction selection rewrite rules
The theory is used to encode the problem of synthesizing instruction selection rewrite rules from RTL: an IR operation expressed in bitvector logic is checked for equivalence with an architectural RTL also modeled in bitvector logic, and the SMT solver returns a rule (or proves that none exists) [3]. The paper reports synthesizing rewrite rules for 16-bit processing elements and for the RISC-V ISA, including extensions with floating-point operations expressed in the bitvector sort, in seconds; multi-instruction sequences for pseudo-operations take at most 90 seconds [1] [3].
Related concepts
- SMT (Satisfiability Modulo Theories) — the general framework under which the bitvector theory is solved.
- SMT-LIB — the standard language/theory specification that defines the bitvector theory's syntax and semantics.
- hwtypes — a Python library whose semantics are aligned with the SMT-LIB theory of bitvectors and which is used in conjunction with the Magma HDL.
- Boolector — an SMT solver used in the source work for bitvector queries.