mirror of
https://github.com/Z3Prover/z3
synced 2026-01-28 12:58:43 +00:00
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>
This commit is contained in:
parent
105bc0fd57
commit
01948e168b
2 changed files with 25 additions and 0 deletions
|
|
@ -216,6 +216,8 @@ sig
|
|||
val to_string : sort -> string
|
||||
val mk_uninterpreted : context -> Symbol.symbol -> sort
|
||||
val mk_uninterpreted_s : context -> string -> sort
|
||||
val mk_type_variable : context -> Symbol.symbol -> sort
|
||||
val mk_type_variable_s : context -> string -> sort
|
||||
end = struct
|
||||
type sort = Z3native.sort
|
||||
let gc a = Z3native.context_of_ast a
|
||||
|
|
@ -228,6 +230,8 @@ end = struct
|
|||
let to_string (x:sort) = Z3native.sort_to_string (gc x) x
|
||||
let mk_uninterpreted ctx s = Z3native.mk_uninterpreted_sort ctx s
|
||||
let mk_uninterpreted_s (ctx:context) (s:string) = mk_uninterpreted ctx (Symbol.mk_string ctx s)
|
||||
let mk_type_variable ctx s = Z3native.mk_type_variable ctx s
|
||||
let mk_type_variable_s (ctx:context) (s:string) = mk_type_variable ctx (Symbol.mk_string ctx s)
|
||||
end
|
||||
|
||||
and FuncDecl :
|
||||
|
|
@ -908,6 +912,13 @@ struct
|
|||
let mk_sort_s (ctx:context) (name:string) (constructors:Constructor.constructor list) =
|
||||
mk_sort ctx (Symbol.mk_string ctx name) constructors
|
||||
|
||||
let mk_polymorphic_sort (ctx:context) (name:Symbol.symbol) (type_params:Sort.sort list) (constructors:Constructor.constructor list) =
|
||||
let (x,_) = Z3native.mk_polymorphic_datatype ctx name (List.length type_params) type_params (List.length constructors) constructors in
|
||||
x
|
||||
|
||||
let mk_polymorphic_sort_s (ctx:context) (name:string) (type_params:Sort.sort list) (constructors:Constructor.constructor list) =
|
||||
mk_polymorphic_sort ctx (Symbol.mk_string ctx name) type_params constructors
|
||||
|
||||
let mk_sort_ref (ctx: context) (name:Symbol.symbol) =
|
||||
Z3native.mk_datatype_sort ctx name 0 []
|
||||
|
||||
|
|
|
|||
|
|
@ -290,6 +290,12 @@ sig
|
|||
|
||||
(** Create a new uninterpreted sort. *)
|
||||
val mk_uninterpreted_s : context -> string -> sort
|
||||
|
||||
(** Create a type variable sort for use in polymorphic datatypes. *)
|
||||
val mk_type_variable : context -> Symbol.symbol -> sort
|
||||
|
||||
(** Create a type variable sort for use in polymorphic datatypes. *)
|
||||
val mk_type_variable_s : context -> string -> sort
|
||||
end
|
||||
|
||||
(** Function declarations *)
|
||||
|
|
@ -1099,6 +1105,14 @@ sig
|
|||
(** Create a new datatype sort. *)
|
||||
val mk_sort_s : context -> string -> Constructor.constructor list -> Sort.sort
|
||||
|
||||
(** Create a new polymorphic datatype sort with type parameters.
|
||||
Type parameters should be created using Sort.mk_type_variable. *)
|
||||
val mk_polymorphic_sort : context -> Symbol.symbol -> Sort.sort list -> Constructor.constructor list -> Sort.sort
|
||||
|
||||
(** Create a new polymorphic datatype sort with type parameters.
|
||||
Type parameters should be created using Sort.mk_type_variable. *)
|
||||
val mk_polymorphic_sort_s : context -> string -> Sort.sort list -> Constructor.constructor list -> Sort.sort
|
||||
|
||||
(** Create mutually recursive datatypes. *)
|
||||
val mk_sorts : context -> Symbol.symbol list -> Constructor.constructor list list -> Sort.sort list
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue