Skip to main content

Overview

The Sort API provides functions for creating and manipulating Z3 sorts (types). Sorts are used to define the domains of constants, variables, and functions.

Types

Z3_sort

A kind of AST used to represent types/sorts in Z3.

Z3_sort_kind

Enumeration of different sort kinds:

Built-in Sorts

Z3_mk_bool_sort

Create the Boolean type.
Z3_sort
Boolean sort
Description: This type is used to create propositional variables and predicates. Example:

Z3_mk_int_sort

Create the integer type.
Z3_sort
Integer sort
Description: This is mathematical integers (unbounded), not machine integers. For machine integers, use bit-vectors. Example:

Z3_mk_real_sort

Create the real number type.
Z3_sort
Real sort
Description: This is mathematical reals, not floating-point numbers. Example:

Z3_mk_bv_sort

Create a bit-vector type of given size.
Z3_sort
Bit-vector sort
Description: Bit-vectors can be used to model machine integers and perform bit-level operations. Example:

Z3_mk_finite_domain_sort

Create a named finite domain sort.
Z3_sort
Finite domain sort
Description: To create constants in this domain, use numeric constants from 0 to size-1.

Uninterpreted Sorts

Z3_mk_uninterpreted_sort

Create a free (uninterpreted) type using the given name.
Z3_sort
Uninterpreted sort
Description: Two free types are considered the same if and only if they have the same name. Example:

Z3_mk_type_variable

Create a type variable.
Z3_sort
Type variable
Description: Functions using type variables can be applied to instantiations that match the signature.

Composite Sorts

Z3_mk_array_sort

Create an array type [domain -> range].
Z3_sort
Array sort
Description: Arrays are commonly used to model heap/memory in software verification. Example:

Z3_mk_tuple_sort

Create a tuple sort.
Z3_sort
Tuple sort
Example:

Z3_mk_seq_sort

Create a sequence sort.
Z3_sort
Sequence sort
Example:

Z3_mk_re_sort

Create a regular expression sort.
Z3_sort
Regular expression sort

Floating-Point Sorts

Z3_mk_fpa_sort

Create a floating-point sort.
Z3_sort
Floating-point sort
Example:

Z3_mk_fpa_sort_16

Create the half-precision (16-bit) floating-point sort.
Z3_sort
16-bit float sort

Z3_mk_fpa_sort_32

Create the single-precision (32-bit) floating-point sort.
Z3_sort
32-bit float sort

Z3_mk_fpa_sort_64

Create the double-precision (64-bit) floating-point sort.
Z3_sort
64-bit float sort

Z3_mk_fpa_sort_128

Create the quadruple-precision (128-bit) floating-point sort.
Z3_sort
128-bit float sort

Sort Inspection

Z3_get_sort_kind

Return the sort kind.
Z3_sort_kind
Sort kind

Z3_get_sort

Return the sort of an AST node.
Z3_sort
Sort of the expression

Z3_get_bv_sort_size

Return the size of the given bit-vector sort.
unsigned
Size in bits

Z3_get_array_sort_domain

Return the domain sort of an array sort.
Z3_sort
Domain sort

Z3_get_array_sort_range

Return the range sort of an array sort.
Z3_sort
Range sort

Sort Conversion

Z3_sort_to_ast

Convert a sort into an AST node.
Z3_ast
AST representation of sort
Description: Allows using sorts in places that expect AST nodes (e.g., for reference counting).

Complete Example