Beispiel #1
0
        /// <summary>
        /// returns ListSort
        /// </summary>
        /// <param name="name"></param>
        /// <param name="elemSort"></param>
        /// <param name="inil"></param>
        /// <param name="iisnil"></param>
        /// <param name="icons"></param>
        /// <param name="iiscons"></param>
        /// <param name="ihead"></param>
        /// <param name="itail"></param>
        /// <returns>The list algebraic datatype</returns>

        public Z3_sort MkListSort(string name, Z3_sort elemSort,
                                  out Z3_func_decl inil, out Z3_func_decl iisnil,
                                  out Z3_func_decl icons, out Z3_func_decl iiscons,
                                  out Z3_func_decl ihead, out Z3_func_decl itail)
        {
            Debug.Assert(!string.IsNullOrEmpty(name));
            Debug.Assert(elemSort != IntPtr.Zero);

            IntPtr nil = IntPtr.Zero, isnil = IntPtr.Zero,
                   cons = IntPtr.Zero, iscons = IntPtr.Zero,
                   head = IntPtr.Zero, tail = IntPtr.Zero;

            var symbol = Native.Z3_mk_string_symbol(nCtx, name);
            var sort   = Native.Z3_mk_list_sort(nCtx, symbol, elemSort,
                                                ref nil, ref isnil, ref cons, ref iscons, ref head, ref tail);

            inil    = nil;
            iisnil  = isnil;
            icons   = cons;
            iiscons = iscons;
            ihead   = head;
            itail   = tail;

            return(sort);
        }
