Z3
TupleSort.cs
Go to the documentation of this file.
1 /*++
2 Copyright (c) 2012 Microsoft Corporation
3 
4 Module Name:
5 
6  TupleSort.cs
7 
8 Abstract:
9 
10  Z3 Managed API: Tuple Sorts
11 
12 Author:
13 
14  Christoph Wintersteiger (cwinter) 2012-11-23
15 
16 Notes:
17 
18 --*/
19 
20 using System;
21 using System.Diagnostics.Contracts;
22 
23 namespace Microsoft.Z3
24 {
28  [ContractVerification(true)]
29  public class TupleSort : Sort
30  {
34  public FuncDecl MkDecl
35  {
36  get
37  {
38  Contract.Ensures(Contract.Result<FuncDecl>() != null);
39 
40  return new FuncDecl(Context, Native.Z3_get_tuple_sort_mk_decl(Context.nCtx, NativeObject));
41  }
42  }
43 
47  public uint NumFields
48  {
49  get { return Native.Z3_get_tuple_sort_num_fields(Context.nCtx, NativeObject); }
50  }
51 
55  public FuncDecl[] FieldDecls
56  {
57  get
58  {
59  Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
60 
61  uint n = NumFields;
62  FuncDecl[] res = new FuncDecl[n];
63  for (uint i = 0; i < n; i++)
64  res[i] = new FuncDecl(Context, Native.Z3_get_tuple_sort_field_decl(Context.nCtx, NativeObject, i));
65  return res;
66  }
67  }
68 
69  #region Internal
70  internal TupleSort(Context ctx, Symbol name, uint numFields, Symbol[] fieldNames, Sort[] fieldSorts)
71  : base(ctx, IntPtr.Zero)
72  {
73  Contract.Requires(ctx != null);
74  Contract.Requires(name != null);
75 
76  IntPtr t = IntPtr.Zero;
77  IntPtr[] f = new IntPtr[numFields];
78  NativeObject = Native.Z3_mk_tuple_sort(ctx.nCtx, name.NativeObject, numFields,
79  Symbol.ArrayToNative(fieldNames), AST.ArrayToNative(fieldSorts),
80  ref t, f);
81  }
82  #endregion
83  };
84 }
static Z3_sort Z3_mk_tuple_sort(Z3_context a0, IntPtr a1, uint a2, [In] IntPtr[] a3, [In] Z3_sort[] a4, [In, Out] ref Z3_func_decl a5, [Out] Z3_func_decl[] a6)
Definition: Native.cs:2210
using System
static Z3_func_decl Z3_get_tuple_sort_mk_decl(Z3_context a0, Z3_sort a1)
Definition: Native.cs:3270
static Z3_func_decl Z3_get_tuple_sort_field_decl(Z3_context a0, Z3_sort a1, uint a2)
Definition: Native.cs:3286
static uint Z3_get_tuple_sort_num_fields(Z3_context a0, Z3_sort a1)
Definition: Native.cs:3278
The main interaction with Z3 happens via the Context.
Definition: Context.cs:31
The Sort class implements type information for ASTs.
Definition: Sort.cs:29
The abstract syntax tree (AST) class.
Definition: AST.cs:31
Symbols are used to name several term and type constructors.
Definition: Symbol.cs:30
Function declarations.
Definition: FuncDecl.cs:29
Tuple sorts.
Definition: TupleSort.cs:29