internal ArraySort(Context ctx, Sort domain, Sort range)
     : base(ctx, Native.Z3_mk_array_sort(ctx.nCtx, domain.NativeObject, range.NativeObject))
 {
     Contract.Requires(ctx != null);
     Contract.Requires(domain != null);
     Contract.Requires(range != null);
 }
 /// <summary>
 /// Z3 expr to C# pretty printer
 /// </summary>
 public CSPrettyPrinter(Context z3)
 {
     this.charSort = z3.MkBitVecSort(16);
     this.tt = z3.MkBool(true);
     this.ff = z3.MkBool(false);
     this.encoding = 16;
 }
        public Automaton<Expr> getAutomata(Z3Provider z3p, Expr universe, Expr var, Sort sort)
        {   //Sort for pairs (input theory, BV)
            var bv = z3p.Z3.MkBitVecSort(BVConst.BVSIZE);
            var pairSort = z3p.MkTupleSort(sort, bv);

            var dfapair = this.Normalize().PushQuantifiers().getAutomata(z3p, new List<string>(), universe, var, sort);            

            //Compute the new moves by dropping the last bit of every element in the phiMoves
            var newMoves = Automaton<Expr>.Empty.GetMoves().ToList();
            foreach (var oldMove in dfapair.GetMoves())
            {
                var oldCond = oldMove.Label;                             

                //Compute the new condition as ()
                Expr newCond = oldCond;
                

                //Update the new set of moves
                newMoves.Add(new Move<Expr>(oldMove.SourceState, oldMove.TargetState, newCond));
            }

            //Build the new dfa with the new moves
            var automaton = Automaton<Expr>.Create(dfapair.InitialState, dfapair.GetFinalStates(), newMoves);

            return automaton.Determinize(z3p).Minimize(z3p);
        }
Example #4
0
        internal TupleSort(Context ctx, Symbol name, uint numFields, Symbol[] fieldNames, Sort[] fieldSorts)
            : base(ctx)
        {
            Contract.Requires(ctx != null);
            Contract.Requires(name != null);

            IntPtr t = IntPtr.Zero;
            NativeObject = Native.Z3_mk_tuple_sort(ctx.nCtx, name.NativeObject, numFields,
                                                   Symbol.ArrayToNative(fieldNames), AST.ArrayToNative(fieldSorts),
                                                   ref t, new IntPtr[numFields]);
        }
Example #5
0
        /// <summary>
        /// Create axiom: function f is injective in the i-th argument.
        /// </summary>
        /// <remarks>
        /// The following axiom is produced:
        /// <c>
        /// forall (x_0, ..., x_n) finv(f(x_0, ..., x_i, ..., x_{n-1})) = x_i
        /// </c>
        /// Where, <code>finv</code>is a fresh function declaration.
        /// </summary>
        public static BoolExpr InjAxiom(Context ctx, FuncDecl f, int i)
        {
            Sort[] domain = f.Domain;
            uint sz = f.DomainSize;

            if (i >= sz)
            {
                Console.WriteLine("failed to create inj axiom");
                return null;
            }

            /* declare the i-th inverse of f: finv */
            Sort finv_domain = f.Range;
            Sort finv_range = domain[i];
            FuncDecl finv = ctx.MkFuncDecl("f_fresh", finv_domain, finv_range);

            /* allocate temporary arrays */
            Expr[] xs = new Expr[sz];
            Symbol[] names = new Symbol[sz];
            Sort[] types = new Sort[sz];

            /* fill types, names and xs */

            for (uint j = 0; j < sz; j++)
            {
                types[j] = domain[j];
                names[j] = ctx.MkSymbol(String.Format("x_{0}", j));
                xs[j] = ctx.MkBound(j, types[j]);
            }
            Expr x_i = xs[i];

            /* create f(x_0, ..., x_i, ..., x_{n-1}) */
            Expr fxs = f[xs];

            /* create f_inv(f(x_0, ..., x_i, ..., x_{n-1})) */
            Expr finv_fxs = finv[fxs];

            /* create finv(f(x_0, ..., x_i, ..., x_{n-1})) = x_i */
            Expr eq = ctx.MkEq(finv_fxs, x_i);

            /* use f(x_0, ..., x_i, ..., x_{n-1}) as the pattern for the quantifier */
            Pattern p = ctx.MkPattern(new Expr[] { fxs });

            /* create & assert quantifier */
            BoolExpr q = ctx.MkForall(
                types, /* types of quantified variables */
                names, /* names of quantified variables */
                eq,
                1,
                new Pattern[] { p } /* patterns */);

            return q;
        }
Example #6
0
 /// <summary>
 /// Returns the Z3 term corresponding to the MSF rational number.
 /// </summary>
 /// <param name="rational">The MSF rational</param>
 /// <returns>The Z3 term</returns>
 public static ArithExpr GetNumeral(Context context, Rational rational, Sort sort = null)
 {
     try
     {
         sort = rational.IsInteger() ? ((Sort)context.IntSort) : (sort == null ? (Sort)context.RealSort : sort);
         return (ArithExpr)context.MkNumeral(rational.ToString(), sort);                
     }
     catch (Z3Exception e)
     {
         Console.Error.WriteLine("Conversion of {0} failed:\n {1}", rational, e);
         throw new NotSupportedException();
     }
 }
Example #7
0
        internal ListSort(Context ctx, Symbol name, Sort elemSort)
            : base(ctx)
        {
            Contract.Requires(ctx != null);
            Contract.Requires(name != null);
            Contract.Requires(elemSort != null);

            IntPtr inil = IntPtr.Zero, iisnil = IntPtr.Zero,
                   icons = IntPtr.Zero, iiscons = IntPtr.Zero,
                   ihead = IntPtr.Zero, itail = IntPtr.Zero;

            NativeObject = Native.Z3_mk_list_sort(ctx.nCtx, name.NativeObject, elemSort.NativeObject,
                                                  ref inil, ref iisnil, ref icons, ref iiscons, ref ihead, ref itail);
        }
        internal Quantifier(Context ctx, bool isForall, Sort[] sorts, Symbol[] names, Expr body,
            uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null,
            Symbol quantifierID = null, Symbol skolemID = null
            )
            : base(ctx)
        {
            Contract.Requires(ctx != null);
            Contract.Requires(sorts != null);
            Contract.Requires(names != null);
            Contract.Requires(body != null);
            Contract.Requires(sorts.Length == names.Length);
            Contract.Requires(Contract.ForAll(sorts, s => s != null));
            Contract.Requires(Contract.ForAll(names, n => n != null));
            Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null));
            Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null));

            Context.CheckContextMatch(patterns);
            Context.CheckContextMatch(noPatterns);
            Context.CheckContextMatch(sorts);
            Context.CheckContextMatch(names);
            Context.CheckContextMatch(body);

            if (sorts.Length != names.Length)
                throw new Z3Exception("Number of sorts does not match number of names");

            IntPtr[] _patterns = AST.ArrayToNative(patterns);

            if (noPatterns == null && quantifierID == null && skolemID == null)
            {
                NativeObject = Native.Z3_mk_quantifier(ctx.nCtx, (isForall) ? 1 : 0, weight,
                                           AST.ArrayLength(patterns),  AST.ArrayToNative(patterns),
                                           AST.ArrayLength(sorts), AST.ArrayToNative(sorts),
                                           Symbol.ArrayToNative(names),
                                           body.NativeObject);
            }
            else
            {
                NativeObject = Native.Z3_mk_quantifier_ex(ctx.nCtx, (isForall) ? 1 : 0, weight,
                                  AST.GetNativeObject(quantifierID), AST.GetNativeObject(skolemID),
                                  AST.ArrayLength(patterns), AST.ArrayToNative(patterns),
                                  AST.ArrayLength(noPatterns), AST.ArrayToNative(noPatterns),
                                  AST.ArrayLength(sorts), AST.ArrayToNative(sorts),
                                  Symbol.ArrayToNative(names),
                                  body.NativeObject);
            }
        }
        internal RankedAlphabet(
            TreeTheory tt,
            string[] symbols,
            Dictionary<string, int> idMap,
            Sort alphabetSort,
            Sort nodeSort,
            int[] ranks,
            FuncDecl[] constructors,
            FuncDecl[][] accessors,
            FuncDecl[] testers,
            FuncDecl acceptor,
            Expr[] vars
            )
        {
            this.tt = tt;
            this.symbols = new List<string>(symbols).AsReadOnly();
            this.idMap = idMap;
            this.alphabetSort = alphabetSort;
            this.nodeSort = nodeSort;
            this.ranks = ranks;
            this.constructors = constructors;
            this.accessors = accessors;
            this.testers = testers;
            this.acceptor = acceptor;
            this.vars = vars;
            this.trans = tt.GetTrans(alphabetSort, alphabetSort);
            this.emptyAcceptor = TreeTransducer.MkEmpty(this);
            this.fullAcceptor = TreeTransducer.MkFull(this);
            this.idAut = TreeTransducer.MkId(this);

            this.symbolsOfRank = new Dictionary<int, List<FuncDecl>>();
            for (int i = 0; i < ranks.Length; i++)
            {
                var r = ranks[i];
                if (!symbolsOfRank.ContainsKey(r))
                    symbolsOfRank[r] = new List<FuncDecl>();
                symbolsOfRank[r].Add(constructors[i]);
            }

            var attrDomain = tt.Z.MkFreshFuncDecl("_", new Sort[] { nodeSort }, tt.Z.BoolSort);
            this.attrExpr = tt.Z.MkApp(attrDomain, vars[0]);
            tt.Z.AssertAxiom(this.attrExpr, tt.Z.True, vars[0]);
        }
Example #10
0
 public UnrankedTreeInfo(Sort treeListSort, FuncDecl getNodeValue, FuncDecl getSubtrees, FuncDecl mkNode,
     FuncDecl mkLeaf, FuncDecl getLeafValue, FuncDecl isNode, FuncDecl isLeaf,
     Expr empty, FuncDecl first, FuncDecl rest,
     FuncDecl cons, FuncDecl isEmpty, FuncDecl isCons)
 {
     this.TreeListSort = treeListSort;
     this.GetNodeLabel = getNodeValue;
     this.GetNodeSubtrees = getSubtrees;
     this.MkNode = mkNode;
     this.EmptyTreeList = empty;
     this.GetFirst = first;
     this.GetRest = rest;
     this.MkCons = cons;
     this.IsEmpty = isEmpty;
     this.IsCons = isCons;
     this.MkLeaf = mkLeaf;
     this.GetLeafValue = getLeafValue;
     this.IsNode = isNode;
     this.IsLeaf = isLeaf;
 }
 public Const(ConstDef def, FastTransducerInstance fti, Z3Provider z3p)
 {
     this.z3p = z3p;
     this.name = def.id.text;
     switch (def.sort.kind)
     {
         case (FastSortKind.Real):
             {
                 sort = z3p.RealSort;
                 break;
             }
         case (FastSortKind.Bool):
             {
                 sort = z3p.BoolSort;
                 break;
             }
         case (FastSortKind.Int):
             {
                 sort = z3p.IntSort;
                 break;
             }
         case (FastSortKind.String):
             {
                 sort = z3p.MkListSort(z3p.CharSort);
                 break;
             }
         case (FastSortKind.Tree):
             {
                 foreach (var enumSort in fti.enums)
                 {
                     if (enumSort.name == def.sort.name.text)
                     {
                         sort = enumSort.sort;
                         break;
                     }
                 }
                 break;
             }
     }
     this.value = GenerateZ3ExprFromExpr(def.expr, fti).Simplify();
 }
        internal override Automaton<Expr> getAutomata(Z3Provider z3p, List<string> variables, Expr universe, Expr var, Sort sort)
        {            
            //var bit1 = z3p.Z3.MkInt2Bv(1,
            //        z3p.MkInt(1));
            var bit1 = z3p.Z3.MkInt2BV(BVConst.BVSIZE, (IntExpr)z3p.MkInt(1));

            //Sort for pairs (input theory, BV)
            var bv = z3p.Z3.MkBitVecSort(BVConst.BVSIZE);
            var pairSort = z3p.MkTupleSort(sort, bv);

            //Add the representation of the existential variable to the list of variables
            var newVariables = variables.ToArray().ToList();
            newVariables.Insert(0, variable);

            //Compute the DFA for the formula phi
            var phiDfa = phi.getAutomata(z3p, newVariables, universe, var, sort);

            //Compute the new moves by dropping the last bit of every element in the phiMoves
            var newMoves = Automaton<Expr>.Empty.GetMoves().ToList();
            foreach (var oldMove in phiDfa.GetMoves())
            {
                var oldCond = oldMove.Label;                               

                var t = z3p.MkProj(1,var);
                //Compute the new conditions
                var newCond0 = z3p.ApplySubstitution(oldCond, t,
                        z3p.Z3.MkBVSHL((BitVecExpr)t, (BitVecExpr)bit1));
                var newCond1 = z3p.ApplySubstitution(oldCond, t, 
                    z3p.MkBvAdd(
                        z3p.Z3.MkBVSHL((BitVecExpr)t, (BitVecExpr)bit1),
                        bit1));
                
                //Update the new set of moves
                newMoves.Add(new Move<Expr>(oldMove.SourceState, oldMove.TargetState, z3p.MkOr(z3p.Simplify(newCond0),z3p.Simplify(newCond1))));
            }

            //Build the new dfa with the new moves
            return Automaton<Expr>.Create(phiDfa.InitialState, phiDfa.GetFinalStates(), newMoves);
                //.Determinize(z3p).MinimizeClassical(z3p, int.MaxValue,false);            
        }
        internal Constructor(Context ctx, Symbol name, Symbol recognizer, Symbol[] fieldNames,
            Sort[] sorts, uint[] sortRefs)
            : base(ctx)
        {
            Contract.Requires(ctx != null);
            Contract.Requires(name != null);
            Contract.Requires(recognizer != null);

            n = AST.ArrayLength(fieldNames);

            if (n != AST.ArrayLength(sorts))
                throw new Z3Exception("Number of field names does not match number of sorts");
            if (sortRefs != null && sortRefs.Length != n)
                throw new Z3Exception("Number of field names does not match number of sort refs");

            if (sortRefs == null) sortRefs = new uint[n];

            NativeObject = Native.Z3_mk_constructor(ctx.nCtx, name.NativeObject, recognizer.NativeObject,
                                                    n,
                                                    Symbol.ArrayToNative(fieldNames),
                                                    Sort.ArrayToNative(sorts),
                                                    sortRefs);
        }
Example #14
0
        /// <summary>
        /// Create a new list sort.
        /// </summary>
        public ListSort MkListSort(string name, Sort elemSort)
        {
            Contract.Requires(elemSort != null);
            Contract.Ensures(Contract.Result<ListSort>() != null);

            CheckContextMatch(elemSort);
            return new ListSort(this, MkSymbol(name), elemSort);
        }
Example #15
0
        /// <summary>
        /// Creates a new function declaration.
        /// </summary>
        public FuncDecl MkFuncDecl(string name, Sort domain, Sort range)
        {
            Contract.Requires(range != null);
            Contract.Requires(domain != null);
            Contract.Ensures(Contract.Result<FuncDecl>() != null);

            CheckContextMatch(domain);
            CheckContextMatch(range);
            Sort[] q = new Sort[] { domain };
            return new FuncDecl(this, MkSymbol(name), q, range);
        }
Example #16
0
        /// <summary>
        /// Creates a new function declaration.
        /// </summary>
        public FuncDecl MkFuncDecl(string name, Sort[] domain, Sort range)
        {
            Contract.Requires(range != null);
            Contract.Requires(Contract.ForAll(domain, d => d != null));
            Contract.Ensures(Contract.Result<FuncDecl>() != null);

            CheckContextMatch(domain);
            CheckContextMatch(range);
            return new FuncDecl(this, MkSymbol(name), domain, range);
        }
Example #17
0
        /// <summary>
        /// Create the full set.
        /// </summary>
        public Expr MkFullSet(Sort domain)
        {
            Contract.Requires(domain != null);
            Contract.Ensures(Contract.Result<Expr>() != null);

            CheckContextMatch(domain);
            return Expr.Create(this, Native.Z3_mk_full_set(nCtx, domain.NativeObject));
        }
Example #18
0
        /// <summary>
        /// Creates a fresh constant function declaration with a name prefixed with <paramref name="prefix"/>.
        /// </summary>
        /// <seealso cref="MkFuncDecl(string,Sort,Sort)"/>
        /// <seealso cref="MkFuncDecl(string,Sort[],Sort)"/>
        public FuncDecl MkFreshConstDecl(string prefix, Sort range)
        {
            Contract.Requires(range != null);
            Contract.Ensures(Contract.Result<FuncDecl>() != null);

            CheckContextMatch(range);
            return new FuncDecl(this, prefix, null, range);
        }
Example #19
0
 internal FuncDecl(Context ctx, string prefix, Sort[] domain, Sort range)
     : base(ctx, Native.Z3_mk_fresh_func_decl(ctx.nCtx, prefix, AST.ArrayLength(domain), AST.ArrayToNative(domain), range.NativeObject))
 {
     Contract.Requires(ctx != null);
     Contract.Requires(range != null);
 }
Example #20
0
        /// <summary>
        /// Creates a new bound variable.
        /// </summary>
        /// <param name="index">The de-Bruijn index of the variable</param>
        /// <param name="ty">The sort of the variable</param>
        public Expr MkBound(uint index, Sort ty)
        {
            Contract.Requires(ty != null);
            Contract.Ensures(Contract.Result<Expr>() != null);

            return Expr.Create(this, Native.Z3_mk_bound(nCtx, index, ty.NativeObject));
        }
Example #21
0
        /// <summary>
        /// Create a set type.
        /// </summary>
        public SetSort MkSetSort(Sort ty)
        {
            Contract.Requires(ty != null);
            Contract.Ensures(Contract.Result<SetSort>() != null);

            CheckContextMatch(ty);
            return new SetSort(this, ty);
        }
Example #22
0
        /// <summary>
        /// Create a Term of a given sort. This function can be use to create numerals that fit in a machine integer.
        /// It is slightly faster than <c>MakeNumeral</c> since it is not necessary to parse a string.       
        /// </summary>
        /// <param name="v">Value of the numeral</param>
        /// <param name="ty">Sort of the numeral</param>
        /// <returns>A Term with value <paramref name="v"/> and type <paramref name="ty"/></returns>
        public Expr MkNumeral(ulong v, Sort ty)
        {
            Contract.Requires(ty != null);
            Contract.Ensures(Contract.Result<Expr>() != null);

            CheckContextMatch(ty);
            return Expr.Create(this, Native.Z3_mk_unsigned_int64(nCtx, v, ty.NativeObject));
        }
Example #23
0
        /// <summary>
        /// Create a Quantifier.
        /// </summary>
        public Quantifier MkQuantifier(bool universal, Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null)
        {
            Contract.Requires(body != null);
            Contract.Requires(names != null);
            Contract.Requires(sorts != null);
            Contract.Requires(sorts.Length == names.Length);
            Contract.Requires(Contract.ForAll(sorts, s => s != null));
            Contract.Requires(Contract.ForAll(names, n => n != null));
            Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null));
            Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null));

            Contract.Ensures(Contract.Result<Quantifier>() != null);

            if (universal)
                return MkForall(sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
            else
                return MkExists(sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
        }
Example #24
0
        /// <summary>
        /// Parse the given string using the SMT-LIB2 parser. 
        /// </summary>
        /// <seealso cref="ParseSMTLIBString"/>
        /// <returns>A conjunction of assertions in the scope (up to push/pop) at the end of the string.</returns>
        public BoolExpr ParseSMTLIB2String(string str, Symbol[] sortNames = null, Sort[] sorts = null, Symbol[] declNames = null, FuncDecl[] decls = null)
        {
            Contract.Ensures(Contract.Result<BoolExpr>() != null);

            uint csn = Symbol.ArrayLength(sortNames);
            uint cs = Sort.ArrayLength(sorts);
            uint cdn = Symbol.ArrayLength(declNames);
            uint cd = AST.ArrayLength(decls);
            if (csn != cs || cdn != cd)
                throw new Z3Exception("Argument size mismatch");
            return (BoolExpr)Expr.Create(this, Native.Z3_parse_smtlib2_string(nCtx, str,
                AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts),
                AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls)));
        }
Example #25
0
        /// <summary>
        /// Create a new tuple sort.
        /// </summary>    
        public TupleSort MkTupleSort(Symbol name, Symbol[] fieldNames, Sort[] fieldSorts)
        {
            Contract.Requires(name != null);
            Contract.Requires(fieldNames != null);
            Contract.Requires(Contract.ForAll(fieldNames, fn => fn != null));
            Contract.Requires(fieldSorts == null || Contract.ForAll(fieldSorts, fs => fs != null));
            Contract.Ensures(Contract.Result<TupleSort>() != null);

            CheckContextMatch(name);
            CheckContextMatch(fieldNames);
            CheckContextMatch(fieldSorts);
            return new TupleSort(this, name, (uint)fieldNames.Length, fieldNames, fieldSorts);
        }
