mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
add recfuns to Java #4820
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
6aba325cea
commit
d6a5ef4343
6 changed files with 71 additions and 17 deletions
|
@ -439,7 +439,6 @@ public class Context implements AutoCloseable {
|
|||
* Creates a new function declaration.
|
||||
**/
|
||||
public FuncDecl mkFuncDecl(Symbol name, Sort[] domain, Sort range)
|
||||
|
||||
{
|
||||
checkContextMatch(name);
|
||||
checkContextMatch(domain);
|
||||
|
@ -483,6 +482,33 @@ public class Context implements AutoCloseable {
|
|||
return new FuncDecl(this, mkSymbol(name), q, range);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new recursive function declaration.
|
||||
**/
|
||||
public FuncDecl mkRecFuncDecl(Symbol name, Sort[] domain, Sort range)
|
||||
{
|
||||
checkContextMatch(name);
|
||||
checkContextMatch(domain);
|
||||
checkContextMatch(range);
|
||||
return new FuncDecl(this, name, domain, range, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bind a definition to a recursive function declaration.
|
||||
* The function must have previously been created using
|
||||
* MkRecFuncDecl. The body may contain recursive uses of the function or
|
||||
* other mutually recursive functions.
|
||||
*/
|
||||
public void AddRecDef(FuncDecl f, Expr[] args, Expr body)
|
||||
{
|
||||
checkContextMatch(f);
|
||||
checkContextMatch(args);
|
||||
checkContextMatch(body);
|
||||
long[] argsNative = AST.arrayToNative(args);
|
||||
Native.addRecDef(nCtx(), f.getNativeObject(), (uint)args.Length, argsNative, body.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a fresh function declaration with a name prefixed with
|
||||
* {@code prefix}.
|
||||
|
|
|
@ -336,11 +336,17 @@ public class FuncDecl extends AST
|
|||
}
|
||||
|
||||
FuncDecl(Context ctx, Symbol name, Sort[] domain, Sort range)
|
||||
|
||||
{
|
||||
super(ctx, Native.mkFuncDecl(ctx.nCtx(), name.getNativeObject(),
|
||||
AST.arrayLength(domain), AST.arrayToNative(domain),
|
||||
range.getNativeObject()));
|
||||
}
|
||||
|
||||
FuncDecl(Context ctx, Symbol name, Sort[] domain, Sort range, bool is_rec)
|
||||
{
|
||||
super(ctx, Native.mkRecFuncDecl(ctx.nCtx(), name.getNativeObject(),
|
||||
AST.arrayLength(domain), AST.arrayToNative(domain),
|
||||
range.getNativeObject()));
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue