z3.go

Core types (Context, Config, Symbol, Sort, Expr, FuncDecl, Quantifier, Lambda) and basic operations

Types

type AST

AST represents a Z3 abstract syntax tree node.

Methods:

Equal

func (a *AST) Equal(other *AST) bool

Equal checks if two ASTs are equal.

Hash

func (a *AST) Hash() uint32

Hash returns the hash code of the AST.

String

func (a *AST) String() string

String returns the string representation of the AST.

type ASTVector

ASTVector represents a vector of Z3 ASTs.

type Config

Config represents a Z3 configuration object.

Methods:

SetParamValue

func (c *Config) SetParamValue(paramID, paramValue string)

SetParamValue sets a configuration parameter.

type Context

Context methods (receiver omitted for clarity)

Methods:

MkAnd

func (c *Context) MkAnd(exprs ...*Expr) *Expr

Boolean operations MkAnd creates a conjunction.

MkApp

func (c *Context) MkApp(decl *FuncDecl, args ...*Expr) *Expr

MkApp creates a function application.

MkBool

func (c *Context) MkBool(value bool) *Expr

MkBool creates a Boolean constant.

MkBoolConst

func (c *Context) MkBoolConst(name string) *Expr

MkBoolConst creates a Boolean constant (variable) with the given name.

MkBoolSort

func (c *Context) MkBoolSort() *Sort

MkBoolSort creates the Boolean sort.

MkBvSort

func (c *Context) MkBvSort(sz uint) *Sort

MkBvSort creates a bit-vector sort of the given size.

MkConst

func (c *Context) MkConst(name *Symbol, sort *Sort) *Expr

MkConst creates a constant (variable) with the given name and sort.

MkDistinct

func (c *Context) MkDistinct(exprs ...*Expr) *Expr

MkDistinct creates a distinct constraint.

MkEq

func (c *Context) MkEq(lhs, rhs *Expr) *Expr

Comparison operations MkEq creates an equality.

MkExists

func (c *Context) MkExists(bound []*Expr, body *Expr) *Expr

MkExists creates an existential quantifier.

MkFalse

func (c *Context) MkFalse() *Expr

MkFalse creates the Boolean constant false.

MkForall

func (c *Context) MkForall(bound []*Expr, body *Expr) *Expr

Quantifier operations MkForall creates a universal quantifier.

MkFuncDecl

func (c *Context) MkFuncDecl(name *Symbol, domain []*Sort, range_ *Sort) *FuncDecl

MkFuncDecl creates a function declaration.

MkIff

func (c *Context) MkIff(lhs, rhs *Expr) *Expr

MkIff creates a bi-implication (if and only if).

MkImplies

func (c *Context) MkImplies(lhs, rhs *Expr) *Expr

MkImplies creates an implication.

MkIntSymbol

func (c *Context) MkIntSymbol(i int) *Symbol

MkIntSymbol creates an integer symbol.

MkLambda

func (c *Context) MkLambda(sorts []*Sort, names []*Symbol, body *Expr) *Lambda

MkLambda creates a lambda expression with sorts and names

MkLambdaConst

func (c *Context) MkLambdaConst(bound []*Expr, body *Expr) *Lambda

MkLambdaConst creates a lambda expression using constant bound variables

MkNot

func (c *Context) MkNot(expr *Expr) *Expr

MkNot creates a negation.

MkNumeral

func (c *Context) MkNumeral(numeral string, sort *Sort) *Expr

MkNumeral creates a numeral from a string.

MkOr

func (c *Context) MkOr(exprs ...*Expr) *Expr

MkOr creates a disjunction.

MkQuantifier

func (c *Context) MkQuantifier(isForall bool, weight int, sorts []*Sort, names []*Symbol, body *Expr, patterns []*Pattern) *Quantifier

MkQuantifier creates a quantifier with patterns

MkQuantifierConst

func (c *Context) MkQuantifierConst(isForall bool, weight int, bound []*Expr, body *Expr, patterns []*Pattern) *Quantifier

MkQuantifierConst creates a quantifier using constant bound variables

MkStringSymbol

func (c *Context) MkStringSymbol(s string) *Symbol

MkStringSymbol creates a string symbol.

MkTrue

func (c *Context) MkTrue() *Expr

MkTrue creates the Boolean constant true.

MkTypeVariable

func (c *Context) MkTypeVariable(name *Symbol) *Sort

MkTypeVariable creates a type variable sort for use in polymorphic functions and datatypes

