-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFuncInterp.java
More file actions
185 lines (169 loc) · 3.89 KB
/
FuncInterp.java
File metadata and controls
185 lines (169 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/**
* This file was automatically generated from FuncInterp.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.microsoft.z3;
/**
* A function interpretation is represented as a finite map and an 'else' value.
* Each entry in the finite map represents the value of a function given a set
* of arguments.
**/
public class FuncInterp extends Z3Object
{
/**
* An Entry object represents an element in the finite map used to encode a
* function interpretation.
**/
public class Entry extends Z3Object
{
/**
* Return the (symbolic) value of this entry.
*
* @throws Z3Exception
**/
public Expr getValue() throws Z3Exception
{
return Expr.create(getContext(),
Native.funcEntryGetValue(getContext().nCtx(), getNativeObject()));
}
/**
* The number of arguments of the entry.
**/
public int getNumArgs() throws Z3Exception
{
return Native.funcEntryGetNumArgs(getContext().nCtx(), getNativeObject());
}
/**
* The arguments of the function entry.
*
* @throws Z3Exception
**/
public Expr[] getArgs() throws Z3Exception
{
int n = getNumArgs();
Expr[] res = new Expr[n];
for (int i = 0; i < n; i++)
res[i] = Expr.create(getContext(), Native.funcEntryGetArg(
getContext().nCtx(), getNativeObject(), i));
return res;
}
/**
* A string representation of the function entry.
**/
public String toString()
{
try
{
int n = getNumArgs();
String res = "[";
Expr[] args = getArgs();
for (int i = 0; i < n; i++)
res += args[i] + ", ";
return res + getValue() + "]";
} catch (Z3Exception e)
{
return new String("Z3Exception: " + e.getMessage());
}
}
Entry(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
void incRef(long o) throws Z3Exception
{
getContext().funcEntry_DRQ().incAndClear(getContext(), o);
super.incRef(o);
}
void decRef(long o) throws Z3Exception
{
getContext().funcEntry_DRQ().add(o);
super.decRef(o);
}
};
/**
* The number of entries in the function interpretation.
**/
public int getNumEntries() throws Z3Exception
{
return Native.funcInterpGetNumEntries(getContext().nCtx(), getNativeObject());
}
/**
* The entries in the function interpretation
*
* @throws Z3Exception
**/
public Entry[] getEntries() throws Z3Exception
{
int n = getNumEntries();
Entry[] res = new Entry[n];
for (int i = 0; i < n; i++)
res[i] = new Entry(getContext(), Native.funcInterpGetEntry(getContext()
.nCtx(), getNativeObject(), i));
return res;
}
/**
* The (symbolic) `else' value of the function interpretation.
*
* @throws Z3Exception
**/
public Expr getElse() throws Z3Exception
{
return Expr.create(getContext(),
Native.funcInterpGetElse(getContext().nCtx(), getNativeObject()));
}
/**
* The arity of the function interpretation
**/
public int getArity() throws Z3Exception
{
return Native.funcInterpGetArity(getContext().nCtx(), getNativeObject());
}
/**
* A string representation of the function interpretation.
**/
public String toString()
{
try
{
String res = "";
res += "[";
for (Entry e : getEntries())
{
int n = e.getNumArgs();
if (n > 1)
res += "[";
Expr[] args = e.getArgs();
for (int i = 0; i < n; i++)
{
if (i != 0)
res += ", ";
res += args[i];
}
if (n > 1)
res += "]";
res += " -> " + e.getValue() + ", ";
}
res += "else -> " + getElse();
res += "]";
return res;
} catch (Z3Exception e)
{
return new String("Z3Exception: " + e.getMessage());
}
}
FuncInterp(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
void incRef(long o) throws Z3Exception
{
getContext().funcInterp_DRQ().incAndClear(getContext(), o);
super.incRef(o);
}
void decRef(long o) throws Z3Exception
{
getContext().funcInterp_DRQ().add(o);
super.decRef(o);
}
}