Repository navigation
[API Coherence] Report for 2026-10-17 - Solver & Optimize APIs #11210
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by API Coherence Checker. A newer discussion is available at Discussion #11214. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
This is the first run of the API Coherence Checker (no prior cache found). Analyzed two core API families in depth: Solver API and Optimize API, across all 8 target language bindings (C++, Java, .NET, Python, TypeScript/JS, OCaml, Go, Rust).
Functions checked: ~51
Z3_solver_*+ 27Z3_optimize_*= 78 C API functionsLanguages covered: 8 (C++, Java, .NET, Python, TypeScript, OCaml, Go, Rust)
Previously cached issues resolved: N/A (first run)
Inconsistencies found: 7
Progress
High Priority Issues
1.
Z3_optimize_register_model_ehmissing in Java, .NET, C++, OCaml, Go, JavaScript/TypeScriptWhat: A callback that is invoked each time the optimizer finds an improved model during incremental optimization. Useful for streaming intermediate/anytime solutions.
Available in: C API (
Z3_optimize_register_model_eh,src/api/z3_optimization.h), Python (Optimize.set_on_model,src/api/python/z3/z3.py), Rust (Optimize::set_model_handler,z3/src/optimize.rs)Missing in: Java (
src/api/java/*/Optimize.java), .NET (src/api/dotnet/Optimize.cs), C++ (src/api/c++/z3++.h, classoptimize), OCaml (src/api/ml/z3.mli), Go (src/api/go/optimize.go), TypeScript (src/api/js/src/high-level/high-level.ts,OptimizeImpl)Fix: Add a model-callback wrapper (e.g.
addEventHandler/setOnModel/onModel) to each binding's Optimize class that marshals the native callback into an idiomatic language callback, mirroring the PythonOnClause-style / Rustset_model_handlerpattern.Priority: High — this is a distinctive Z3 feature (anytime optimization) with no idiomatic equivalent in 6/8 bindings.
2.
Z3_solver_register_on_clausemissing in JavaWhat: Callback invoked whenever the SAT/SMT core learns or asserts a clause; used for proof logging/clause tracing.
Available in: C API, Python (
OnClauseclass), .NET (OnClause.cs), C++ (line ~4757 inz3++.h), OCaml (Solver.register_on_clause), Go (Solver.NewOnClauseviapropagator.go)Missing in: Java (
src/api/java/) — onlyNativeStatic.txtreferences the native symbol; noOnClause.java/wrapper class existsFix: Add
com.microsoft.z3.OnClausewrapper class andSolver.registerOnClause(...)method analogous to the existingOnClause.csin .NET.Priority: High — Java is the only binding missing this debugging/verification feature entirely.
Medium Priority Issues
3.
Solver.get_help()/help()wrapper missing in C++What:
Z3_solver_get_helpreturns solver-specific parameter documentation string.Available in: C API, Java (
getHelp()), .NET, OCaml (get_help), Go (GetHelp())Missing in: C++
z3::solverclass (src/api/c++/z3++.h, classsolver~line 3078) — C++ hashelp()wrappers fortactic,simplifier,optimize, andfixedpoint, but not forsolver.Fix: Add
std::string help() const { return Z3_solver_get_help(ctx(), m_solver); }to thesolverclass inz3++.h.Priority: Medium — minor but inconsistent since sibling classes (
optimize,tactic) already expose this.4. Optimize API missing
setInitialValue,getHelp,setParamsin TypeScriptWhat:
Z3_optimize_set_initial_value,Z3_optimize_get_help,Z3_optimize_set_paramshave no high-level wrapper.Available in: C API, Python (
set_initial_value,help,set), Java (setInitialValue), .NET, C++ (set_initial_value,help,set)Missing in: TypeScript
OptimizeImpl(src/api/js/src/high-level/high-level.ts, ~line 2413-2560)Fix: Add
setInitialValue(variable, value),getHelp(), andsetParams(params)methods toOptimizeImpl.Priority: Medium.
5. Rust
Optimizemissingget_help,get_param_descrs,set_initial_value,from_fileWhat: Several configuration/introspection functions on
Z3_optimizehave no Rust wrapper.Available in: C API, Python, Java, .NET, C++
Missing in: Rust (
z3/src/optimize.rsinprove-rs/z3.rs) — hasfrom_string/to_string/translate/set_params, but notfrom_file,get_help,get_param_descrs, orset_initial_value.Fix: Add corresponding Rust methods calling
Z3_optimize_from_file,Z3_optimize_get_help,Z3_optimize_get_param_descrs, andZ3_optimize_set_initial_value(all already exposed viaz3-sys).Priority: Medium — external crate (
prove-rs/z3.rs), but commonly used.6. Go
OptimizemissingGetStatisticsandSetInitialValueWhat:
Z3_optimize_get_statisticsandZ3_optimize_set_initial_valuehave no Go wrapper.Available in: C API, Python, Java, .NET, C++
Missing in: Go (
src/api/go/optimize.go) — hasGetLower/GetUpper/etc. but noGetStatistics()orSetInitialValue().Fix: Add
func (o *Optimize) GetStatistics() *Statistics { ... Z3_optimize_get_statistics ... }andfunc (o *Optimize) SetInitialValue(variable, value *Expr) { ... Z3_optimize_set_initial_value ... }tooptimize.go, matching the existing pattern insolver.go'sSetInitialValue.Priority: Medium.
Low Priority Issues
7. Rust
Solverlacks several low-level introspection methods present elsewhereWhat:
get_help,get_param_descrs,get_units,get_non_units,get_trail,get_levels,cube,congruence_root/next/explain,solve_for,set_initial_value,register_on_clause,import_model_converter,add_simplifier,dimacs/to_dimacs_string,from_fileare present in the C API, Python, Java, .NET, C++, OCaml, and Go, but not in the Rustz3crate'sSolver(z3/src/solver.rs).Fix: These are advanced/niche features (congruence closure explanation, cube-and-conquer, user propagation internals). Recommend prioritizing
register_on_clause,set_initial_value, andget_help/get_param_descrsfirst, as these have the broadest utility; the congruence/cube APIs are more specialized.Priority: Low-Medium — Rust binding is externally maintained (
prove-rs/z3.rs) and intentionally exposes a curated high-level subset; full parity may not be a goal of that project, but flagging for awareness.Note on Scope
Issues #5 and #7 affect an external, community-maintained crate (not part of this repository). Recommendations for Rust are informational; Z3Prover maintainers may wish to file upstream issues at
prove-rs/z3.rsrather than directly fixing in this repo.Next Steps
Future runs will analyze: BitVector operations (sign/zero extension, rotation, overflow checks), Array theory (store/select, const arrays, lambda arrays), Floating-point APIs, Tactic/Goal/Probe APIs, and UserPropagator/callback APIs — all currently unanalyzed.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
github.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
All reactions