mirror of
https://github.com/Z3Prover/z3
synced 2026-04-03 18:31:08 +00:00
Refactor: replace int_constraint with constraint struct, promote cur_path to member, expose path leaf side constraints (#9124)
* chore: update plan with cur_path and side constraints requirements Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/1523cf0a-b7a4-41a6-b792-7cd41b4dcd3b * Refactor: rename int_constraint to constraint, remove int_constraint_kind enum - Rename int_constraint struct to constraint with fields fml/dep - Remove int_constraint_kind enum; pre-build formula expressions instead - nielsen_edge: add_side_int/side_int() -> add_side_constraint/side_constraints() - nielsen_node: add_int_constraint/int_constraints() -> add_constraint/constraints() - nielsen_graph: mk_int_constraint(lhs,rhs,kind,dep) -> mk_constraint(fml,dep) - Remove int_constraint_to_expr (no longer needed) - search_dfs/simplify_and_init/check_int_feasibility/check_lp_le: drop cur_path param - Add m_cur_path member to nielsen_graph; m_cur_path.reset() in solve() - Add get_path_leaf_side_constraints() implementation - Update seq_parikh.h/cpp and seq_nielsen_pp.cpp to use new constraint API Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor: constraint struct, promote cur_path, expose path leaf side constraints Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/1523cf0a-b7a4-41a6-b792-7cd41b4dcd3b * fix: remove spurious includes from seq_nielsen.cpp Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/aa283d79-cd42-4b87-aaf0-4273a8327b76 * fix: update test files to use renamed constraint API and fix inverted root guard Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/b09bbc56-9617-4277-8e0c-27fa7e588037 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
9f6eb4f455
commit
e3e235aa7f
7 changed files with 183 additions and 231 deletions
|
|
@ -3300,26 +3300,26 @@ static void test_add_lower_int_bound_basic() {
|
|||
// initially no bounds
|
||||
SASSERT(node->var_lb(x) == 0);
|
||||
SASSERT(node->var_ub(x) == UINT_MAX);
|
||||
SASSERT(node->int_constraints().empty());
|
||||
SASSERT(node->constraints().empty());
|
||||
|
||||
// add lower bound lb=3: should tighten and add constraint
|
||||
bool tightened = node->add_lower_int_bound(x, 3, dep);
|
||||
SASSERT(tightened);
|
||||
SASSERT(node->var_lb(x) == 3);
|
||||
SASSERT(node->int_constraints().size() == 1);
|
||||
SASSERT(node->int_constraints()[0].m_kind == seq::int_constraint_kind::ge);
|
||||
SASSERT(node->constraints().size() == 1);
|
||||
SASSERT(node->constraints()[0].fml);
|
||||
|
||||
// add weaker lb=2: no tightening
|
||||
tightened = node->add_lower_int_bound(x, 2, dep);
|
||||
SASSERT(!tightened);
|
||||
SASSERT(node->var_lb(x) == 3);
|
||||
SASSERT(node->int_constraints().size() == 1);
|
||||
SASSERT(node->constraints().size() == 1);
|
||||
|
||||
// add tighter lb=5: should tighten and add another constraint
|
||||
tightened = node->add_lower_int_bound(x, 5, dep);
|
||||
SASSERT(tightened);
|
||||
SASSERT(node->var_lb(x) == 5);
|
||||
SASSERT(node->int_constraints().size() == 2);
|
||||
SASSERT(node->constraints().size() == 2);
|
||||
|
||||
std::cout << " ok\n";
|
||||
}
|
||||
|
|
@ -3347,20 +3347,20 @@ static void test_add_upper_int_bound_basic() {
|
|||
bool tightened = node->add_upper_int_bound(x, 10, dep);
|
||||
SASSERT(tightened);
|
||||
SASSERT(node->var_ub(x) == 10);
|
||||
SASSERT(node->int_constraints().size() == 1);
|
||||
SASSERT(node->int_constraints()[0].m_kind == seq::int_constraint_kind::le);
|
||||
SASSERT(node->constraints().size() == 1);
|
||||
SASSERT(node->constraints()[0].fml);
|
||||
|
||||
// add weaker ub=20: no tightening
|
||||
tightened = node->add_upper_int_bound(x, 20, dep);
|
||||
SASSERT(!tightened);
|
||||
SASSERT(node->var_ub(x) == 10);
|
||||
SASSERT(node->int_constraints().size() == 1);
|
||||
SASSERT(node->constraints().size() == 1);
|
||||
|
||||
// add tighter ub=5: tightens
|
||||
tightened = node->add_upper_int_bound(x, 5, dep);
|
||||
SASSERT(tightened);
|
||||
SASSERT(node->var_ub(x) == 5);
|
||||
SASSERT(node->int_constraints().size() == 2);
|
||||
SASSERT(node->constraints().size() == 2);
|
||||
|
||||
std::cout << " ok\n";
|
||||
}
|
||||
|
|
@ -3427,7 +3427,7 @@ static void test_bounds_cloned() {
|
|||
SASSERT(child->var_ub(y) == UINT_MAX);
|
||||
|
||||
// child's int_constraints should also be cloned (3 constraints: lb_x, ub_x, lb_y)
|
||||
SASSERT(child->int_constraints().size() == parent->int_constraints().size());
|
||||
SASSERT(child->constraints().size() == parent->constraints().size());
|
||||
|
||||
std::cout << " ok\n";
|
||||
}
|
||||
|
|
@ -3454,7 +3454,7 @@ static void test_var_bound_watcher_single_var() {
|
|||
// set bounds: 3 <= len(x) <= 7
|
||||
node->add_lower_int_bound(x, 3, dep);
|
||||
node->add_upper_int_bound(x, 7, dep);
|
||||
node->int_constraints().reset(); // clear for clean count
|
||||
node->constraints().reset(); // clear for clean count
|
||||
|
||||
// apply substitution x → a·y
|
||||
euf::snode* ay = sg.mk_concat(a, y);
|
||||
|
|
@ -3490,7 +3490,7 @@ static void test_var_bound_watcher_conflict() {
|
|||
|
||||
// set bounds: 3 <= len(x) (so x must have at least 3 chars)
|
||||
node->add_lower_int_bound(x, 3, dep);
|
||||
node->int_constraints().reset();
|
||||
node->constraints().reset();
|
||||
|
||||
// apply substitution x → a·b (const_len=2 < lb=3)
|
||||
euf::snode* ab = sg.mk_concat(a, b);
|
||||
|
|
@ -3624,7 +3624,7 @@ static void test_var_bound_watcher_multi_var() {
|
|||
|
||||
// set upper bound: len(x) <= 5
|
||||
node->add_upper_int_bound(x, 5, dep);
|
||||
node->int_constraints().reset();
|
||||
node->constraints().reset();
|
||||
|
||||
// apply substitution x → y·z (two vars, no constants)
|
||||
euf::snode* yz = sg.mk_concat(y, z);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue