3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-17 22:24:20 +00:00
Commit graph

116 commits

Author SHA1 Message Date
copilot-swe-agent[bot]
ac39c021bf Add datatype_update_field to C++, Python, TypeScript, and OCaml bindings
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-04 21:57:57 +00:00
Copilot
01948e168b
Add polymorphic datatype support to ML API (#8378)
* Initial plan

* Add ML bindings for polymorphic datatypes (mk_type_variable and mk_polymorphic_sort)

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Add polymorphic datatype example for ML API

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Delete examples/ml/polymorphic_datatype_example.ml

---------

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>
2026-01-27 11:44:35 -08:00
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
Shiwei Weng 翁士伟
c2efd3dc6d
Update on building OCaml binding with CMake (#7698)
* fix: add generating META for ocamlfind.

* Patch macos. We need to keep the `@rpath` and use environment var to enable the test because we need to leave it to be fixed by package managers.

* Trigger CI.

* Debug.

* Debug.

* Debug.

* Debug.

* Debug.

* Debug.

* Hacky fix for ocaml building warning.

* Fix typo and rename variables.
2025-06-27 17:55:58 -07:00
Nikolaj Bjorner
17cac7d87c provide shortcut to command-line version to retrieve parameters
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-04-19 13:51:08 -07:00
Shiwei Weng 翁士伟
f7aec02503
WIP: Migrating OCaml binding to CMake (#7254)
* Update doc for `mk_context`.

* Migrating to cmake.

* Migrating to cmake. It builds both internal or external libz3.

* Start to work on platform-specific problem.

* Messy notes.

* debug.

* Cleanup a bit.

* Fixing shared lib extension.

* Minor.

* Resume working on this PR.

* Remove including `AddOCaml`.

* Keep `z3.ml` and `z3.mli` in the src but specify the generated file in the bin.

* Keep `ml_example.ml` in the src.

* Try github action for ocaml.

* Add workflow using matrix.

* Fix mac linking once more.

* Bypass @rpath in building sanity check.
2025-04-19 13:41:27 -07:00
Christoph M. Wintersteiger
68a2c08d5e
Add Z3_get_estimated_alloc_size to OCaml API (#7068) 2023-12-21 12:54:30 -08:00
Andrey Andreyevich Bienkowski
18f14921ba
Clarify optimizer guarantees (#7030)
* Clarify optimizer guarantees (python)

* Clarify optimization guarantees (OCaml)

* Clarify optimizer guarantees (java)

* Clarify optimizer guarantees (.net)
2023-12-04 09:32:26 -08:00
Christoph M. Wintersteiger
16753e43f1
Add accessors for RCF numeral internals (#7013) 2023-11-23 17:54:23 +01:00
Christoph M. Wintersteiger
3af2b36cd7
Add Z3_solver_interrupt to OCaml API (#6976) 2023-10-31 08:48:06 -07:00
Christoph M. Wintersteiger
23de8056d7
Add RCF functions to OCaml API (#6932) 2023-10-06 11:49:22 +09:00
권승완
6670807103
update ocaml binding to support more string apis (#6656) 2023-03-29 05:49:33 -07:00
Nikolaj Bjorner
d51d518f96 update ml api
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2023-01-31 19:24:45 -08:00
Nikolaj Bjorner
1289937d1a update ml api
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2023-01-31 19:19:41 -08:00
Nikolaj Bjorner
9a94a9aa6f update ml api
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2023-01-31 19:14:24 -08:00
Nikolaj Bjorner
4c6d44f974 add ocaml signature for simplifier
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2023-01-31 18:58:18 -08:00
Nikolaj Bjorner
fa72ec5405 switch to expose fresh function instead of changing legacy function
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2023-01-24 13:05:34 -08:00
Nikolaj Bjorner
3f1b7866ca convert caml mk_real to int64
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2023-01-24 03:53:42 -08:00
Nikolaj Bjorner
b5a89eb4ab add missing generation of z3.z3 for pydoc and add some explanations to logging function declaration 2022-07-17 11:03:55 -07:00
Stefan Muenzel
99212a2726
Use int64 for ocaml api functions that require it (#6150)
* Use int64 for ocaml api functions that require it

Signed-off-by: Stefan Muenzel <source@s.muenzel.net>

* Use elif

Signed-off-by: Stefan Muenzel <source@s.muenzel.net>
2022-07-11 09:25:05 -07:00
Sacha Ayoun
ffbabf251d
enhance ocaml seq api (#6010)
Signed-off-by: Sacha Ayoun <sachaayoun@gmail.com>
2022-05-04 12:03:22 -07:00
Gabriel Radanne
0c7625cd26
Remove size argument in OCaml's Z3.mk_re_intersect (#5383)
* Remove size argument in OCaml's `Z3.mk_re_intersect`

Passing the size as argument is unnecessary in OCaml, and that argument is abridged in all similar `Seq` functions. This applies the same pattern.

* Enable the ocaml documentation in Seq.

Turn all the comments into proper documentation comments.
2021-07-06 01:21:04 -07:00
Nikolaj Bjorner
04a1d4245c fix #4801 2021-02-12 20:20:00 -08:00
Nikolaj Bjorner
49dfaeb406 na
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-10-12 13:11:46 -07:00
Nikolaj Bjorner
dd5e2e8930 check for 0
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-07-22 10:44:00 -07:00
Nikolaj Bjorner
006418e027 build
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-07-04 23:34:21 -07:00
Nikolaj Bjorner
f3b51db891 ml build
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-07-04 16:22:01 -07:00
Nikolaj Bjorner
10d0404175 add rec decl/def to ML #4563
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-07-04 15:38:32 -07:00
Nikolaj Bjorner
a432fd71d3 update ocaml doc per #2843
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-01-06 20:26:06 -08:00
Nicola Mometto
77c3f1fb82 fix ocaml build by moving to Zarith methods 2019-10-14 09:48:51 -07:00
Nikolaj Bjorner
40e329fc92 remove push/pop for fixedpoint objects from API #2249
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-04-27 10:13:15 -07:00
Nicola Mometto
9008beeb01 fix mk_quantifier signature 2019-03-26 14:33:20 +00:00
Nicola Mometto
fa97f4a626 fix name clash in ocaml api 2019-03-26 14:16:31 +00:00
Bruce Mitchener
7fb0106ead Fix typo in OCaml API docs. 2018-11-27 22:14:41 +07:00
Nicola Mometto
f18227bf2d Add Memory.reset to OCaml API 2018-11-26 17:24:51 +00:00
Nikolaj Bjorner
0457b5a73f add arguments to optimize_check fix #1866
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2018-10-14 20:39:54 -07:00
Nikolaj Bjorner
a5762a78e9 change to ast-vector
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2018-09-30 17:39:18 -07:00
Nikolaj Bjorner
94ffa3963e fix #1800 by converting large integers to strings
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2018-08-24 16:54:22 +02:00
Nikolaj Bjorner
6dc9c3a587 fix ml build breakd #1659, #1660
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2018-05-29 07:37:27 -07:00
Bruce Mitchener
a3facc82fb Update OCaml docs for changes made elsewhere.
This removes references to the PROOF_MODE that have been removed
elsewhere.
2018-05-23 23:55:17 +07:00
Nikolaj Bjorner
b1f05d8271 fix #1539
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2018-03-14 18:14:29 -07:00
Bruce Mitchener
73b3da37d8 Typo fixes. 2018-01-02 22:48:06 +07:00
Christoph M. Wintersteiger
c3c06d756c Documentation fixes. 2017-12-18 20:12:19 +00:00
Nikolaj Bjorner
8e1ab23c3d remove deprecated functions from ML API. #1393
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2017-12-07 18:43:29 +05:30
Christoph M. Wintersteiger
ed5058d225 Fixed typo in ML API. Relates to #1214. 2017-08-21 18:21:31 +01:00
Nikolaj Bjorner
aa81d58bb0 add sequences to ML API #1214
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2017-08-18 14:29:53 -07:00
Nikolaj Bjorner
6feb7ba795 :q
add sequences to ML API

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2017-08-18 14:28:05 -07:00
Christoph M. Wintersteiger
9053e6eba6 Resolved merge conflicts. Added FPA API input validity checks. 2016-11-15 20:19:40 +00:00
Christoph M. Wintersteiger
9ebea09d05 added is_numeral_negative to ML API. 2016-11-07 10:28:39 +00:00
Christoph M. Wintersteiger
81fce55d78 Updated optimization ML API. Addresses #776. 2016-11-04 21:22:01 +00:00