3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-10-22 15:34:35 +00:00
Commit graph

78 commits

Author SHA1 Message Date
Copilot
5163411f9b
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 <3085284+NikolajBjorner@users.noreply.github.com>

* 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 <3085284+NikolajBjorner@users.noreply.github.com>

* 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 <3085284+NikolajBjorner@users.noreply.github.com>

* 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 <3085284+NikolajBjorner@users.noreply.github.com>

* 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 <3085284+NikolajBjorner@users.noreply.github.com>

* 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 <3085284+NikolajBjorner@users.noreply.github.com>

* 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 <3085284+NikolajBjorner@users.noreply.github.com>

* 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 <3085284+NikolajBjorner@users.noreply.github.com>

---------

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: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-10-15 20:51:21 +02:00
Bruce Mitchener
6835522a7f z3++.h: No longer include unused sstream.
This makes some code using the C++ API have to include `<sstream>`
if they used the functionality but didn't include it themselves.
2022-08-05 09:41:49 +03:00
Nikolaj Bjorner
5b219aab76 add mutual recursive datatypes to c++ API #6179
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2022-07-20 20:32:00 -07:00
Nikolaj Bjorner
2e13c0bf41 add API and example for one dimensional algebraic datatype #6179 2022-07-20 19:43:18 -07:00
Nikolaj Bjorner
393c63fe0c fix #6114 2022-07-18 09:33:39 -07:00
Nuno Lopes
fcbbf7ba76 fix build warning+error in c++ example 2022-06-17 16:43:34 +01:00
Henrich Lauko
96671cfc73
Add and fix a few general compiler warnings. (#5628)
* rewriter: fix unused variable warnings

* cmake: make missing non-virtual dtors error

* treewide: add missing virtual destructors

* cmake: add a few more checks

* api: add missing virtual destructor to user_propagator_base

* examples: compile cpp example with compiler warnings

* model: fix unused variable warnings

* rewriter: fix logical-op-parentheses warnings

* sat: fix unused variable warnings

* smt: fix unused variable warnings
2021-10-29 15:42:32 +02:00
Nikolaj Bjorner
eb8c8da8a7 ex handler
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2021-10-27 09:38:36 +02:00
Nikolaj Bjorner
7f41d6140f use some suggestions from #5615
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2021-10-22 12:39:55 -04:00
Nikolaj Bjorner
f05ac8a429 updated C++ API for escaped and unescaped strings #5615
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2021-10-21 14:52:59 -04:00
Nikolaj Bjorner
55285b2193 make it easier to iterate over arguments of an application
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2021-09-02 09:51:59 -07:00
Rolf Eike Beer
7f8e2a9f75
clean up CMake code (#5182)
* CMake: simplify FindGMP.cmake

Remove printing of all the different variables, and let FPHSA output the library
name. Add an imported target, which bundles the library and the include
directories for easier usage.

* fix build: vector::c_ptr() now is vector::data()

* CMake: use Threads::Threads imported module

Otherwise the setting of THREADS_PREFER_PTHREAD_FLAG has no effect.

* CMake: remove needless policy setting

The minimum required version is CMake 3.4, where these policies are already set
to new because they were introduced earlier.

* CMake: remove needless variable expansion
2021-04-14 10:29:15 -07:00
Nikolaj Bjorner
eacef5f3f9 deal with warnings over unused variables and procedures
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-11-29 19:45:35 -08:00
Nuno Lopes
9c08b60b5a c++ example: call Z3_finalize_memory() so that the buildbot leak checker doesnt complain about reachable memory 2020-10-24 15:35:56 +01:00
Nikolaj Bjorner
773b27296f translate optimize from c++ API #2859
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-01-15 04:24:51 -08:00
Nikolaj Bjorner
31a6788859 comment
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-10-11 12:39:57 -07:00
Nikolaj Bjorner
a990e7f02e add visitor example, fix double conversion
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-10-11 12:37:26 -07:00
Bruce Mitchener
0edd587e5a Fix typos in examples. 2019-08-14 22:00:50 -07:00
Nikolaj Bjorner
cb6d3d2458 increase minimal requirement to 3.4
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-06-07 17:05:12 -07:00
Nikolaj Bjorner
25c93410b1 add #2298 to regression/example
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-05-29 07:24:42 -07:00
Nikolaj Bjorner
082a0f4df4 add get_lstring per #2286
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-05-22 18:32:57 +04:00
Nikolaj Bjorner
886c62ef41 add example from #2138
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-02-16 10:30:44 -08:00
Nikolaj Bjorner
51a0022450 add recfun to API
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2018-10-27 11:41:18 -05:00
Florian Pigorsch
326bf401b9 Fix some spelling errors (mostly in comments). 2018-10-20 17:07:41 +02:00
Nikolaj Bjorner
694a6a26c9 bump version, add double access
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2018-10-19 20:20:08 -07:00
Bruce Mitchener
a76397d3b8 Refer to macOS rather than Mac OS / OSX. 2018-10-02 17:38:09 +07:00
rainoftime
bb534f6103 Add example of using z3's model construction C++ API 2018-07-10 11:16:20 +08:00
Nikolaj Bjorner
46ea054784 merge get_value and get_ivalue that produced different results
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2018-07-02 03:55:40 -07:00
Nikolaj Bjorner
f525f43e43 merge
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2018-04-30 09:30:43 -07:00
Nikolaj Bjorner
3b78bdc8e5 shorthands in enode to access args and partents
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2018-04-06 14:01:09 -07:00
Nikolaj Bjorner
5ba939ad5e add tuple shortcut and example to C++ API
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2018-04-03 12:40:18 -07:00
Nikolaj Bjorner
c513f3ca09 merge with master
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2018-03-25 14:57:01 -07:00
Nikolaj Bjorner
6b258578f9 fix uninitialized variable m_gc_burst in config, have cuber accept and receive optional vector of variables indicating splits and global autarky as output
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2017-12-14 02:38:45 -08:00
Dan Liew
92059942e6 [CMake] Use C++11 when building C++ API example.
This is a change requested by @NikolajBjorner (
5f8c97532c (commitcomment-26049417)
).
2017-12-07 10:56:44 +00:00
Nikolaj Bjorner
0bfea99cff fix issues found in parsing examples
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2017-12-01 14:43:52 -08:00
Nikolaj Bjorner
a9ebda105c remove assertion that gets violated on exception path (declaration of datatypes are not getting removed)
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2017-12-01 08:59:36 -08:00
Nikolaj Bjorner
392334f779 add ability to create and manipulate model objects
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2017-08-22 10:44:32 -07:00
Nikolaj Bjorner
b482dbd589 merge
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2017-07-27 17:02:27 -07:00
Dan Liew
4b517b96df [CMake] Move CMake files into their intended location so the
`contrib/cmake/bootstrap.py` script no longer needs to be executed.

The previous location of the CMake files was a compromise proposed
by @agurfinkel in #461. While this has served us well (allowing progress
to be made) over time limitations of this approach have appeared.

The main problem is that doing many git operations (e.g. pull, rebase)
means the CMake files don't get updated unless the user remembers to
run the script. This can lead to broken and confusing build system
behaviour.

This commit only does the file moving and necessary changes to
`.gitignore`. Other changes will be done in subsequent commits.
2017-06-12 11:59:00 +01:00
Nikolaj Bjorner
0ac80fc042 have parser produce ast-vector instead of single ast
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2017-06-01 21:21:05 -07:00
Nikolaj Bjorner
5d9820f3e2 add example of parsing with external declarations
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2016-10-07 12:57:07 -07:00
Nikolaj Bjorner
2263be1b4d adding consequence examples
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2016-07-29 17:24:14 -07:00
Christoph M. Wintersteiger
8c191781e7 Fixed warning message 2016-06-22 18:52:30 +01:00
Nikolaj Bjorner
8d61d36c3f add documentation methods to param_descrs, add C++ API and example for param_descrs. Issue #443
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2016-02-12 11:45:00 +00:00
Christoph M. Wintersteiger
2818e977b6 Fixed unused variable warnings in examples. 2015-10-29 13:20:56 +00:00
Christoph M. Wintersteiger
a1eee6275f Bugfix for C++ examples.
Relates to #26
2015-10-19 19:03:36 +01:00
Christoph M. Wintersteiger
a6f85f3932 Merge branch 'sudoku-in-c++' of https://github.com/benlaurie/z3 into benlaurie-sudoku-in-c++
# Conflicts:
#	examples/c++/example.cpp
2015-10-19 14:09:36 +01:00
Nikolaj Bjorner
d469a16bb8 add more Copyright notes
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2015-06-10 11:59:21 -07:00
Nikolaj Bjorner
ab5022888c Merge branch 'opt' of https://github.com/Z3Prover/z3 into unstable 2015-05-14 12:11:17 +01:00
Nikolaj Bjorner
4a9d97bd02 add concat to z3++, codeplex request
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2015-05-08 21:29:48 -07:00