The FiniteSets theory was added in Z3 version 4.17.0. Support for
set.range and set.map is partial. Support for set.size exists but without optimization.Overview
The FiniteSets theory provides:- Set construction: Empty sets, singletons, ranges
- Set operations: Union, intersection, difference
- Predicates: Membership, subset
- Functions: Size, map, filter
- Base sorts: Sets over any sort (integers, booleans, custom datatypes, etc.)
Basic Set Operations
Creating Sets
Set Operations
Set Cardinality
Membership and Subset Constraints
Membership Constraints
Subset Relationships
Advanced Operations
Set Mapping
Apply a function to all elements of a set:Set Filtering
Filter elements based on a predicate:Integer Ranges
Support for
set.range is partial in the current implementation. Basic range operations work, but complex range constraints may have limitations.Sets Over Different Sorts
Boolean Sets
Sets of Bit-Vectors
Sets of Custom Datatypes
Practical Examples
Sudoku Constraints
Set Partitioning Problem
C API Reference
The C API for finite sets (defined inapi_finite_set.cpp):
Key Functions
Current Limitations
As noted in the Z3 4.17.0 release notes:set.rangesupport is partial: Basic integer ranges work, but complex range operations may be limitedset.mapsupport is partial: Simple mappings work, but complex transformations may not be fully supportedset.sizelacks optimization: Cardinality constraints work but are not optimized. Performance may be slower for large sets or complex size constraints
See Also
- RELEASE_NOTES.md - Z3 4.17.0 release information
- Arrays - Related theory for arrays and maps
- Datatypes - Custom sorts for set elements
