3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-05-25 19:36:20 +00:00

fix issues 1-10: add missing API bindings across Go, Julia, TypeScript, OCaml, and Java (#9432)

Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/b89f3b76-dfd7-47ec-97dd-8ae5e8e88a4a

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-05-04 09:29:47 -07:00 committed by GitHub
parent eefb644c93
commit 1c6943c2cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 356 additions and 0 deletions

43
src/api/go/char.go Normal file
View file

@ -0,0 +1,43 @@
package z3
/*
#include "z3.h"
*/
import "C"
// Char operations
// MkCharSort creates the character sort (Unicode characters).
func (c *Context) MkCharSort() *Sort {
return newSort(c, C.Z3_mk_char_sort(c.ptr))
}
// MkChar creates a character literal from a Unicode code point.
func (c *Context) MkChar(ch uint) *Expr {
return newExpr(c, C.Z3_mk_char(c.ptr, C.uint(ch)))
}
// MkCharLe creates a character less-than-or-equal predicate (ch1 ≤ ch2).
func (c *Context) MkCharLe(ch1, ch2 *Expr) *Expr {
return newExpr(c, C.Z3_mk_char_le(c.ptr, ch1.ptr, ch2.ptr))
}
// MkCharToInt converts a character to its integer (Unicode code point) value.
func (c *Context) MkCharToInt(ch *Expr) *Expr {
return newExpr(c, C.Z3_mk_char_to_int(c.ptr, ch.ptr))
}
// MkCharToBV converts a character to a bit-vector.
func (c *Context) MkCharToBV(ch *Expr) *Expr {
return newExpr(c, C.Z3_mk_char_to_bv(c.ptr, ch.ptr))
}
// MkCharFromBV converts a bit-vector to a character.
func (c *Context) MkCharFromBV(bv *Expr) *Expr {
return newExpr(c, C.Z3_mk_char_from_bv(c.ptr, bv.ptr))
}
// MkCharIsDigit creates a predicate that is true if the character is a decimal digit.
func (c *Context) MkCharIsDigit(ch *Expr) *Expr {
return newExpr(c, C.Z3_mk_char_is_digit(c.ptr, ch.ptr))
}

38
src/api/go/relations.go Normal file
View file

@ -0,0 +1,38 @@
package z3
/*
#include "z3.h"
*/
import "C"
// Special relation constructors
// MkLinearOrder creates a linear (total) order relation over the given sort.
// The id parameter distinguishes multiple linear orders over the same sort.
func (c *Context) MkLinearOrder(s *Sort, id uint) *FuncDecl {
return newFuncDecl(c, C.Z3_mk_linear_order(c.ptr, s.ptr, C.uint(id)))
}
// MkPartialOrder creates a partial order relation over the given sort.
// The id parameter distinguishes multiple partial orders over the same sort.
func (c *Context) MkPartialOrder(s *Sort, id uint) *FuncDecl {
return newFuncDecl(c, C.Z3_mk_partial_order(c.ptr, s.ptr, C.uint(id)))
}
// MkPiecewiseLinearOrder creates a piecewise linear order relation over the given sort.
// The id parameter distinguishes multiple piecewise linear orders over the same sort.
func (c *Context) MkPiecewiseLinearOrder(s *Sort, id uint) *FuncDecl {
return newFuncDecl(c, C.Z3_mk_piecewise_linear_order(c.ptr, s.ptr, C.uint(id)))
}
// MkTreeOrder creates a tree order relation over the given sort.
// The id parameter distinguishes multiple tree orders over the same sort.
func (c *Context) MkTreeOrder(s *Sort, id uint) *FuncDecl {
return newFuncDecl(c, C.Z3_mk_tree_order(c.ptr, s.ptr, C.uint(id)))
}
// MkTransitiveClosure creates the transitive closure of a binary relation.
// The resulting relation is recursive.
func (c *Context) MkTransitiveClosure(f *FuncDecl) *FuncDecl {
return newFuncDecl(c, C.Z3_mk_transitive_closure(c.ptr, f.ptr))
}

77
src/api/go/set.go Normal file
View file

@ -0,0 +1,77 @@
package z3
/*
#include "z3.h"
*/
import "C"
// Regular (array-encoded) Set operations
// MkSetSort creates a set sort with the given element sort.
func (c *Context) MkSetSort(elemSort *Sort) *Sort {
return newSort(c, C.Z3_mk_set_sort(c.ptr, elemSort.ptr))
}
// MkEmptySet creates an empty set of the given element sort.
func (c *Context) MkEmptySet(elemSort *Sort) *Expr {
return newExpr(c, C.Z3_mk_empty_set(c.ptr, elemSort.ptr))
}
// MkFullSet creates the full set (universe) of the given element sort.
func (c *Context) MkFullSet(elemSort *Sort) *Expr {
return newExpr(c, C.Z3_mk_full_set(c.ptr, elemSort.ptr))
}
// MkSetAdd adds an element to a set.
func (c *Context) MkSetAdd(set, elem *Expr) *Expr {
return newExpr(c, C.Z3_mk_set_add(c.ptr, set.ptr, elem.ptr))
}
// MkSetDel removes an element from a set.
func (c *Context) MkSetDel(set, elem *Expr) *Expr {
return newExpr(c, C.Z3_mk_set_del(c.ptr, set.ptr, elem.ptr))
}
// MkSetUnion creates the union of two or more sets.
func (c *Context) MkSetUnion(sets ...*Expr) *Expr {
if len(sets) == 0 {
return nil
}
cSets := make([]C.Z3_ast, len(sets))
for i, s := range sets {
cSets[i] = s.ptr
}
return newExpr(c, C.Z3_mk_set_union(c.ptr, C.uint(len(sets)), &cSets[0]))
}
// MkSetIntersect creates the intersection of two or more sets.
func (c *Context) MkSetIntersect(sets ...*Expr) *Expr {
if len(sets) == 0 {
return nil
}
cSets := make([]C.Z3_ast, len(sets))
for i, s := range sets {
cSets[i] = s.ptr
}
return newExpr(c, C.Z3_mk_set_intersect(c.ptr, C.uint(len(sets)), &cSets[0]))
}
// MkSetDifference creates the set difference (set1 \ set2).
func (c *Context) MkSetDifference(set1, set2 *Expr) *Expr {
return newExpr(c, C.Z3_mk_set_difference(c.ptr, set1.ptr, set2.ptr))
}
// MkSetComplement creates the complement of a set.
func (c *Context) MkSetComplement(set *Expr) *Expr {
return newExpr(c, C.Z3_mk_set_complement(c.ptr, set.ptr))
}
// MkSetMember creates a membership predicate: elem ∈ set.
func (c *Context) MkSetMember(elem, set *Expr) *Expr {
return newExpr(c, C.Z3_mk_set_member(c.ptr, elem.ptr, set.ptr))
}
// MkSetSubset creates a subset predicate: set1 ⊆ set2.
func (c *Context) MkSetSubset(set1, set2 *Expr) *Expr {
return newExpr(c, C.Z3_mk_set_subset(c.ptr, set1.ptr, set2.ptr))
}