3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-10 02:47:15 +00:00

Go/OCaml API gaps: substitution, AST introspection, Spacer, Goal completion (#9277)

* fix: address issues 1,2,4,5 and add Goal API to Go bindings

Issue 2 (Go): Add Substitute, SubstituteVars, SubstituteFuns to Expr
Issue 4 (Go): Add GetDecl, NumArgs, Arg to Expr for AST app introspection
Goal API (Go): Add IsInconsistent and ToDimacsString to Goal
ASTVector (Go): Add public Size, Get, String methods
ASTMap (Go): Add ASTMap type with full CRUD API in spacer.go
Issue 1 (Go): Add Spacer fixedpoint methods QueryFromLvl, GetGroundSatAnswer,
  GetRulesAlongTrace, GetRuleNamesAlongTrace, AddInvariant, GetReachable
Issue 1 (Go): Add context-level QE functions ModelExtrapolate, QeLite,
  QeModelProject, QeModelProjectSkolem, QeModelProjectWithWitness
Issue 5 (OCaml): Add substitute_funs to z3.ml and z3.mli

Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/afa18588-47af-4720-8cea-55fe0544ae55

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* fix: add substitute_funs to Expr module sig in z3.ml

The internal sig...end block in z3.ml (the module type declaration for Expr)
was missing val substitute_funs, causing OCaml compiler error:
  The value substitute_funs is required but not provided

Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/c6662702-46a3-4aa0-b225-d6b73c2a2505

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
Copilot 2026-04-12 14:00:03 -07:00 committed by GitHub
parent 1566d3cc41
commit 68e528eaf7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 290 additions and 0 deletions

View file

@ -228,6 +228,17 @@ func (g *Goal) String() string {
return C.GoString(C.Z3_goal_to_string(g.ctx.ptr, g.ptr))
}
// IsInconsistent returns true if the goal contains the formula false.
func (g *Goal) IsInconsistent() bool {
return bool(C.Z3_goal_inconsistent(g.ctx.ptr, g.ptr))
}
// ToDimacsString converts the goal to a string in DIMACS format.
// If includeNames is true, formula names are included as comments.
func (g *Goal) ToDimacsString(includeNames bool) string {
return C.GoString(C.Z3_goal_to_dimacs_string(g.ctx.ptr, g.ptr, C.bool(includeNames)))
}
// ApplyResult represents the result of applying a tactic to a goal.
type ApplyResult struct {
ctx *Context