Add TypeScript API parity: Solver introspection, congruence closure, and Model sort universe methods #8129
+516
−43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✅ TypeScript/JavaScript API Parity - Complete Implementation
This PR implements all missing TypeScript APIs identified in GitHub Discussion #8121, achieving full API parity with Python and other bindings for solver introspection, congruence closure analysis, and model sort universe operations.
📋 Implementation Summary
11 new public API methods added:
Solver Class (7 methods)
units()- Get unit literals inferred by solvernonUnits()- Get non-unit atomic formulastrail()- Get solver decision trailcongruenceRoot(expr)- Get congruence class rootcongruenceNext(expr)- Get next in congruence classcongruenceExplain(a, b)- Explain term congruencefromFile(filename)- Load SMT-LIB2 from fileModel Class (4 methods)
numSorts()- Count uninterpreted sortsgetSort(i)- Get sort by indexgetSorts()- Get all sorts arraysortUniverse(sort)- Get sort universe elements📊 Code Changes
✨ Key Features
api.Context('main')pattern🎯 API Parity Matrix
Result: TypeScript now has 100% parity for all analyzed APIs! 🎉
🔍 Usage Examples
See
examples/high-level/api-parity-demo.tsfor complete examples.✅ Quality Assurance
📚 Documentation
🎁 Benefits
🚀 Implementation Approach
This PR fully addresses GitHub Discussion #8121 for the TypeScript binding.
All requested APIs have been implemented, tested, documented, and are ready for production use.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.