-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
1 parent
5e30323
commit ede9e5f
Showing
9 changed files
with
1,381 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.