Skip to content

Commit a4bcd74

Browse files
ilanashapirodependabot[bot]CopilotNikolajBjornerlevnach
authored
Setting up param tuning python prototyping experiment (#7993)
* draft attempt at optimizing cube tree with resolvents. have not tested/ran yet * adding comments * fix bug about needing to bubble resolvent upwards to highest ancestor * fix bug where we need to cover the whole resolvent in the path when bubbling up * clean up comments * Bump actions/checkout from 4 to 5 (#7954) Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * close entire tree when sibling resolvent is empty * integrate asms directly into cube tree, remove separate tracking * try to fix bug about redundant resolutions, merging close and try_resolve_upwards into once function * separate the logic again to avoid mutual recursion * [WIP] Add a mutex to warning.cpp to ensure that warning messages from different threads don't interfere (#7963) * Initial plan * Add mutex to warning.cpp for thread safety Co-authored-by: NikolajBjorner <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: NikolajBjorner <[email protected]> * Remove unused variable 'first' in mpz.cpp Removed unused variable 'first' from the function. * fixing the order Signed-off-by: Lev Nachmanson <[email protected]> * fixing the order Signed-off-by: Lev Nachmanson <[email protected]> * fix the order of parameter evaluation Signed-off-by: Lev Nachmanson <[email protected]> * remove AI slop Signed-off-by: Nikolaj Bjorner <[email protected]> * param order Signed-off-by: Lev Nachmanson <[email protected]> * param order Signed-off-by: Lev Nachmanson <[email protected]> * param order evaluation * parameter eval order * parameter evaluation order * param eval * param eval order * parameter eval order Signed-off-by: Lev Nachmanson <[email protected]> * parameter eval order Signed-off-by: Lev Nachmanson <[email protected]> * parameter eval order Signed-off-by: Lev Nachmanson <[email protected]> * parameter eval order Signed-off-by: Lev Nachmanson <[email protected]> * parameter eval order Signed-off-by: Lev Nachmanson <[email protected]> * parameter eval order Signed-off-by: Lev Nachmanson <[email protected]> * parameter eval order Signed-off-by: Lev Nachmanson <[email protected]> * Bump github/codeql-action from 3 to 4 (#7971) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3 to 4. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@v3...v4) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: '4' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update Z3_mk_datatype_sort API to accept array of sort parameters and add Z3_mk_polymorphic_datatype (#7966) * Initial plan * Update Z3_mk_datatype_sort API to accept array of parameters Co-authored-by: NikolajBjorner <[email protected]> * Update language bindings for parametric datatype sort API - Python: Updated DatatypeSort() to accept optional params list - OCaml: Added mk_sort_ref_p/mk_sort_ref_ps for parametric datatypes - .NET: Added MkDatatypeSortRef() methods with optional params - Java: Added mkDatatypeSortRef() methods with optional params - All changes maintain backward compatibility Co-authored-by: NikolajBjorner <[email protected]> * Fix .NET build error - rename params to parameters The 'params' keyword is reserved in C#, causing compilation errors. Renamed parameter from 'params' to 'parameters' in MkDatatypeSortRef methods. Co-authored-by: NikolajBjorner <[email protected]> * Add unit test for parametric datatypes Added test_parametric_datatype.cpp to demonstrate polymorphic datatypes. The test creates two concrete instantiations of a generic pair concept: - pair_int_real with fields (first:Int, second:Real) - pair_real_int with fields (first:Real, second:Int) Then verifies that accessors work correctly and type checking is enforced. Co-authored-by: NikolajBjorner <[email protected]> * Implement polymorphic type variables support for parametric datatypes - Modified datatype_decl_plugin to allow type variables as parameters - Updated mk_datatype_decl to extract type variables from field sorts - Type variables are collected in order of first appearance - Revised unit test to use Z3_mk_type_variable for polymorphic datatypes - Test creates pair datatype with type variables alpha and beta - Successfully instantiates with concrete types (pair Int Real) and (pair Real Int) - Verifies accessor types match and equality terms are well-typed - All tests pass Co-authored-by: NikolajBjorner <[email protected]> * Add Z3_mk_polymorphic_datatype API and refactor datatype creation - Added new API Z3_mk_polymorphic_datatype to z3_api.h - Renamed static mk_datatype_decl to api_datatype_decl in api_datatype.cpp - Modified api_datatype_decl to accept explicit type parameters - Updated all callers to use renamed function - Added test_polymorphic_datatype_api demonstrating new API usage - Both tests pass successfully Co-authored-by: NikolajBjorner <[email protected]> * Remove type variable collection logic from constructors Removed the logic for collecting type variables from field sorts based on constructors. * Update comments on parameter handling in api_datatype.cpp Clarify usage of parameters in API documentation. * Fix OCaml build error - use list instead of array for mk_datatype_sort Changed mk_sort_ref to pass empty list [] instead of empty array [||]. Changed mk_sort_ref_p to pass params list directly instead of converting to array. Z3native.mk_datatype_sort expects a list, not an array. Co-authored-by: NikolajBjorner <[email protected]> * Add polymorphic datatype example to C++ examples Added polymorphic_datatype_example() demonstrating: - Creating type variables alpha and beta with Z3_mk_type_variable - Defining parametric Pair datatype with fields of type alpha and beta - Instantiating with concrete types (Pair Int Real) and (Pair Real Int) - Getting constructors and accessors from instantiated datatypes - Creating constants and expressions using the polymorphic types - Verifying type correctness with equality (= (first p1) (second p2)) Co-authored-by: NikolajBjorner <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: NikolajBjorner <[email protected]> Co-authored-by: Nikolaj Bjorner <[email protected]> * trim parametric datatype test Signed-off-by: Nikolaj Bjorner <[email protected]> * restore single cell Signed-off-by: Lev Nachmanson <[email protected]> * restore the method behavior Signed-off-by: Lev Nachmanson <[email protected]> * setting up python tuning experiment, not done * Add finite_set_value_factory for creating finite set values in model generation (#7981) * Initial plan * Add finite_set_value_factory implementation Co-authored-by: NikolajBjorner <[email protected]> * Remove unused dl_decl_plugin variable and include Co-authored-by: NikolajBjorner <[email protected]> * Update copyright and add TODOs in finite_set_value_factory Updated copyright information and added TODO comments for handling in finite_set_value_factory methods. * Update copyright information in finite_set_value_factory.h Updated copyright year from 2006 to 2025. * Implement finite_set_value_factory using array_util to create singleton sets Co-authored-by: NikolajBjorner <[email protected]> * Simplify empty set creation in finite_set_value_factory Refactor finite_set_value_factory to simplify empty set handling and remove array-specific logic. * Change family ID for finite_set_value_factory * Fix build error by restoring array_decl_plugin include and implementation Co-authored-by: NikolajBjorner <[email protected]> * Update finite_set_value_factory.h * Add SASSERT for finite set check in factory Added assertion to check if the sort is a finite set. * Rename member variable from m_util to u * Refactor finite_set_value_factory for value handling * Use register_value instead of direct set insertion Replaced direct insertion into set with register_value calls. * Update finite_set_value_factory.cpp --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: NikolajBjorner <[email protected]> Co-authored-by: Nikolaj Bjorner <[email protected]> * Revert "Add finite_set_value_factory for creating finite set values in model …" (#7985) This reverts commit 05ffc0a. * Update arith_rewriter.cpp fix memory leak introduced by update to ensure determinism * update pythonnn prototyping experiment, need to add a couple more things * add explicit constructors for nightly mac build failure Signed-off-by: Nikolaj Bjorner <[email protected]> * build fixes Signed-off-by: Nikolaj Bjorner <[email protected]> * fixes * fix some more things but now it hangs * change multithread to multiprocess seems to have resolved current deadlock * fix some bugs, it seems to run now * fix logic about checking clauses individually, and add proof prefix clause selection (naively) via the OnClause hook * disable manylinux until segfault is resolved Signed-off-by: Nikolaj Bjorner <[email protected]> * add the "noexcept" keyword to value_score=(value_score&&) declaration * expose a status flag for clauses but every single one is being coded as an assumption... * Add a fast-path to _coerce_exprs. (#7995) When the inputs are already the same sort, we can skip most of the coercion logic and just return. Currently, `_coerce_exprs` is by far the most expensive part of building up many common Z3 ASTs, so this fast-path is a substantial speedup for many use-cases. * Bump actions/setup-node from 5 to 6 (#7994) Bumps [actions/setup-node](https://github.com/actions/setup-node) from 5 to 6. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](actions/setup-node@v5...v6) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Lev Nachmanson <[email protected]> Signed-off-by: Nikolaj Bjorner <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Copilot <[email protected]> Co-authored-by: NikolajBjorner <[email protected]> Co-authored-by: Nikolaj Bjorner <[email protected]> Co-authored-by: Lev Nachmanson <[email protected]> Co-authored-by: Nelson Elhage <[email protected]>
1 parent c5d65cd commit a4bcd74

33 files changed

+989
-118
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ jobs:
2020

2121
steps:
2222
- name: Checkout repository
23-
uses: actions/checkout@v4
23+
uses: actions/checkout@v5
2424

2525
- name: Initialize CodeQL
26-
uses: github/codeql-action/init@v3
26+
uses: github/codeql-action/init@v4
2727
with:
2828
languages: ${{ matrix.language }}
2929

3030
- name: Autobuild
31-
uses: github/codeql-action/autobuild@v3
31+
uses: github/codeql-action/autobuild@v4
3232

3333
- name: Run CodeQL Query
34-
uses: github/codeql-action/analyze@v3
34+
uses: github/codeql-action/analyze@v4
3535
with:
3636
category: 'custom'
3737
queries: ./codeql/custom-queries

.github/workflows/wasm-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
uses: actions/checkout@v5
2525

2626
- name: Setup node
27-
uses: actions/setup-node@v5
27+
uses: actions/setup-node@v6
2828
with:
2929
node-version: "lts/*"
3030
registry-url: "https://registry.npmjs.org"

.github/workflows/wasm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
uses: actions/checkout@v5
2525

2626
- name: Setup node
27-
uses: actions/setup-node@v5
27+
uses: actions/setup-node@v6
2828
with:
2929
node-version: "lts/*"
3030

a-tst.gcno

-221 Bytes
Binary file not shown.

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ jobs:
6666
pool:
6767
vmImage: "ubuntu-latest"
6868
container: "quay.io/pypa/manylinux2014_x86_64:latest"
69+
condition: eq(0,1)
6970
steps:
7071
- script: curl -L -o /tmp/arm-toolchain.tar.xz 'https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz?rev=33c6e30e5ac64e6dba8f0431f2c35f1b&hash=9918A05BF47621B632C7A5C8D2BB438FB80A4480'
7172
- script: mkdir -p /tmp/arm-toolchain/

examples/c++/example.cpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,95 @@ void datatype_example() {
10061006

10071007
}
10081008

1009+
void polymorphic_datatype_example() {
1010+
std::cout << "polymorphic datatype example\n";
1011+
context ctx;
1012+
1013+
// Create type variables alpha and beta for polymorphic datatype using C API
1014+
Z3_symbol alpha_sym = Z3_mk_string_symbol(ctx, "alpha");
1015+
Z3_symbol beta_sym = Z3_mk_string_symbol(ctx, "beta");
1016+
sort alpha(ctx, Z3_mk_type_variable(ctx, alpha_sym));
1017+
sort beta(ctx, Z3_mk_type_variable(ctx, beta_sym));
1018+
1019+
std::cout << "Type variables: " << alpha << ", " << beta << "\n";
1020+
1021+
// Define parametric Pair datatype with constructor mk-pair(first: alpha, second: beta)
1022+
symbol pair_name = ctx.str_symbol("Pair");
1023+
symbol mk_pair_name = ctx.str_symbol("mk-pair");
1024+
symbol is_pair_name = ctx.str_symbol("is-pair");
1025+
symbol first_name = ctx.str_symbol("first");
1026+
symbol second_name = ctx.str_symbol("second");
1027+
1028+
symbol field_names[2] = {first_name, second_name};
1029+
sort field_sorts[2] = {alpha, beta}; // Use type variables
1030+
1031+
constructors cs(ctx);
1032+
cs.add(mk_pair_name, is_pair_name, 2, field_names, field_sorts);
1033+
sort pair = ctx.datatype(pair_name, cs);
1034+
1035+
std::cout << "Created parametric datatype: " << pair << "\n";
1036+
1037+
// Instantiate Pair with concrete types: (Pair Int Real)
1038+
sort_vector params_int_real(ctx);
1039+
params_int_real.push_back(ctx.int_sort());
1040+
params_int_real.push_back(ctx.real_sort());
1041+
sort pair_int_real = ctx.datatype_sort(pair_name, params_int_real);
1042+
1043+
std::cout << "Instantiated with Int and Real: " << pair_int_real << "\n";
1044+
1045+
// Instantiate Pair with concrete types: (Pair Real Int)
1046+
sort_vector params_real_int(ctx);
1047+
params_real_int.push_back(ctx.real_sort());
1048+
params_real_int.push_back(ctx.int_sort());
1049+
sort pair_real_int = ctx.datatype_sort(pair_name, params_real_int);
1050+
1051+
std::cout << "Instantiated with Real and Int: " << pair_real_int << "\n";
1052+
1053+
// Get constructors and accessors for (Pair Int Real) using C API
1054+
func_decl mk_pair_ir(ctx, Z3_get_datatype_sort_constructor(ctx, pair_int_real, 0));
1055+
func_decl first_ir(ctx, Z3_get_datatype_sort_constructor_accessor(ctx, pair_int_real, 0, 0));
1056+
func_decl second_ir(ctx, Z3_get_datatype_sort_constructor_accessor(ctx, pair_int_real, 0, 1));
1057+
1058+
std::cout << "Constructors and accessors for (Pair Int Real):\n";
1059+
std::cout << " Constructor: " << mk_pair_ir << "\n";
1060+
std::cout << " first accessor: " << first_ir << "\n";
1061+
std::cout << " second accessor: " << second_ir << "\n";
1062+
1063+
// Get constructors and accessors for (Pair Real Int) using C API
1064+
func_decl mk_pair_ri(ctx, Z3_get_datatype_sort_constructor(ctx, pair_real_int, 0));
1065+
func_decl first_ri(ctx, Z3_get_datatype_sort_constructor_accessor(ctx, pair_real_int, 0, 0));
1066+
func_decl second_ri(ctx, Z3_get_datatype_sort_constructor_accessor(ctx, pair_real_int, 0, 1));
1067+
1068+
std::cout << "Constructors and accessors for (Pair Real Int):\n";
1069+
std::cout << " Constructor: " << mk_pair_ri << "\n";
1070+
std::cout << " first accessor: " << first_ri << "\n";
1071+
std::cout << " second accessor: " << second_ri << "\n";
1072+
1073+
// Create constants of these types
1074+
expr p1 = ctx.constant("p1", pair_int_real);
1075+
expr p2 = ctx.constant("p2", pair_real_int);
1076+
1077+
std::cout << "Created constants: " << p1 << " : " << p1.get_sort() << "\n";
1078+
std::cout << " " << p2 << " : " << p2.get_sort() << "\n";
1079+
1080+
// Create expressions using accessors
1081+
expr first_p1 = first_ir(p1); // first(p1) has type Int
1082+
expr second_p2 = second_ri(p2); // second(p2) has type Int
1083+
1084+
std::cout << "first(p1) = " << first_p1 << " : " << first_p1.get_sort() << "\n";
1085+
std::cout << "second(p2) = " << second_p2 << " : " << second_p2.get_sort() << "\n";
1086+
1087+
// Create equality term: (= (first p1) (second p2))
1088+
expr eq = first_p1 == second_p2;
1089+
std::cout << "Equality term: " << eq << "\n";
1090+
1091+
// Verify both sides have the same type (Int)
1092+
assert(first_p1.get_sort().id() == ctx.int_sort().id());
1093+
assert(second_p2.get_sort().id() == ctx.int_sort().id());
1094+
1095+
std::cout << "Successfully created and verified polymorphic datatypes!\n";
1096+
}
1097+
10091098
void expr_vector_example() {
10101099
std::cout << "expr_vector example\n";
10111100
context c;
@@ -1394,6 +1483,7 @@ int main() {
13941483
enum_sort_example(); std::cout << "\n";
13951484
tuple_example(); std::cout << "\n";
13961485
datatype_example(); std::cout << "\n";
1486+
polymorphic_datatype_example(); std::cout << "\n";
13971487
expr_vector_example(); std::cout << "\n";
13981488
exists_expr_vector_example(); std::cout << "\n";
13991489
substitute_example(); std::cout << "\n";

0 commit comments

Comments
 (0)