Skip to content

Commit 520ea65

Browse files
move towards theory phase selection, implement getitem on lambda
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent 0eafeb9 commit 520ea65

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

src/api/python/z3/z3.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,15 @@ def is_lambda(self):
18611861
"""
18621862
return Z3_is_lambda(self.ctx_ref(), self.ast)
18631863

1864+
def __getitem__(self, arg):
1865+
"""Return the Z3 expression `self[arg]`.
1866+
"""
1867+
if z3_debug():
1868+
_z3_assert(self.is_lambda(), "quantifier should be a lambda expression")
1869+
arg = self.sort().domain().cast(arg)
1870+
return _to_expr_ref(Z3_mk_select(self.ctx_ref(), self.as_ast(), arg.as_ast()), self.ctx)
1871+
1872+
18641873
def weight(self):
18651874
"""Return the weight annotation of `self`.
18661875
@@ -4288,6 +4297,9 @@ def is_array(a):
42884297
"""
42894298
return isinstance(a, ArrayRef)
42904299

4300+
def is_array_sort(a):
4301+
return _ast_kind(a.ctx(), a.sort()) == Z3_ARRAY_SORT
4302+
42914303
def is_const_array(a):
42924304
"""Return `True` if `a` is a Z3 constant array.
42934305
@@ -4412,7 +4424,7 @@ def Update(a, i, v):
44124424
proved
44134425
"""
44144426
if z3_debug():
4415-
_z3_assert(is_array(a), "First argument must be a Z3 array expression")
4427+
_z3_assert(is_array_sort(a), "First argument must be a Z3 array expression")
44164428
i = a.domain().cast(i)
44174429
v = a.range().cast(v)
44184430
ctx = a.ctx
@@ -4425,7 +4437,7 @@ def Default(a):
44254437
proved
44264438
"""
44274439
if z3_debug():
4428-
_z3_assert(is_array(a), "First argument must be a Z3 array expression")
4440+
_z3_assert(is_array_sort(a), "First argument must be a Z3 array expression")
44294441
return a.default()
44304442

44314443

@@ -4456,7 +4468,7 @@ def Select(a, i):
44564468
True
44574469
"""
44584470
if z3_debug():
4459-
_z3_assert(is_array(a), "First argument must be a Z3 array expression")
4471+
_z3_assert(is_array_sort(a), "First argument must be a Z3 array expression")
44604472
return a[i]
44614473

44624474

@@ -4476,7 +4488,7 @@ def Map(f, *args):
44764488
if z3_debug():
44774489
_z3_assert(len(args) > 0, "At least one Z3 array expression expected")
44784490
_z3_assert(is_func_decl(f), "First argument must be a Z3 function declaration")
4479-
_z3_assert(all([is_array(a) for a in args]), "Z3 array expected expected")
4491+
_z3_assert(all([is_array_sort(a) for a in args]), "Z3 array expected expected")
44804492
_z3_assert(len(args) == f.arity(), "Number of arguments mismatch")
44814493
_args, sz = _to_ast_array(args)
44824494
ctx = f.ctx
@@ -4511,7 +4523,7 @@ def Ext(a, b):
45114523
"""
45124524
ctx = a.ctx
45134525
if z3_debug():
4514-
_z3_assert(is_array(a) and is_array(b), "arguments must be arrays")
4526+
_z3_assert(is_array_sort(a) and is_array_sort(b), "arguments must be arrays")
45154527
return _to_expr_ref(Z3_mk_array_ext(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
45164528

45174529
def SetHasSize(a, k):

src/smt/smt_context.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3873,7 +3873,9 @@ namespace smt {
38733873
default:
38743874
break;
38753875
}
3876-
if (m_fparams.m_phase_selection == PS_CACHING_CONSERVATIVE || m_fparams.m_phase_selection == PS_CACHING_CONSERVATIVE2)
3876+
if (m_fparams.m_phase_selection == PS_THEORY ||
3877+
m_fparams.m_phase_selection == PS_CACHING_CONSERVATIVE ||
3878+
m_fparams.m_phase_selection == PS_CACHING_CONSERVATIVE2)
38773879
forget_phase_of_vars_in_current_level();
38783880
m_atom_propagation_queue.reset();
38793881
m_eq_propagation_queue.reset();

src/smt/smt_setup.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ namespace smt {
317317
// }
318318
// else {
319319
TRACE("rdl_bug", tout << "using theory_mi_arith\n";);
320+
//setup_lra_arith();
320321
m_context.register_plugin(alloc(smt::theory_mi_arith, m_manager, m_params));
321322
// }
322323
}
@@ -477,13 +478,10 @@ namespace smt {
477478
m_params.m_relevancy_lvl = 2;
478479
m_params.m_relevancy_lemma = false;
479480
}
480-
if (st.m_cnf) {
481-
m_params.m_phase_selection = PS_CACHING_CONSERVATIVE2;
482-
}
483-
else {
481+
m_params.m_phase_selection = PS_THEORY;
482+
if (!st.m_cnf) {
484483
m_params.m_restart_strategy = RS_GEOMETRIC;
485484
m_params.m_arith_stronger_lemmas = false;
486-
m_params.m_phase_selection = PS_ALWAYS_FALSE;
487485
m_params.m_restart_adaptive = false;
488486
}
489487
m_params.m_arith_small_lemma_size = 32;
@@ -533,7 +531,6 @@ namespace smt {
533531
}
534532
else {
535533
m_params.m_eliminate_term_ite = true;
536-
m_params.m_phase_selection = PS_CACHING;
537534
m_params.m_restart_adaptive = false;
538535
m_params.m_restart_strategy = RS_GEOMETRIC;
539536
m_params.m_restart_factor = 1.5;

0 commit comments

Comments
 (0)