Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frizensami/smtlib-ext
Fork of https://github.com/stanford-oval/node-smtlib to generate SMT-LIB 2.0 strings for timetable optimizers
https://github.com/frizensami/smtlib-ext
Last synced: 27 days ago
JSON representation
Fork of https://github.com/stanford-oval/node-smtlib to generate SMT-LIB 2.0 strings for timetable optimizers
- Host: GitHub
- URL: https://github.com/frizensami/smtlib-ext
- Owner: frizensami
- License: mit
- Created: 2021-06-30T04:18:44.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-07-03T07:16:43.000Z (over 3 years ago)
- Last Synced: 2024-11-08T23:42:21.045Z (about 2 months ago)
- Language: TypeScript
- Size: 39.1 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY
- License: LICENSE
Awesome Lists containing this project
README
# Node.js API for SMT-LIB 2.0
This is a fork of [Stanford Open Virtual Assistant Lab's Node.js SMT-LIB 2.0 library](https://github.com/stanford-oval/node-smtlib).
It adds new library calls to act as a utility library for [NUSMods](https://github.com/nusmodifications/nusmods), specifically a timetable optimizer.
SMT-LIB 2.0 is an interoperability format to communicate with
different SMT solvers, such as 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))
(check-sat)
```This package provides an high-level API to construct SMT-Lib
expressions, taking care of escaping. A simple example of its usage to assert a boolean condition is and get the SMT-LIB 2.0 string is:
```
const smt = require('smtlib');
let solver = new smt.BaseSolver('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')));// Retrieving an SMT-LIB 2.0 string to pass to Z3
let constraintStr = "";
solver.forEachStatement((stmt: string) => (constraintStr += stmt + '\n'));
```