Skip to main content
The Z3 .NET API provides a managed, object-oriented interface to Z3. All classes are in the Microsoft.Z3 namespace.

Core Classes

Context

The central class that manages all Z3 objects.
class : IDisposable
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.
void
Release all resources. Called automatically with using statement.

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 : 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.
abstract class : Expr
Base for IntExpr and RealExpr.

IntExpr

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

RealExpr

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

IntNum and RatNum

Numeric value classes.
class : ArithExpr
class : RealExpr

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

Version Information

class

Sorts (Types)

class

SMT-LIB Parsing

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

Exception Handling

class : Exception
Exception thrown by Z3 operations.

Best Practices

Use Using Statements

Always use using for Context to ensure cleanup.

Check Status First

Always check solver status before accessing Model.

Enable Model Generation

Set configuration if you need models.

Use Typed Expressions

Prefer typed expressions for safety.

Resources

Official .NET API Docs

Complete API documentation

.NET Examples

Example programs on GitHub

Getting Started

Learn the basics

Z3 Guide

Interactive tutorial