mirror of
https://github.com/Z3Prover/z3
synced 2025-05-09 00:35:47 +00:00
[WIP] More TS Binding Features (#6412)
* feat: basic quantfier support * feat: added isQuantifier * feat: expanded functions * wip: (lambda broken) * temp fix to LambdaImpl typing issue * feat: function type inference * formatting with prettier * fix: imported from invalid module * fix isBool bug and dumping to smtlib * substitution and model.updateValue * api to add custom func interps to model * fix: building * properly handling uint32 -> number conversion in z3 TS wrapper * added simplify * remame Add->Sum and Mul->Product * formatting
This commit is contained in:
parent
5e30323b1a
commit
ede9e5ffc2
9 changed files with 1383 additions and 332 deletions
36
src/api/js/examples/high-level/using_smtlib2.ts
Normal file
36
src/api/js/examples/high-level/using_smtlib2.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
// @ts-ignore we're not going to bother with types for this
|
||||
import process from 'process';
|
||||
import { init } from '../../build/node';
|
||||
import assert from 'assert';
|
||||
|
||||
(async () => {
|
||||
let { Context, em } = await init();
|
||||
let z3 = Context('main');
|
||||
|
||||
const x = z3.BitVec.const('x', 256);
|
||||
const y = z3.BitVec.const('y', 256);
|
||||
const z = z3.BitVec.const('z', 256);
|
||||
const xPlusY = x.add(y);
|
||||
const xPlusZ = x.add(z);
|
||||
const expr = xPlusY.mul(xPlusZ);
|
||||
|
||||
const to_check = expr.eq(z3.Const('test', expr.sort));
|
||||
|
||||
const solver = new z3.Solver();
|
||||
solver.add(to_check);
|
||||
const cr = await solver.check();
|
||||
console.log(cr);
|
||||
assert(cr === 'sat');
|
||||
|
||||
const model = solver.model();
|
||||
let modelStr = model.sexpr();
|
||||
modelStr = modelStr.replace(/\n/g, ' ');
|
||||
console.log("Model: ", modelStr);
|
||||
|
||||
const exprs = z3.ast_from_string(modelStr);
|
||||
console.log(exprs);
|
||||
|
||||
})().catch(e => {
|
||||
console.error('error', e);
|
||||
process.exit(1);
|
||||
});
|
|
@ -1,3 +1,4 @@
|
|||
// @ts-ignore we're not going to bother with types for this
|
||||
import process from 'process';
|
||||
import { init, Z3_error_code } from '../../build/node';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue