[API Coherence] Solver and Model API Analysis - Feb 20, 2026 #8705
Closed
Replies: 1 comment
-
|
This discussion was automatically closed because it expired on 2026-02-27T04:17:40.584Z.
|
Beta Was this translation helpful? Give feedback.
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 systematic API coherence analysis for Z3's multi-language bindings. I analyzed 3 API families covering solver core functionality, diagnostic features, and model inspection across 7 programming languages: Java, .NET (C#), C++, Python, TypeScript/JavaScript, OCaml, and Go.
Statistics
Progress Tracking
This is run #1 of an incremental analysis. Future runs will cover:
API Families Analyzed
1. Solver Core APIs
C API Functions:
Z3_solver_push,Z3_solver_pop,Z3_solver_reset,Z3_solver_assert,Z3_solver_check,Z3_solver_check_assumptions,Z3_solver_get_model,Z3_solver_get_proof,Z3_solver_get_unsat_coreStatus: ✅ All languages have complete coverage
All languages provide these essential solver operations:
push(),pop(),reset(),add(),check(),model(),proof(),unsat_core()push(),pop(),reset(),add(),check(),getModel(),getProof(),getUnsatCore()push(),pop(),reset(),add(),check(),get_model(),proof(),unsat_core()Push(),Pop(),Reset(),Add(),Check(),Model,Proof,UnsatCorepush(),pop(),reset(),add(),check(),model(),unsatCore()push,pop,reset,add,check,get_model,get_proof,get_unsat_corePush(),Pop(),Reset(),Assert(),Check(),Model(),Proof(),UnsatCore()2. Solver Diagnostic APIs
C API Functions:
Z3_solver_assert_and_track,Z3_solver_from_file,Z3_solver_from_string,Z3_solver_get_reason_unknown,Z3_solver_get_num_scopes,Z3_solver_get_statisticsStatus:⚠️ TypeScript missing
assertAndTrackCoverage by language:
assert_and_track,from_file,from_string,reason_unknown, statistics)assertAndTrack,fromFile,fromString,getReasonUnknown)add(e, p)for tracking,from_file,from_string,reason_unknown)AssertAndTrack,FromFile,FromString,ReasonUnknown)assertAndTrack(hasfromFile,fromString,reasonUnknown,numScopes)assert_and_track,from_file,from_string,get_reason_unknown,get_num_scopes)AssertAndTrack,FromFile,FromString,ReasonUnknown,NumScopes)3. Model APIs
C API Functions:
Z3_model_eval,Z3_model_get_num_consts,Z3_model_get_num_funcs,Z3_model_get_const_decl,Z3_model_get_func_declStatus: ✅ All languages have coverage
All languages provide model evaluation and iteration:
eval(), iteration via__getitem__,__len__,decls()evaluate(),getNumConsts(),getNumFuncs(),getConstDecl(),getFuncDecl()eval(), iteration supportEvaluate(),NumConsts,NumFuncs,ConstDecls,FuncDeclseval(), iteration viaentries(),length()eval, iteration viaget_num_consts,get_num_funcs,get_const_decl,get_func_declEval(),NumConsts(),NumFuncs(),ConstDecl(),FuncDecl()High Priority Issues
Issue #1: Missing
Solver.assertAndTrackin TypeScriptWhat: The
Z3_solver_assert_and_trackC API is not exposed in TypeScript/JavaScript bindings.C API:
Available in: C, C++, Python, .NET, Java, OCaml, Go
Missing in: TypeScript/JavaScript
Purpose: This API is essential for extracting minimal unsat cores. It associates a constraint with a tracking literal (Boolean constant) that can later be retrieved via
unsatCore()to identify which constraints caused unsatisfiability.Use Case:
Current Workaround: Users must use
check()with assumptions, which is less flexible.Fix Recommendation: Add
assertAndTrack(constraint: Bool, track: Bool): voidmethod to theSolverclass in TypeScript.Files to Modify:
src/api/js/src/high-level/types.ts- Add method signature to Solver interfacesrc/api/js/src/high-level/high-level.ts- Implement the method callingZ3.solver_assert_and_trackPriority: HIGH - This is a core diagnostic feature used for debugging unsatisfiable formulas.
Issue #2: Missing
Optimize.assertAndTrackin TypeScriptWhat: The
Z3_optimize_assert_and_trackC API is not exposed in TypeScript/JavaScript bindings.C API:
Available in: C, C++, Python, .NET, Java, OCaml, Go
Missing in: TypeScript/JavaScript
Purpose: Same as Issue #1 but for the Optimize solver, allowing tracking of constraints for unsat core extraction in optimization problems.
Fix Recommendation: Add
assertAndTrack(constraint: Bool, track: Bool): voidmethod to theOptimizeclass in TypeScript.Files to Modify:
src/api/js/src/high-level/types.ts- Add method signature to Optimize interfacesrc/api/js/src/high-level/high-level.ts- Implement the method callingZ3.optimize_assert_and_trackPriority: HIGH - Essential for debugging optimization problems.
Observations
Excellent Coverage Overall
Z3's language bindings show remarkable consistency. The core solver APIs are 100% covered across all 7 languages, which is outstanding for a project of this complexity.
TypeScript Gaps
TypeScript bindings are newer and still catching up to the maturity of other bindings. The missing
assertAndTrackmethods are the only significant gaps found in this analysis round.Naming Conventions
Each language follows its native conventions appropriately:
assertAndTrack,AssertAndTrack)assert_and_track)fromFile,numScopes)AssertAndTrack)get_model, overloadedadd)This is good practice and makes each binding feel native to its ecosystem.
Next Analysis (Run #2)
The next analysis will focus on:
sign_ext,zero_ext,rotate_left,rotate_right,extract, and overflow checking functionsselect,store, and array property functionsMethodology
This analysis was conducted using:
src/api/z3_api.h,src/api/z3_optimization.h)All findings were verified against the current codebase state as of February 20, 2026.
Maintainer Action Items
assertAndTrackfor TypeScript Solver and Optimize classes (estimated 2-4 hours)Beta Was this translation helpful? Give feedback.
All reactions