7
7
#include " utils/utils.h"
8
8
#include " mm/toolbox.h"
9
9
#include " mm/setmm.h"
10
+ #include " z3prover3.h"
10
11
11
12
// #define VERBOSE_Z3
12
13
13
- unsigned expr_get_num_bound (const z3::expr &e) {
14
- assert (e.is_quantifier ());
15
- unsigned num = Z3_get_quantifier_num_bound (e.ctx (), e);
16
- e.check_error ();
17
- return num;
18
- }
19
-
20
- z3::symbol expr_get_quantifier_bound_name (const z3::expr &e, unsigned i) {
21
- assert (e.is_quantifier ());
22
- Z3_symbol sym = Z3_get_quantifier_bound_name (e.ctx (), e, i);
23
- e.check_error ();
24
- return z3::symbol (e.ctx (), sym);
25
- }
26
-
27
- z3::sort expr_get_quantifier_bound_sort (const z3::expr &e, unsigned i) {
28
- assert (e.is_quantifier ());
29
- Z3_sort sort = Z3_get_quantifier_bound_sort (e.ctx (), e, i);
30
- e.check_error ();
31
- return z3::sort (e.ctx (), sort);
32
- }
33
-
34
- bool expr_is_quantifier_forall (const z3::expr &e) {
35
- assert (e.is_quantifier ());
36
- Z3_bool is_forall = Z3_is_quantifier_forall (e.ctx (), e);
37
- e.check_error ();
38
- return static_cast < bool >(is_forall);
39
- }
40
-
41
- unsigned expr_get_var_index (const z3::expr &e) {
42
- assert (e.is_var ());
43
- unsigned idx = Z3_get_index_value (e.ctx (), e);
44
- e.check_error ();
45
- return idx;
46
- }
47
-
48
14
/* So far this procedure is not correct, because it does not address very important
49
15
* mismatches between the two languages of Z3 and Metamath: in Z3 function applications,
50
16
* variable binding is explicit and position-based, while in Metamath it is implicit
@@ -171,18 +137,18 @@ ParsingTree< SymTok, LabTok > expr_to_pt(const z3::expr &e, const LibraryToolbox
171
137
throw " Cannot handle this formula" ;
172
138
}
173
139
} else if (e.is_quantifier ()) {
174
- for (unsigned i = 0 ; i < expr_get_num_bound (e); i++) {
175
- bound_var_stack.push_back (expr_get_quantifier_bound_name (e, i));
140
+ for (unsigned i = 0 ; i < gio::mmpp::z3prover:: expr_get_num_bound (e); i++) {
141
+ bound_var_stack.push_back (gio::mmpp::z3prover:: expr_get_quantifier_bound_name (e, i));
176
142
}
177
143
ParsingTree< SymTok, LabTok > ret = expr_to_pt (e.body (), tb, bound_var_stack);
178
144
ParsingTree< SymTok, LabTok > templ;
179
- if (expr_is_quantifier_forall (e)) {
145
+ if (gio::mmpp::z3prover:: expr_is_quantifier_forall (e)) {
180
146
templ = tb.parse_sentence (tb.read_sentence (" wff A. x ph" ));
181
147
} else {
182
148
templ = tb.parse_sentence (tb.read_sentence (" wff E. x ph" ));
183
149
}
184
150
assert (templ.label != LabTok{});
185
- for (unsigned i = 0 ; i < expr_get_num_bound (e); i++) {
151
+ for (unsigned i = 0 ; i < gio::mmpp::z3prover:: expr_get_num_bound (e); i++) {
186
152
SubstMap< SymTok, LabTok > subst;
187
153
subst[tb.get_var_sym_to_lab (tb.get_symbol (" x" ))].type = tb.get_symbol (" set" );
188
154
auto sym = tb.get_symbol (bound_var_stack.back ().str ());
@@ -196,7 +162,7 @@ ParsingTree< SymTok, LabTok > expr_to_pt(const z3::expr &e, const LibraryToolbox
196
162
} else if (e.is_var ()) {
197
163
ParsingTree< SymTok, LabTok > ret;
198
164
SubstMap< SymTok, LabTok > subst;
199
- unsigned idx = expr_get_var_index (e);
165
+ unsigned idx = gio::mmpp::z3prover:: expr_get_var_index (e);
200
166
auto z3sym = bound_var_stack.at (bound_var_stack.size () - 1 - idx);
201
167
ret = tb.parse_sentence (tb.read_sentence (" class x" ));
202
168
assert (ret.label != LabTok{});
@@ -389,8 +355,8 @@ int test_z3_2_main(int argc, char *argv[]) {
389
355
}
390
356
391
357
auto proof = s.proof ();
392
- // std::cout << "Proof:" << std::endl << proof << std::endl;
393
- scan_proof (proof, tb);
358
+ std::cout << " Proof:" << std::endl << proof << std::endl;
359
+ // scan_proof(proof, tb);
394
360
395
361
std::cout << std::endl;
396
362
} catch (z3::exception &e) {
0 commit comments