A Javascript wrapper with a Z3-ish API for SMT-LIB 2.0, the language of Satisfiability Modulo Theories solvers

  • smtlib

Downloads in past


8101.0.04 years ago7 years agoMinified + gzip package size for smtlib in KB


Node.js API for SMT-LIB 2.0
Build Status Coverage Status Dependency Status
SMT-LIB 2.0 is an interoperability format to communicate with different SMT solvers, such as CVC4 or Z3.
The syntax of SMT-LIB is similar to Lisp:
(set-logic QF_ALL_SUPPORTED)
(declare-fun x () Bool)
(declare-fun y () Bool)
(assert (and (or x y) (not x) (not y))

This package provides an high-level API to construct SMT-Lib expressions, taking care of escaping:
const smt = require('smtlib');
let solver = new smt.LocalCVC4Solver('QF_ALL_SUPPORTED');
solver.add(smt.DeclareFun('x', [], 'Bool'))
solver.add(smt.DeclareFun('y', [], 'Bool'))
solver.assert(smt.And(smt.Or('x', 'y'), smt.Not('x'), smt.Not('y')));
solver.checkSat().then(([sat, assignment]) => ...).catch((e) => ...);

The library also includes code to interact with a locally installed CVC4, as an external process.