From 10d040417524a13c9a16545dcf0ce4e1003690f6 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 4 Jul 2020 15:38:23 -0700 Subject: [PATCH] add rec decl/def to ML #4563 Signed-off-by: Nikolaj Bjorner --- src/api/ml/z3.ml | 11 +++++++++++ src/api/ml/z3.mli | 14 +++++++++++++- src/util/bit_vector.h | 4 +--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/api/ml/z3.ml b/src/api/ml/z3.ml index 47dd487ee..0bb4e4ff2 100644 --- a/src/api/ml/z3.ml +++ b/src/api/ml/z3.ml @@ -263,6 +263,8 @@ sig end val mk_func_decl : context -> Symbol.symbol -> Sort.sort list -> Sort.sort -> func_decl val mk_func_decl_s : context -> string -> Sort.sort list -> Sort.sort -> func_decl + val mk_rec_fun : context > Symbol.symbol -> Sort.sort list -> Sort.sort -> func_decl + val mk_rec_fun_s : context > string -> Sort.sort list -> Sort.sort -> func_decl val mk_fresh_func_decl : context -> string -> Sort.sort list -> Sort.sort -> func_decl val mk_const_decl : context -> Symbol.symbol -> Sort.sort -> func_decl val mk_const_decl_s : context -> string -> Sort.sort -> func_decl @@ -338,6 +340,15 @@ end = struct let mk_func_decl_s (ctx:context) (name:string) (domain:Sort.sort list) (range:Sort.sort) = mk_func_decl ctx (Symbol.mk_string ctx name) domain range + let mk_rec_fun (ctx:context) (name:Symbol.symbol) (domain:Sort.sort list) (range:Sort.sort) = + Z3native.mk_rec_fun ctx name (List.length domain) domain range + + let mk_rec_fun_s (ctx:context) (name:string) (domain:Sort.sort list) (range:Sort.sort) = + mk_rec_fun ctx (Symbol.mk_string ctx name) domain range + + let add_rec_def (ctx:context) (f:func_decl) (args:Expr.expr list) (body:Expr.expr) + Z3native.add_rec_def ctx f (List.length args) args body + let mk_fresh_func_decl (ctx:context) (prefix:string) (domain:Sort.sort list) (range:Sort.sort) = Z3native.mk_fresh_func_decl ctx prefix (List.length domain) domain range diff --git a/src/api/ml/z3.mli b/src/api/ml/z3.mli index 3ddb766d6..c19d39801 100644 --- a/src/api/ml/z3.mli +++ b/src/api/ml/z3.mli @@ -326,10 +326,22 @@ sig (** Creates a new function declaration. *) val mk_func_decl_s : context -> string -> Sort.sort list -> Sort.sort -> func_decl - (** Creates a fresh function declaration with a name prefixed with a prefix string. *) + (** Creates a function declaration that can be used in a recursive function definition. + {!add_rec_def} *) + val mk_rec_fun : context > Symbol.symbol -> Sort.sort list -> Sort.sort -> func_decl + + (** Creates a function declaration that can be used in a recursive function definition. + {!add_rec_def} *) + val mk_rec_fun_s : context > string -> Sort.sort list -> Sort.sort -> func_decl + + (** Registers a recursive function definition *) + val add_rec_def : context -> func_decl -> Expr.expr list -> Expr.expr -> unit + + (** Creates a fresh function declaration with a name prefixed with a prefix string. *) val mk_fresh_func_decl : context -> string -> Sort.sort list -> Sort.sort -> func_decl + (** Creates a new constant function declaration. *) val mk_const_decl : context -> Symbol.symbol -> Sort.sort -> func_decl diff --git a/src/util/bit_vector.h b/src/util/bit_vector.h index 5f21d2e59..31cb00281 100644 --- a/src/util/bit_vector.h +++ b/src/util/bit_vector.h @@ -16,8 +16,7 @@ Author: Revision History: --*/ -#ifndef BIT_VECTOR_H_ -#define BIT_VECTOR_H_ +#pragma once #include #include "util/debug.h" @@ -251,5 +250,4 @@ public: } }; -#endif /* BIT_VECTOR_H_ */