Quick Start
Create a simple Z3 program:example.js
High-Level API Overview
The high-level API provides a clean, object-oriented interface similar to Z3Py.Initialization
Always start by initializing Z3:The
init() function is async because it loads the WebAssembly module.Creating Variables
Building Expressions
Solving Constraints
Common Examples
Example 1: Solving Linear Equations
Solve the system:- x + y = 10
- x - y = 2
Example 2: Boolean Logic
Solve: (p ∨ q) ∧ (¬p ∨ ¬q)Example 3: Bit-Vector Arithmetic
Example 4: Using Simplifiers
Fromsrc/api/js/examples/high-level/simplifier-example.ts:
Example 5: Parsing SMT-LIB2
Context Isolation
Z3 contexts are isolated from each other. TypeScript types enforce this at compile time:Working with Multiple Contexts
Use templated functions to propagate types:Asynchronous Operations
These operations are async:solver.check()solver.check(assumptions)solver.consequences()tactic.apply()
Using SMT-LIB2 Format
You can parse and work with SMT-LIB2 strings:TypeScript Support
The bindings include full TypeScript definitions:Memory Management
Z3’s WebAssembly module manages memory automatically. Objects are garbage collected when no longer referenced.Error Handling
Next Steps
API Reference
Complete API documentation
Examples
More examples and tutorials
Low-Level API
C-like API documentation
Source Examples
Example code on GitHub
