Z3
Loading...
Searching...
No Matches
src
api
dotnet
EnumSort.cs
Go to the documentation of this file.
1
/*++
2
Copyright (c) 2012 Microsoft Corporation
3
4
Module Name:
5
6
EnumSort.cs
7
8
Abstract:
9
10
Z3 Managed API: Enum Sorts
11
12
Author:
13
14
Christoph Wintersteiger (cwinter) 2012-11-23
15
16
Notes:
17
18
--*/
19
20
using
System.Diagnostics;
21
using
System;
22
23
namespace
Microsoft.Z3
24
{
28
public
class
EnumSort
:
Sort
29
{
33
public
FuncDecl
[]
ConstDecls
34
{
35
get
36
{
37
uint n = Native.Z3_get_datatype_sort_num_constructors(
Context
.nCtx, NativeObject);
38
FuncDecl
[] t =
new
FuncDecl
[n];
39
for
(uint i = 0; i < n; i++)
40
t[i] =
new
FuncDecl
(
Context
, Native.Z3_get_datatype_sort_constructor(
Context
.nCtx, NativeObject, i));
41
return
t;
42
}
43
}
44
50
public
FuncDecl
ConstDecl
(uint inx)
51
{
52
return
new
FuncDecl
(
Context
, Native.Z3_get_datatype_sort_constructor(
Context
.nCtx, NativeObject, inx));
53
}
54
58
public
Expr
[]
Consts
59
{
60
get
61
{
62
FuncDecl
[] cds =
ConstDecls
;
63
Expr
[] t =
new
Expr
[cds.Length];
64
for
(uint i = 0; i < t.Length; i++)
65
t[i] =
Context
.
MkApp
(cds[i]);
66
return
t;
67
}
68
}
69
75
public
Expr
Const
(uint inx)
76
{
77
using
var decl =
ConstDecl
(inx);
78
return
Context
.
MkApp
(decl);
79
}
80
84
public
FuncDecl
[]
TesterDecls
85
{
86
get
87
{
88
uint n = Native.Z3_get_datatype_sort_num_constructors(
Context
.nCtx, NativeObject);
89
FuncDecl
[] t =
new
FuncDecl
[n];
90
for
(uint i = 0; i < n; i++)
91
t[i] =
new
FuncDecl
(
Context
, Native.Z3_get_datatype_sort_recognizer(
Context
.nCtx, NativeObject, i));
92
return
t;
93
}
94
}
95
101
public
FuncDecl
TesterDecl
(uint inx)
102
{
103
return
new
FuncDecl
(
Context
, Native.Z3_get_datatype_sort_recognizer(
Context
.nCtx, NativeObject, inx));
104
}
105
106
#region Internal
107
internal
EnumSort
(
Context
ctx,
Symbol
name,
Symbol
[] enumNames)
108
: base(ctx, IntPtr.Zero)
109
{
110
Debug.Assert(ctx !=
null
);
111
Debug.Assert(name !=
null
);
112
Debug.Assert(enumNames !=
null
);
113
114
int
n = enumNames.Length;
115
IntPtr[] n_constdecls =
new
IntPtr[n];
116
IntPtr[] n_testers =
new
IntPtr[n];
117
NativeObject = Native.Z3_mk_enumeration_sort(ctx.nCtx, name.NativeObject, (uint)n,
118
Symbol
.ArrayToNative(enumNames), n_constdecls, n_testers);
119
}
120
#endregion
121
};
122
}
Microsoft.Z3.Context
The main interaction with Z3 happens via the Context.
Definition
Context.cs:34
Microsoft.Z3.Context.MkApp
Expr MkApp(FuncDecl f, params Expr[] args)
Create a new function application.
Definition
Context.cs:896
Microsoft.Z3.EnumSort
Enumeration sorts.
Definition
EnumSort.cs:29
Microsoft.Z3.EnumSort.TesterDecl
FuncDecl TesterDecl(uint inx)
Retrieves the inx'th tester/recognizer declaration in the enumeration.
Definition
EnumSort.cs:101
Microsoft.Z3.EnumSort.Consts
Expr[] Consts
The constants in the enumeration.
Definition
EnumSort.cs:59
Microsoft.Z3.EnumSort.ConstDecl
FuncDecl ConstDecl(uint inx)
Retrieves the inx'th constant declaration in the enumeration.
Definition
EnumSort.cs:50
Microsoft.Z3.EnumSort.ConstDecls
FuncDecl[] ConstDecls
The function declarations of the constants in the enumeration.
Definition
EnumSort.cs:34
Microsoft.Z3.EnumSort.TesterDecls
FuncDecl[] TesterDecls
The test predicates (recognizers) for the constants in the enumeration.
Definition
EnumSort.cs:85
Microsoft.Z3.EnumSort.Const
Expr Const(uint inx)
Retrieves the inx'th constant in the enumeration.
Definition
EnumSort.cs:75
Microsoft.Z3.Expr
Expressions are terms.
Definition
Expr.cs:31
Microsoft.Z3.FuncDecl
Function declarations.
Definition
FuncDecl.cs:31
Microsoft.Z3.Sort
The Sort class implements type information for ASTs.
Definition
Sort.cs:29
Microsoft.Z3.Symbol
Symbols are used to name several term and type constructors.
Definition
Symbol.cs:30
Microsoft.Z3
Definition
AlgebraicNum.cs:27
Generated on Sat Dec 20 2025 19:33:21 for Z3 by
1.9.8