当前位置: 首页>>代码示例>>C#>>正文


C# Z3.Sort类代码示例

本文整理汇总了C#中Microsoft.Z3.Sort的典型用法代码示例。如果您正苦于以下问题:C# Sort类的具体用法?C# Sort怎么用?C# Sort使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Sort类属于Microsoft.Z3命名空间,在下文中一共展示了Sort类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getAutomata

        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);
        }
开发者ID:AutomataTutor,项目名称:automatatutor-backend,代码行数:26,代码来源:WS1SZ3.cs

示例2: ArraySort

 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);
 }
开发者ID:annachen368,项目名称:HadoopStreamingTester,代码行数:7,代码来源:Sort.cs

示例3: CSPrettyPrinter

 /// <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;
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:10,代码来源:TermPrettyPrinter.cs

示例4: TupleSort

        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]);
        }
开发者ID:kayceesrk,项目名称:Z3,代码行数:11,代码来源:TupleSort.cs

示例5: InjAxiom

        /// <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;
        }
开发者ID:perillaseed,项目名称:z3,代码行数:63,代码来源:Program.cs

示例6: GetNumeral

 /// <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();
     }
 }
开发者ID:perillaseed,项目名称:z3,代码行数:18,代码来源:Utils.cs

示例7: ListSort

        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);
        }
开发者ID:sslab-gatech,项目名称:juxta,代码行数:14,代码来源:ListSort.cs

示例8: Quantifier

        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);
            }
        }
开发者ID:annachen368,项目名称:HadoopStreamingTester,代码行数:46,代码来源:Quantifier.cs

示例9: RankedAlphabet

        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]);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:43,代码来源:RankedAlphabet.cs

示例10: UnrankedTreeInfo

 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;
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:20,代码来源:TreeInfo.cs

示例11: Const

 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();
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:41,代码来源:TransducersGenerator.cs

示例12: Constructor

        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);
        }
开发者ID:annachen368,项目名称:HadoopStreamingTester,代码行数:23,代码来源:Constructor.cs

示例13: MkTupleSort

        /// <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);
        }
开发者ID:kayceesrk,项目名称:Z3,代码行数:16,代码来源:Context.cs

示例14: MkSetSort

        /// <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);
        }
开发者ID:kayceesrk,项目名称:Z3,代码行数:11,代码来源:Context.cs

示例15: MkQuantifier

        /// <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);
        }
开发者ID:kayceesrk,项目名称:Z3,代码行数:21,代码来源:Context.cs


注:本文中的Microsoft.Z3.Sort类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。