Skip to main content
The Z3 Java API provides an object-oriented interface to Z3. All classes are in the com.microsoft.z3 package.

Core Classes

Context

The central class that manages all Z3 objects.
class
The main context class. All Z3 objects are created and managed through a context.
Solver
Create a new solver instance.
Params
Create a parameter set for configuring solvers and tactics.

Solver

Incremental satisfiability solver.
class
Main interface for checking satisfiability.

Status

Enumeration for solver results.
enum

Model

A satisfying assignment for constraints.
class

Expression Classes

Expr

Base class for all expressions.
abstract class

BoolExpr

Boolean expressions.
class extends Expr
Represents Boolean formulas.
BoolExpr
Create the true constant.
BoolExpr
Create the false constant.
BoolExpr
Create a Boolean variable.
BoolExpr

ArithExpr

Base class for arithmetic expressions (Int and Real).
abstract class extends Expr
Base for IntExpr and RealExpr.

IntExpr

Integer expressions.
class extends ArithExpr
Represents integer terms.
IntExpr
Create integer constants.
IntExpr
Create integer variables.

RealExpr

Real (rational) expressions.
class extends ArithExpr
Represents real terms.
RealExpr
Create real constants.
RealExpr
Create real variables.

Arithmetic Operations

ArithExpr

Comparison Operations

BoolExpr

Bit-Vector Operations

BitVecExpr

Array Operations

ArrayExpr

Quantifiers

BoolExpr
Create universal quantifier.
BoolExpr
Create existential quantifier (same signature as mkForall).
Pattern
Create a pattern (trigger) for quantifiers.

Datatypes

DatatypeSort

Tactics and Goals

Tactic

Optimization

Optimize

Utilities

class
class
class

SMT-LIB Parsing

BoolExpr[]
Parse SMT-LIB2 format string.
BoolExpr[]
Parse SMT-LIB2 format file (same parameters as parseSMTLIB2String).

Exception Handling

class extends Exception
Exception thrown by Z3 operations.

Best Practices

Use Try-With-Resources

Always use try-with-resources for Context to ensure cleanup.

Check Status First

Always check solver status before accessing results.

Enable Model Generation

Set configuration if you need models.

Use Typed Expressions

Prefer typed expressions for safety.

Resources

Official Java API Docs

Complete Javadoc documentation

Java Examples

Example programs on GitHub

Getting Started

Learn the basics

Z3 Guide

Interactive tutorial