20using System.Diagnostics;
22using System.Collections;
23using System.Collections.Generic;
41 return Object.ReferenceEquals(a, b) ||
42 (!Object.ReferenceEquals(a,
null) &&
43 !Object.ReferenceEquals(b,
null) &&
44 a.Context.nCtx == b.Context.nCtx &&
45 0 != Native.Z3_is_eq_ast(a.
Context.nCtx, a.NativeObject, b.NativeObject));
63 public override bool Equals(
object o)
66 if (casted ==
null)
return false;
67 return this == casted;
77 if (other ==
null)
return 1;
85 else if (
Id > oAST.
Id)
98 return (
int)Native.Z3_get_ast_hash(
Context.nCtx, NativeObject);
106 get {
return Native.Z3_get_ast_id(
Context.nCtx, NativeObject); }
116 Debug.Assert(ctx !=
null);
118 if (ReferenceEquals(
Context, ctx))
121 return Create(ctx, Native.Z3_translate(
Context.nCtx, NativeObject, ctx.nCtx));
145 default:
return false;
155 get {
return this.ASTKind ==
Z3_ast_kind.Z3_APP_AST; }
163 get {
return this.ASTKind ==
Z3_ast_kind.Z3_VAR_AST; }
171 get {
return this.ASTKind ==
Z3_ast_kind.Z3_QUANTIFIER_AST; }
179 get {
return this.ASTKind ==
Z3_ast_kind.Z3_SORT_AST; }
187 get {
return this.ASTKind ==
Z3_ast_kind.Z3_FUNC_DECL_AST; }
195 return Native.Z3_ast_to_string(
Context.nCtx, NativeObject);
204 return Native.Z3_ast_to_string(
Context.nCtx, NativeObject);
208 internal AST(
Context ctx) : base(ctx) { Debug.Assert(ctx !=
null); }
209 internal AST(
Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx !=
null); }
211 internal override void IncRef(IntPtr o)
213 if (
Context !=
null && o != IntPtr.Zero)
214 Native.Z3_inc_ref(
Context.nCtx, o);
217 internal override void DecRef(IntPtr o)
219 if (
Context !=
null && o != IntPtr.Zero)
223 if (
Context.nCtx != IntPtr.Zero)
224 Native.Z3_dec_ref(
Context.nCtx, o);
229 internal static AST Create(
Context ctx, IntPtr obj)
231 Debug.Assert(ctx !=
null);
233 switch ((
Z3_ast_kind)Native.Z3_get_ast_kind(ctx.nCtx, obj))
235 case Z3_ast_kind.Z3_FUNC_DECL_AST:
return new FuncDecl(ctx, obj);
236 case Z3_ast_kind.Z3_QUANTIFIER_AST:
return new Quantifier(ctx, obj);
237 case Z3_ast_kind.Z3_SORT_AST:
return Sort.Create(ctx, obj);
240 case Z3_ast_kind.Z3_VAR_AST:
return Expr.Create(ctx, obj);
242 throw new Z3Exception(
"Unknown AST kind");
The abstract syntax tree (AST) class.
override bool Equals(object o)
Object comparison.
static bool operator==(AST a, AST b)
Comparison operator.
virtual int CompareTo(object other)
Object Comparison.
bool IsFuncDecl
Indicates whether the AST is a FunctionDeclaration.
static bool operator!=(AST a, AST b)
Comparison operator.
bool IsSort
Indicates whether the AST is a Sort.
bool IsVar
Indicates whether the AST is a BoundVariable.
Z3_ast_kind ASTKind
The kind of the AST.
override int GetHashCode()
The AST's hash code.
uint Id
A unique identifier for the AST (unique among all ASTs).
bool IsQuantifier
Indicates whether the AST is a Quantifier.
override string ToString()
A string representation of the AST.
string SExpr()
A string representation of the AST in s-expression notation.
bool IsApp
Indicates whether the AST is an application.
AST Translate(Context ctx)
Translates (copies) the AST to the Context ctx .
bool IsExpr
Indicates whether the AST is an Expr.
The main interaction with Z3 happens via the Context.
Internal base class for interfacing with native Z3 objects. Should not be used externally.
Context Context
Access Context object.
Z3_ast_kind
The different kinds of Z3 AST (abstract syntax trees). That is, terms, formulas and types.