Z3
 
Loading...
Searching...
No Matches
Data Structures | Public Member Functions
AST Class Reference
+ Inheritance diagram for AST:

Public Member Functions

boolean equals (Object o)
 
int compareTo (AST other)
 
int hashCode ()
 
int getId ()
 
int getDepth ()
 
AST translate (Context ctx)
 
Z3_ast_kind getASTKind ()
 
boolean isExpr ()
 
boolean isApp ()
 
boolean isVar ()
 
boolean isQuantifier ()
 
boolean isSort ()
 
boolean isFuncDecl ()
 
String toString ()
 
String getSExpr ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Z3Object
static long[] arrayToNative (Z3Object[] a)
 
static int arrayLength (Z3Object[] a)
 

Detailed Description

The abstract syntax tree (AST) class.

Definition at line 27 of file AST.java.

Member Function Documentation

◆ compareTo()

int compareTo ( AST  other)
inline

Object Comparison.

Parameters
otherAnother AST
Returns
Negative if the object should be sorted before other, positive if after else zero.
Exceptions
Z3Exceptionon error

Definition at line 55 of file AST.java.

56 {
57 if (other == null) {
58 return 1;
59 }
60 return Integer.compare(getId(), other.getId());
61 }

◆ equals()

boolean equals ( Object  o)
inline

Object comparison.

Parameters
oanother AST

Reimplemented in FuncDecl< R extends Sort >, and Sort.

Definition at line 35 of file AST.java.

36 {
37 if (o == this) return true;
38 if (!(o instanceof AST)) return false;
39 AST casted = (AST) o;
40
41 return
42 (getContext().nCtx() == casted.getContext().nCtx()) &&
43 (Native.isEqAst(getContext().nCtx(), getNativeObject(), casted.getNativeObject()));
44 }

◆ getASTKind()

Z3_ast_kind getASTKind ( )
inline

The kind of the AST.

Exceptions
Z3Exceptionon error

Definition at line 113 of file AST.java.

114 {
115 return Z3_ast_kind.fromInt(Native.getAstKind(getContext().nCtx(),
116 getNativeObject()));
117 }
Z3_ast_kind
The different kinds of Z3 AST (abstract syntax trees). That is, terms, formulas and types.
Definition z3_api.h:142

Referenced by AST.isApp(), AST.isExpr(), AST.isFuncDecl(), AST.isQuantifier(), AST.isSort(), and AST.isVar().

◆ getDepth()

int getDepth ( )
inline

The depth of the AST (max nodes on any root-to-leaf path).

Exceptions
Z3Exceptionon error
Returns
an int

Definition at line 88 of file AST.java.

89 {
90 return Native.getDepth(getContext().nCtx(), getNativeObject());
91 }

◆ getId()

int getId ( )
inline

A unique identifier for the AST (unique among all ASTs).

Exceptions
Z3Exceptionon error

Reimplemented in FuncDecl< R extends Sort >, and Sort.

Definition at line 78 of file AST.java.

79 {
80 return Native.getAstId(getContext().nCtx(), getNativeObject());
81 }

Referenced by AST.compareTo().

◆ getSExpr()

String getSExpr ( )
inline

A string representation of the AST in s-expression notation.

Definition at line 195 of file AST.java.

196 {
197 return Native.astToString(getContext().nCtx(), getNativeObject());
198 }

◆ hashCode()

int hashCode ( )
inline

The AST's hash code.

Returns
A hash code

Reimplemented in Sort.

Definition at line 69 of file AST.java.

70 {
71 return Native.getAstHash(getContext().nCtx(), getNativeObject());
72 }

◆ isApp()

boolean isApp ( )
inline

Indicates whether the AST is an application

Returns
a boolean
Exceptions
Z3Exceptionon error

Definition at line 143 of file AST.java.

144 {
145 return this.getASTKind() == Z3_ast_kind.Z3_APP_AST;
146 }
Z3_ast_kind getASTKind()
Definition AST.java:113

◆ isExpr()

boolean isExpr ( )
inline

Indicates whether the AST is an Expr

Exceptions
Z3Exceptionon error
Z3Exceptionon error

Definition at line 124 of file AST.java.

125 {
126 switch (getASTKind())
127 {
128 case Z3_APP_AST:
129 case Z3_NUMERAL_AST:
131 case Z3_VAR_AST:
132 return true;
133 default:
134 return false;
135 }
136 }
@ Z3_APP_AST
Definition z3_api.h:144
@ Z3_VAR_AST
Definition z3_api.h:145
@ Z3_NUMERAL_AST
Definition z3_api.h:143
@ Z3_QUANTIFIER_AST
Definition z3_api.h:146

◆ isFuncDecl()

boolean isFuncDecl ( )
inline

Indicates whether the AST is a FunctionDeclaration

Definition at line 179 of file AST.java.

180 {
181 return this.getASTKind() == Z3_ast_kind.Z3_FUNC_DECL_AST;
182 }

◆ isQuantifier()

boolean isQuantifier ( )
inline

Indicates whether the AST is a Quantifier

Returns
a boolean
Exceptions
Z3Exceptionon error

Definition at line 163 of file AST.java.

164 {
165 return this.getASTKind() == Z3_ast_kind.Z3_QUANTIFIER_AST;
166 }

◆ isSort()

boolean isSort ( )
inline

Indicates whether the AST is a Sort

Definition at line 171 of file AST.java.

172 {
173 return this.getASTKind() == Z3_ast_kind.Z3_SORT_AST;
174 }

◆ isVar()

boolean isVar ( )
inline

Indicates whether the AST is a BoundVariable.

Returns
a boolean
Exceptions
Z3Exceptionon error

Definition at line 153 of file AST.java.

154 {
155 return this.getASTKind() == Z3_ast_kind.Z3_VAR_AST;
156 }

◆ toString()

String toString ( )
inline

A string representation of the AST.

Reimplemented in Expr< R extends Sort >, FuncDecl< R extends Sort >, Pattern, and Sort.

Definition at line 188 of file AST.java.

188 {
189 return Native.astToString(getContext().nCtx(), getNativeObject());
190 }

◆ translate()

AST translate ( Context  ctx)
inline

Translates (copies) the AST to the Context ctx.

Parameters
ctxA context
Returns
A copy of the AST which is associated with ctx
Exceptions
Z3Exceptionon error

Reimplemented in Expr< R extends Sort >, FuncDecl< R extends Sort >, and Sort.

Definition at line 100 of file AST.java.

101 {
102 if (getContext() == ctx) {
103 return this;
104 } else {
105 return create(ctx, Native.translate(getContext().nCtx(), getNativeObject(), ctx.nCtx()));
106 }
107 }

Referenced by AstRef.__copy__(), Goal.__copy__(), AstVector.__copy__(), FuncInterp.__copy__(), ModelRef.__copy__(), Goal.__deepcopy__(), AstVector.__deepcopy__(), FuncInterp.__deepcopy__(), and ModelRef.__deepcopy__().