Example #26
0
        /// <summary>
        /// Create an array constant.
        /// </summary>        
        public ArrayExpr MkArrayConst(string name, Sort domain, Sort range)
        {
            Contract.Requires(domain != null);
            Contract.Requires(range != null);
            Contract.Ensures(Contract.Result<ArrayExpr>() != null);

            return (ArrayExpr)MkConst(MkSymbol(name), MkArraySort(domain, range));
        }
Example #27
0
 /// <summary>
 /// Parse the given string using the SMT-LIB parser. 
 /// </summary>
 /// <remarks>
 /// The symbol table of the parser can be initialized using the given sorts and declarations. 
 /// The symbols in the arrays <paramref name="sortNames"/> and <paramref name="declNames"/> 
 /// don't need to match the names of the sorts and declarations in the arrays <paramref name="sorts"/> 
 /// and <paramref name="decls"/>. This is a useful feature since we can use arbitrary names to 
 /// reference sorts and declarations.
 /// </remarks>
 public void ParseSMTLIBString(string str, Symbol[] sortNames = null, Sort[] sorts = null, Symbol[] declNames = null, FuncDecl[] decls = null)
 {
     uint csn = Symbol.ArrayLength(sortNames);
     uint cs = Sort.ArrayLength(sorts);
     uint cdn = Symbol.ArrayLength(declNames);
     uint cd = AST.ArrayLength(decls);
     if (csn != cs || cdn != cd)
         throw new Z3Exception("Argument size mismatch");
     Native.Z3_parse_smtlib_string(nCtx, str,
         AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts),
         AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls));
 }
Example #28
0
        /// <summary>
        /// Create a datatype constructor.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="recognizer"></param>
        /// <param name="fieldNames"></param>
        /// <param name="sorts"></param>
        /// <param name="sortRefs"></param>
        /// <returns></returns>
        public Constructor MkConstructor(string name, string recognizer, string[] fieldNames = null, Sort[] sorts = null, uint[] sortRefs = null)
        {
            Contract.Ensures(Contract.Result<Constructor>() != null);

            return new Constructor(this, MkSymbol(name), MkSymbol(recognizer), MkSymbols(fieldNames), sorts, sortRefs);
        }
Example #29
0
        /// <summary>
        /// Create a new array sort.
        /// </summary>
        public ArraySort MkArraySort(Sort domain, Sort range)
        {
            Contract.Requires(domain != null);
            Contract.Requires(range != null);
            Contract.Ensures(Contract.Result<ArraySort>() != null);

            CheckContextMatch(domain);
            CheckContextMatch(range);
            return new ArraySort(this, domain, range);
        }
Example #30
0
        /// <summary>
        /// Creates a fresh Constant of sort <paramref name="range"/> and a 
        /// name prefixed with <paramref name="prefix"/>.
        /// </summary>
        public Expr MkFreshConst(string prefix, Sort range)
        {
            Contract.Requires(range != null);
            Contract.Ensures(Contract.Result<Expr>() != null);

            CheckContextMatch(range);
            return Expr.Create(this, Native.Z3_mk_fresh_const(nCtx, prefix, range.NativeObject));
        }
Example #31
0
        /// <summary>
        /// The finite set of distinct values that represent the interpretation for sort <paramref name="s"/>.
        /// </summary>
        /// <seealso cref="Sorts"/>
        /// <param name="s">An uninterpreted sort</param>
        /// <returns>An array of expressions, where each is an element of the universe of <paramref name="s"/></returns>
        public Expr[] SortUniverse(Sort s)
        {
            Contract.Requires(s != null);
            Contract.Ensures(Contract.Result<Expr[]>() != null);

            ASTVector nUniv = new ASTVector(Context, Native.Z3_model_get_sort_universe(Context.nCtx, NativeObject, s.NativeObject));
            uint n = nUniv.Size;
            Expr[] res = new Expr[n];
            for (uint i = 0; i < n; i++)
                res[i] = Expr.Create(Context, nUniv[i].NativeObject);
            return res;
        }
Example #32
0
 internal Parameter(Z3_parameter_kind k, Sort s)
 {
     this.kind = k;
     this.srt  = s;
 }