Z3
NativeFuncInterp.cs
Go to the documentation of this file.
1/*++
2Copyright (c) 2012 Microsoft Corporation
3
4Module Name:
5
6 NativeFuncInterp.cs
7
8Abstract:
9
10 Z3 Managed API: Function Interpretations
11
12Author:
13
14 Christoph Wintersteiger (cwinter) 2012-03-21
15
16Notes:
17
18--*/
19
20using System.Diagnostics;
21using System;
22
23namespace Microsoft.Z3
24{
25
26 using Z3_context = System.IntPtr;
27 using Z3_ast = System.IntPtr;
28 using Z3_app = System.IntPtr;
29 using Z3_sort = System.IntPtr;
30 using Z3_func_decl = System.IntPtr;
31 using Z3_model = System.IntPtr;
32 using Z3_func_interp = System.IntPtr;
33 using Z3_func_entry = System.IntPtr;
34
39 public class NativeFuncInterp
40 {
41
45 public class Entry
46 {
50 public Z3_ast[] Arguments;
51
55 public Z3_ast Result;
56 }
57
62
66 public Entry[] Entries;
67
71 public Z3_ast Else;
72
73 #region Internal
75 {
76 Debug.Assert(ctx != null);
77 Z3_context nCtx = ctx.nCtx;
78 Native.Z3_func_interp_inc_ref(nCtx, fi);
79
80 Declaration = decl;
81 Else = Native.Z3_func_interp_get_else(nCtx, fi);
82 uint numEntries = Native.Z3_func_interp_get_num_entries(nCtx, fi);
83 uint numArgs = Native.Z3_func_interp_get_arity(nCtx, fi);
84 Entries = new Entry[numEntries];
85
86 for (uint j = 0; j < numEntries; ++j)
87 {
88 var ntvEntry = Native.Z3_func_interp_get_entry(nCtx, fi, j);
89 Entries[j] = new Entry();
90 Native.Z3_func_entry_inc_ref(nCtx, ntvEntry);
91 Entries[j].Arguments = new Z3_ast[numArgs];
92 for (uint i = 0; i < numArgs; ++i)
93 Entries[j].Arguments[i] = Native.Z3_func_entry_get_arg(nCtx, ntvEntry, i);
94 Entries[j].Result = Native.Z3_func_entry_get_value(nCtx, ntvEntry);
95 Native.Z3_func_entry_dec_ref(nCtx, ntvEntry);
96 }
97
98 Native.Z3_func_interp_dec_ref(nCtx, fi);
99 }
100
101
102 #endregion
103 }
104}
The main interaction with Z3 happens via the Context. NativeContext allows for efficient wrapper-redu...
Evaluation entry of a function
Z3_ast[] Arguments
Argument values that define entry
Z3_ast Result
Result of applying function to Arguments in the interpretation
A function interpretation is represented as a finite map and an 'else' value. Each entry in the finit...
Z3_ast Else
Default cause of the function interpretation
Entry[] Entries
Set of non-default entries defining the function graph
Z3_func_decl Declaration
Function that is interpreted
A Model contains interpretations (assignments) of constants and functions.
Definition: NativeModel.cs:37
System.IntPtr Z3_model
System.IntPtr Z3_app
System.IntPtr Z3_context
Definition: Context.cs:29
System.IntPtr Z3_func_interp
System.IntPtr Z3_func_decl
System.IntPtr Z3_ast
System.IntPtr Z3_func_entry
System.IntPtr Z3_sort