/// <summary> /// Retrieves the interpretation (the assignment) of a non-constant <paramref name="f"/> in the model. /// </summary> /// <param name="f">A function declaration of non-zero arity</param> /// <returns>A FunctionInterpretation if the function has an interpretation in the model, null otherwise.</returns> public FuncInterp FuncInterp(FuncDecl f) { Debug.Assert(f != null); Context.CheckContextMatch(f); Z3_sort_kind sk = (Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_range(Context.nCtx, f.NativeObject)); if (f.Arity == 0) { IntPtr n = Native.Z3_model_get_const_interp(Context.nCtx, NativeObject, f.NativeObject); if (sk == Z3_sort_kind.Z3_ARRAY_SORT) { if (n == IntPtr.Zero) { return(null); } else { if (Native.Z3_is_as_array(Context.nCtx, n) == 0) { throw new Z3Exception("Argument was not an array constant"); } IntPtr fd = Native.Z3_get_as_array_func_decl(Context.nCtx, n); using var decl = new FuncDecl(Context, fd); return(FuncInterp(decl)); } } else { throw new Z3Exception("Constant functions do not have a function interpretation; use ConstInterp"); } } else { IntPtr n = Native.Z3_model_get_func_interp(Context.nCtx, NativeObject, f.NativeObject); if (n == IntPtr.Zero) { return(null); } else { return(new FuncInterp(Context, n)); } } }
/// <summary> /// Retrieves the interpretation (the assignment) of a non-constant <paramref name="f"/> in the model. /// </summary> /// <param name="f">A function declaration of non-zero arity</param> /// <returns>A FunctionInterpretation if the function has an interpretation in the model, null otherwise.</returns> public NativeFuncInterp FuncInterp(Z3_func_decl f) { Z3_sort_kind sk = (Z3_sort_kind)Native.Z3_get_sort_kind(ntvContext.nCtx, Native.Z3_get_range(ntvContext.nCtx, f)); if (Native.Z3_get_arity(ntvContext.nCtx, f) == 0) { IntPtr n = Native.Z3_model_get_const_interp(ntvContext.nCtx, NativeObject, f); if (sk == Z3_sort_kind.Z3_ARRAY_SORT) { if (n == IntPtr.Zero) { return(null); } else { if (Native.Z3_is_as_array(ntvContext.nCtx, n) == 0) { throw new Z3Exception("Argument was not an array constant"); } var fd = Native.Z3_get_as_array_func_decl(ntvContext.nCtx, n); return(new NativeFuncInterp(ntvContext, this, f, fd)); } } else { throw new Z3Exception("Constant functions do not have a function interpretation; use ConstInterp"); } } else { IntPtr n = Native.Z3_model_get_func_interp(ntvContext.nCtx, NativeObject, f); if (n == IntPtr.Zero) { return(null); } else { return(new NativeFuncInterp(ntvContext, this, f, n)); } } }