Beispiel #2
0
        /// <summary>
        /// Create a new array sort.
        /// </summary>
        public Z3_sort MkArraySort(Z3_sort domain, Z3_sort range)
        {
            Debug.Assert(domain != IntPtr.Zero);
            Debug.Assert(range != IntPtr.Zero);

            return(Native.Z3_mk_array_sort(nCtx, domain, range));
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new Constant of sort <paramref name="range"/> and named <paramref name="name"/>.
        /// </summary>
        public Z3_ast MkConst(string name, Z3_sort range)
        {
            Debug.Assert(!string.IsNullOrEmpty(name));
            Debug.Assert(range != IntPtr.Zero);

            return(Native.Z3_mk_const(nCtx, MkStringSymbol(name), range));
        }
Beispiel #4
0
        /// <summary>
        /// Create a constant array.
        /// </summary>
        /// <remarks>
        /// The resulting term is an array, such that a <c>select</c>on an arbitrary index
        /// produces the value <c>v</c>.
        /// </remarks>
        public Z3_ast MkConstArray(Z3_sort domain, Z3_ast v)
        {
            Debug.Assert(domain != IntPtr.Zero);
            Debug.Assert(v != IntPtr.Zero);

            return(Native.Z3_mk_const_array(nCtx, domain, v));
        }
Beispiel #5
0
        /// <summary>
        /// Add constraints to ensure the function f can only be injective.
        /// Example:
        /// for function f : D1 x D2 -> R
        /// assert axioms
        ///   forall (x1 : D1, x2 : D2) x1 = inv1(f(x1,x2))
        ///   forall (x1 : D1, x2 : D2) x2 = inv2(f(x1,x2))
        /// </summary>
        /// <param name="f"></param>
        public void AssertInjective(Z3_func_decl f)
        {
            uint    arity = Native.Z3_get_arity(nCtx, f);
            Z3_sort range = Native.Z3_get_range(nCtx, f);

            Z3_ast[]    vars  = new Z3_ast[arity];
            Z3_sort[]   sorts = new Z3_sort[arity];
            Z3_symbol[] names = new Z3_symbol[arity];
            for (uint i = 0; i < arity; ++i)
            {
                Z3_sort domain = Native.Z3_get_domain(nCtx, f, i);
                vars[i]  = ntvContext.MkBound(arity - i - 1, domain);
                sorts[i] = domain;
                names[i] = Native.Z3_mk_int_symbol(nCtx, (int)i);
            }
            Z3_ast app_f = IntPtr.Zero; // Context.MkApp(f, vars);

            for (uint i = 0; i < arity; ++i)
            {
                Z3_sort      domain = Native.Z3_get_domain(nCtx, f, i);
                Z3_func_decl proj   = ntvContext.MkFreshFuncDecl("inv", new Z3_sort[] { range }, domain);
                Z3_ast       body   = ntvContext.MkEq(vars[i], ntvContext.MkApp(proj, app_f));
                Z3_ast       q      = ntvContext.MkForall(names, sorts, body);
                Assert(q);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Creates a new constant function declaration.
        /// </summary>
        public Z3_func_decl MkConstDecl(string name, Z3_sort range)
        {
            Debug.Assert(range != IntPtr.Zero);

            var symbol = Native.Z3_mk_string_symbol(nCtx, name);

            return(Native.Z3_mk_func_decl(nCtx, symbol, 0, new IntPtr[0], range));
        }
Beispiel #7
0
        /// <summary>
        /// Creates a fresh function declaration with a name prefixed with <paramref name="prefix"/>.
        /// </summary>
        public Z3_func_decl MkFreshFuncDecl(string prefix, Z3_sort[] domain, Z3_sort range)
        {
            Debug.Assert(domain != null);
            Debug.Assert(range != IntPtr.Zero);
            Debug.Assert(domain.All(d => d != IntPtr.Zero));

            return(Native.Z3_mk_fresh_func_decl(nCtx, prefix, (uint)(domain?.Length ?? 0), domain, range));
        }
Beispiel #8
0
        /// <summary>
        /// Creates a new function declaration.
        /// </summary>
        public Z3_func_decl MkFuncDecl(string name, Z3_sort[] domain, Z3_sort range)
        {
            Debug.Assert(!string.IsNullOrEmpty(name));
            Debug.Assert(range != IntPtr.Zero);
            Debug.Assert(domain != null);
            Debug.Assert(domain.All(d => d != IntPtr.Zero));

            var symbol = Native.Z3_mk_string_symbol(nCtx, name);

            return(Native.Z3_mk_func_decl(nCtx, symbol, (uint)(domain?.Length ?? 0), domain, range));
        }
Beispiel #9
0
        /// <summary>
        /// Creates a new function declaration.
        /// </summary>
        public Z3_func_decl MkFuncDecl(string name, Z3_sort domain, Z3_sort range)
        {
            Debug.Assert(!string.IsNullOrEmpty(name));
            Debug.Assert(range != IntPtr.Zero);
            Debug.Assert(domain != IntPtr.Zero);

            var symbol = Native.Z3_mk_string_symbol(nCtx, name);
            var q      = new Z3_sort[] { domain };

            return(Native.Z3_mk_func_decl(nCtx, symbol, (uint)q.Length, q, range));
        }
Beispiel #10
0
        /// <summary>
        /// Get domain for a funcdecl
        /// </summary>
        /// <param name="fdecl"></param>
        /// <returns></returns>
        public Z3_sort[] GetDomain(Z3_func_decl fdecl)
        {
            Debug.Assert(fdecl != IntPtr.Zero);

            var sz     = Native.Z3_get_domain_size(nCtx, fdecl);
            var domain = new Z3_sort[sz];

            for (uint i = 0; i < sz; i++)
            {
                domain[i] = Native.Z3_get_domain(nCtx, fdecl, i);
            }
            return(domain);
        }
Beispiel #11
0
        /// <summary>
        /// Create a Term of a given sort. This function can be used to create numerals that fit in a machine integer.
        /// </summary>
        /// <param name="v">Value of the numeral</param>
        /// <param name="sort">Sort of the numeral</param>
        public Z3_ast MkNumeral(uint v, Z3_sort sort)
        {
            Debug.Assert(sort != null);

            return(Native.Z3_mk_unsigned_int(nCtx, v, sort));
        }
Beispiel #12
0
        /// <summary>
        /// Get size of BitVector Sort
        /// </summary>
        public uint GetBvSortSize(Z3_sort bvSort)
        {
            Debug.Assert(bvSort != IntPtr.Zero);

            return(Native.Z3_get_bv_sort_size(nCtx, bvSort));
        }
Beispiel #13
0
 public extern static Z3_ast Z3_mk_bound(Z3_context a0, uint a1, Z3_sort a2);
Beispiel #14
0
 public extern static IntPtr Z3_sort_to_string(Z3_context a0, Z3_sort a1);
Beispiel #15
0
 public static Z3_ast Z3_mk_fpa_to_fp_int_real(Z3_context a0, Z3_ast a1, Z3_ast a2, Z3_ast a3, Z3_sort a4) {
     Z3_ast r = LIB.Z3_mk_fpa_to_fp_int_real(a0, a1, a2, a3, a4);
     Z3_error_code err = (Z3_error_code)LIB.Z3_get_error_code(a0);
     if (err != Z3_error_code.Z3_OK)
         throw new Z3Exception(Marshal.PtrToStringAnsi(LIB.Z3_get_error_msg_ex(a0, (uint)err)));
     return r;
 }
Beispiel #16
0
 public extern static Z3_ast Z3_mk_numeral(Z3_context a0, string a1, Z3_sort a2);
Beispiel #17
0
 public extern static Z3_sort Z3_get_array_sort_range(Z3_context a0, Z3_sort a1);
Beispiel #18
0
 public extern static Z3_sort Z3_get_array_sort_domain(Z3_context a0, Z3_sort a1);
Beispiel #19
0
 public static Z3_func_decl Z3_mk_injective_function(Z3_context a0, IntPtr a1, uint a2, [In] Z3_sort[] a3, Z3_sort a4) {
     Z3_func_decl r = LIB.Z3_mk_injective_function(a0, a1, a2, a3, a4);
     Z3_error_code err = (Z3_error_code)LIB.Z3_get_error_code(a0);
     if (err != Z3_error_code.Z3_OK)
         throw new Z3Exception(Marshal.PtrToStringAnsi(LIB.Z3_get_error_msg_ex(a0, (uint)err)));
     return r;
 }
Beispiel #20
0
 public extern static int Z3_get_finite_domain_sort_size(Z3_context a0, Z3_sort a1, [In, Out] ref UInt64 a2);
Beispiel #21
0
 public extern static uint Z3_get_bv_sort_size(Z3_context a0, Z3_sort a1);
Beispiel #22
0
 public extern static uint Z3_get_sort_kind(Z3_context a0, Z3_sort a1);
Beispiel #23
0
 public extern static int Z3_is_eq_sort(Z3_context a0, Z3_sort a1, Z3_sort a2);
Beispiel #24
0
 public extern static Z3_ast Z3_mk_int64(Z3_context a0, Int64 a1, Z3_sort a2);
Beispiel #25
0
 public extern static Z3_ast Z3_mk_int(Z3_context a0, int a1, Z3_sort a2);
Beispiel #26
0
 public extern static Z3_func_decl Z3_get_tuple_sort_mk_decl(Z3_context a0, Z3_sort a1);
Beispiel #27
0
 public extern static Z3_ast Z3_sort_to_ast(Z3_context a0, Z3_sort a1);
Beispiel #28
0
 public extern static uint Z3_get_tuple_sort_num_fields(Z3_context a0, Z3_sort a1);
Beispiel #29
0
 public extern static Z3_ast_vector Z3_model_get_sort_universe(Z3_context a0, Z3_model a1, Z3_sort a2);
Beispiel #30
0
 public extern static Z3_func_decl Z3_get_tuple_sort_field_decl(Z3_context a0, Z3_sort a1, uint a2);
Beispiel #31
0
 public extern static uint Z3_get_datatype_sort_num_constructors(Z3_context a0, Z3_sort a1);
Beispiel #32
0
 public extern static Z3_func_decl Z3_get_datatype_sort_recognizer(Z3_context a0, Z3_sort a1, uint a2);
Beispiel #33
0
 public extern static Z3_ast Z3_mk_unsigned_int64(Z3_context a0, UInt64 a1, Z3_sort a2);
Beispiel #34
0
 public extern static Z3_func_decl Z3_get_datatype_sort_constructor_accessor(Z3_context a0, Z3_sort a1, uint a2, uint a3);
Beispiel #35
0
        /// <summary>
        /// Get the sort kind from IntPtr
        /// </summary>
        public Z3_sort_kind GetSortKind(Z3_sort sort)
        {
            Debug.Assert(sort != IntPtr.Zero);

            return((Z3_sort_kind)Native.Z3_get_sort_kind(nCtx, sort));
        }
Beispiel #36
0
 public extern static Z3_ast Z3_mk_full_set(Z3_context a0, Z3_sort a1);
Beispiel #37
0
        /// <summary>
        /// Create a Term of a given sort. This function can be used to create numerals that fit in a machine integer.
        /// </summary>
        /// <param name="v">Value of the numeral</param>
        /// <param name="sort">Sort of the numeral</param>
        public Z3_ast MkNumeral(int v, Z3_sort sort)
        {
            Debug.Assert(sort != IntPtr.Zero);

            return(Native.Z3_mk_int(nCtx, v, sort));
        }
Beispiel #38
0
 public extern static Z3_sort Z3_get_relation_column(Z3_context a0, Z3_sort a1, uint a2);
Beispiel #39
0
        /// <summary>
        /// Create a Term of a given sort. This function can be used to create numerals that fit in a machine integer.
        /// </summary>
        /// <param name="v">Value of the numeral</param>
        /// <param name="sort">Sort of the numeral</param>
        public Z3_ast MkNumeral(long v, Z3_sort sort)
        {
            Debug.Assert(sort != null);

            return(Native.Z3_mk_int64(nCtx, v, sort));
        }
Beispiel #40
0
 public static Z3_ast Z3_mk_fpa_numeral_double(Z3_context a0, double a1, Z3_sort a2) {
     Z3_ast r = LIB.Z3_mk_fpa_numeral_double(a0, a1, a2);
     Z3_error_code err = (Z3_error_code)LIB.Z3_get_error_code(a0);
     if (err != Z3_error_code.Z3_OK)
         throw new Z3Exception(Marshal.PtrToStringAnsi(LIB.Z3_get_error_msg_ex(a0, (uint)err)));
     return r;
 }
Beispiel #41
0
 public extern static Z3_ast Z3_mk_unsigned_int(Z3_context a0, uint a1, Z3_sort a2);
Beispiel #42
0
 public static Z3_ast Z3_mk_fpa_numeral_int64_uint64(Z3_context a0, int a1, Int64 a2, UInt64 a3, Z3_sort a4) {
     Z3_ast r = LIB.Z3_mk_fpa_numeral_int64_uint64(a0, a1, a2, a3, a4);
     Z3_error_code err = (Z3_error_code)LIB.Z3_get_error_code(a0);
     if (err != Z3_error_code.Z3_OK)
         throw new Z3Exception(Marshal.PtrToStringAnsi(LIB.Z3_get_error_msg_ex(a0, (uint)err)));
     return r;
 }
Beispiel #43
0
        /// <summary>
        /// Creates a new bound variable.
        /// </summary>
        /// <param name="index">The de-Bruijn index of the variable</param>
        /// <param name="sort">The sort of the variable</param>
        public Z3_ast MkBound(uint index, Z3_sort sort)
        {
            Debug.Assert(sort != IntPtr.Zero);

            return(Native.Z3_mk_bound(nCtx, index, sort));
        }
Beispiel #44
0
 public static uint Z3_fpa_get_sbits(Z3_context a0, Z3_sort a1) {
     uint r = LIB.Z3_fpa_get_sbits(a0, a1);
     Z3_error_code err = (Z3_error_code)LIB.Z3_get_error_code(a0);
     if (err != Z3_error_code.Z3_OK)
         throw new Z3Exception(Marshal.PtrToStringAnsi(LIB.Z3_get_error_msg_ex(a0, (uint)err)));
     return r;
 }
Beispiel #45
0
 public extern static uint Z3_get_relation_arity(Z3_context a0, Z3_sort a1);
Beispiel #46
0
 public extern static IntPtr Z3_get_sort_name(Z3_context a0, Z3_sort a1);