Z3
 
Loading...
Searching...
No Matches
finiteset.go
Go to the documentation of this file.
1package z3
2
3/*
4#include "z3.h"
5*/
6import "C"
7
8// Finite set operations
9
10// MkFiniteSetSort creates a finite set sort with the given element sort.
11func (c *Context) MkFiniteSetSort(elemSort *Sort) *Sort {
12 return newSort(c, C.Z3_mk_finite_set_sort(c.ptr, elemSort.ptr))
13}
14
15// IsFiniteSetSort returns true if the given sort is a finite set sort.
16func (c *Context) IsFiniteSetSort(s *Sort) bool {
17 return bool(C.Z3_is_finite_set_sort(c.ptr, s.ptr))
18}
19
20// GetFiniteSetSortBasis returns the element sort of a finite set sort.
21func (c *Context) GetFiniteSetSortBasis(s *Sort) *Sort {
22 return newSort(c, C.Z3_get_finite_set_sort_basis(c.ptr, s.ptr))
23}
24
25// MkFiniteSetEmpty creates an empty finite set of the given sort.
26func (c *Context) MkFiniteSetEmpty(setSort *Sort) *Expr {
27 return newExpr(c, C.Z3_mk_finite_set_empty(c.ptr, setSort.ptr))
28}
29
30// MkFiniteSetSingleton creates a singleton finite set containing the given element.
31func (c *Context) MkFiniteSetSingleton(elem *Expr) *Expr {
32 return newExpr(c, C.Z3_mk_finite_set_singleton(c.ptr, elem.ptr))
33}
34
35// MkFiniteSetUnion creates the union of two finite sets.
36func (c *Context) MkFiniteSetUnion(s1, s2 *Expr) *Expr {
37 return newExpr(c, C.Z3_mk_finite_set_union(c.ptr, s1.ptr, s2.ptr))
38}
39
40// MkFiniteSetIntersect creates the intersection of two finite sets.
41func (c *Context) MkFiniteSetIntersect(s1, s2 *Expr) *Expr {
42 return newExpr(c, C.Z3_mk_finite_set_intersect(c.ptr, s1.ptr, s2.ptr))
43}
44
45// MkFiniteSetDifference creates the set difference of two finite sets (s1 \ s2).
46func (c *Context) MkFiniteSetDifference(s1, s2 *Expr) *Expr {
47 return newExpr(c, C.Z3_mk_finite_set_difference(c.ptr, s1.ptr, s2.ptr))
48}
49
50// MkFiniteSetMember creates a membership predicate: elem ∈ set.
51func (c *Context) MkFiniteSetMember(elem, set *Expr) *Expr {
52 return newExpr(c, C.Z3_mk_finite_set_member(c.ptr, elem.ptr, set.ptr))
53}
54
55// MkFiniteSetSize creates an expression for the cardinality of a finite set.
56func (c *Context) MkFiniteSetSize(set *Expr) *Expr {
57 return newExpr(c, C.Z3_mk_finite_set_size(c.ptr, set.ptr))
58}
59
60// MkFiniteSetSubset creates a subset predicate: s1 ⊆ s2.
61func (c *Context) MkFiniteSetSubset(s1, s2 *Expr) *Expr {
62 return newExpr(c, C.Z3_mk_finite_set_subset(c.ptr, s1.ptr, s2.ptr))
63}
64
65// MkFiniteSetMap applies a function to all elements of a finite set.
66func (c *Context) MkFiniteSetMap(f, set *Expr) *Expr {
67 return newExpr(c, C.Z3_mk_finite_set_map(c.ptr, f.ptr, set.ptr))
68}
69
70// MkFiniteSetFilter filters a finite set using a predicate function.
71func (c *Context) MkFiniteSetFilter(f, set *Expr) *Expr {
72 return newExpr(c, C.Z3_mk_finite_set_filter(c.ptr, f.ptr, set.ptr))
73}
74
75// MkFiniteSetRange creates a finite set of integers in the range [low, high].
76func (c *Context) MkFiniteSetRange(low, high *Expr) *Expr {
77 return newExpr(c, C.Z3_mk_finite_set_range(c.ptr, low.ptr, high.ptr))
78}