MkXor

func (c *Context) MkXor(lhs, rhs *Expr) *Expr

MkXor creates exclusive or.

SetParam

func (c *Context) SetParam(key, value string)

SetParam sets a global or context parameter.

type Expr

Expr represents a Z3 expression.

Methods:

Equal

func (e *Expr) Equal(other *Expr) bool

Equal checks if two expressions are equal.

GetSort

func (e *Expr) GetSort() *Sort

GetSort returns the sort of the expression.

Simplify

func (e *Expr) Simplify() *Expr

Simplify simplifies an expression.

String

func (e *Expr) String() string

String returns the string representation of the expression.

type FuncDecl

FuncDecl represents a function declaration.

Methods:

GetArity

func (f *FuncDecl) GetArity() int

GetArity returns the arity (number of parameters) of the function.

GetDomain

func (f *FuncDecl) GetDomain(i int) *Sort

GetDomain returns the sort of the i-th parameter.

GetName

func (f *FuncDecl) GetName() *Symbol

GetName returns the name of the function declaration.

GetRange

func (f *FuncDecl) GetRange() *Sort

GetRange returns the sort of the return value.

String

func (f *FuncDecl) String() string

String returns the string representation of the function declaration.

type Lambda

Lambda represents a lambda expression

Methods:

AsExpr

func (l *Lambda) AsExpr() *Expr

AsExpr converts a Lambda to an Expr

GetBody

func (l *Lambda) GetBody() *Expr

GetBody returns the body of the lambda expression

GetBoundName

func (l *Lambda) GetBoundName(idx int) *Symbol

GetBoundName returns the name of the bound variable at the given index

GetBoundSort

func (l *Lambda) GetBoundSort(idx int) *Sort

GetBoundSort returns the sort of the bound variable at the given index

GetNumBound

func (l *Lambda) GetNumBound() int

GetNumBound returns the number of bound variables

String

func (l *Lambda) String() string

String returns the string representation of the lambda

type ParamDescrs

ParamDescrs represents parameter descriptions for Z3 objects.

type Pattern

Pattern represents a Z3 pattern for quantifier instantiation.

type Quantifier

Quantifier represents a quantified formula (forall or exists)

Methods:

AsExpr

func (q *Quantifier) AsExpr() *Expr

AsExpr converts a Quantifier to an Expr

GetBody

func (q *Quantifier) GetBody() *Expr

GetBody returns the body of the quantifier

GetBoundName

func (q *Quantifier) GetBoundName(idx int) *Symbol

GetBoundName returns the name of the bound variable at the given index

GetBoundSort

func (q *Quantifier) GetBoundSort(idx int) *Sort

GetBoundSort returns the sort of the bound variable at the given index

GetNoPattern

func (q *Quantifier) GetNoPattern(idx int) *Pattern

GetNoPattern returns the no-pattern at the given index

GetNumBound

func (q *Quantifier) GetNumBound() int

GetNumBound returns the number of bound variables

GetNumNoPatterns

func (q *Quantifier) GetNumNoPatterns() int

GetNumNoPatterns returns the number of no-patterns

GetNumPatterns

func (q *Quantifier) GetNumPatterns() int

GetNumPatterns returns the number of patterns

GetPattern

func (q *Quantifier) GetPattern(idx int) *Pattern

GetPattern returns the pattern at the given index

GetWeight

func (q *Quantifier) GetWeight() int

GetWeight returns the weight of the quantifier

IsExistential

func (q *Quantifier) IsExistential() bool

IsExistential returns true if this is an existential quantifier (exists)

IsUniversal

func (q *Quantifier) IsUniversal() bool

IsUniversal returns true if this is a universal quantifier (forall)

String

func (q *Quantifier) String() string

String returns the string representation of the quantifier

type Sort

Sort represents a Z3 sort (type).

Methods:

Equal

func (s *Sort) Equal(other *Sort) bool

Equal checks if two sorts are equal.

String

func (s *Sort) String() string

String returns the string representation of the sort.

type Symbol

Symbol represents a Z3 symbol.

Methods:

String

func (s *Symbol) String() string

String returns the string representation of the symbol.

Functions

NewConfig

func NewConfig() *Config

NewConfig creates a new Z3 configuration.

NewContext

func NewContext() *Context

NewContext creates a new Z3 context with default configuration.

NewContextWithConfig

func NewContextWithConfig(cfg *Config) *Context

NewContextWithConfig creates a new Z3 context with the given configuration.