This repository implements a framework for generalizing SMT solutions.
This work is conducted in partial fulfillment of the module "Formal Methods for Software Engineering" at the Bauhaus University Weimar (Winter Semester 2024).
SMT solvers typically produce single solutions (models) for satisfiable SMT problems. The aim of this project is to generalize single solutions to a meaningful description of multiple solutions. To this end, this project:
- Develops meaningful descriptions of multiple solutions / generalizations,
- Finds and implements algorithms to verify whether generalizations hold for a given formula,
- Tests the algorithms with a comprehensive test suite,
- Provides interactive analysis tools for exploring formula properties
- Z3 Setup and Integration
- Model Enumeration
- First Set of Descriptions
- Boolean (Always, Never True) Verification
- Interval Verification
- Description Test Cases
- Fixed Value Test Cases
- Boolean Test Cases
- User Interaction
- Interval Detection
- Naive / Brute Force
- Binary Search
- Further Testing
- Interval Testing
- Performance Testing
app/src/main/java/generalizing/smt/solutions/fm4se/
├── App.java # Main application class with examples
├── SMTConnector.java # Z3 solver interface
├── InteractiveAnalyzer.java # Interactive analysis session
└── strategies/
├── bool/ # Boolean analysis strategies
│ ├── BooleanStrategy.java
│ ├── ModelBasedBooleanStrategy.java
│ └── FormulaBasedBooleanStrategy.java
└── integer/ # Integer analysis strategies
├── IntegerStrategy.java
├── NaiveIntegerStrategy.java
└── BinarySearchIntegerStrategy.java
- Model-Based Analysis: Examines actual solutions to find patterns
- Formula-Based Analysis: Analyzes logical structure to identify relationships
- Combined Analysis: Uses both approaches for comprehensive results
- Detects:
- Fixed values (variables that are always true/false)
- Implications between variables
- Naive Strategy: Linear expansion
- Binary Search Strategy: Exponential expansion + Binary Search
- Detects:
- Variable bounds
Note that Z3 is not available as a Maven dependency, so we need to manually add it to the project.
- Download Z3 from here
- Create a
libs
directory in theapp
folder and copy:com.microsoft.z3.jar
from Z3's Java bindingslibz3.dll
(Windows) or equivalent for your OS
- The project uses Gradle with the following key configurations:
// Dependencies implementation 'org.sosy-lab:java-smt:3.14.3' implementation files('libs/com.microsoft.z3.jar') // Java version java { toolchain { languageVersion = JavaLanguageVersion.of(17) } } // Native library handling systemProperty 'java.library.path', "${projectDir}/libs"
The project automatically handles native library copying and path configuration through Gradle tasks.
-
Is there a desired output format?
- SMT Formula vs. "representation in a single model-like structure"
- Need to clarify the preferred format for generalized solutions
-
What are the workarounds for bounds in Z3?
- Reference: Lecture example and Z3 issue #6941
- Need to investigate handling of bounded variables and domains
-
What are other interesting generalizations?
- How to navigate the model / solution space?
- Current implementation includes implications and range relationships
- Future work could include more complex patterns
-
What about performance?
- Model Based vs Formula Based
- Linear vs Binary Search for integer analysis
- Current implementation shows binary search is more efficient for large ranges