• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Z3.Expr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Check

        /// <summary>
        /// Checks whether the assertions in the context are consistent or not.
        /// </summary>
        public static Status Check(Context ctx, List<BoolExpr> core, ref Model model, ref Expr proof, params Expr[] assumptions)
        {
            Z3_lbool r;
            model = null;
            proof = null;
            if (assumptions == null || assumptions.Length == 0)
                r = (Z3_lbool)Native.Z3_check(ctx.nCtx);
            else {
                IntPtr mdl = IntPtr.Zero, prf = IntPtr.Zero;
                uint core_size = 0;
                IntPtr[] native_core = new IntPtr[assumptions.Length];
                r = (Z3_lbool)Native.Z3_check_assumptions(ctx.nCtx, 
                                   (uint)assumptions.Length, AST.ArrayToNative(assumptions),
                                   ref mdl, ref prf, ref core_size, native_core);

                for (uint i = 0; i < core_size; i++)
                    core.Add((BoolExpr)Expr.Create(ctx, native_core[i]));
                if (mdl != IntPtr.Zero) {
                    model = new Model(ctx, mdl);
                }
                if (prf != IntPtr.Zero) {
                    proof = Expr.Create(ctx, prf);
                }

            }
            switch (r)
            {
                case Z3_lbool.Z3_L_TRUE: return Status.SATISFIABLE;
                case Z3_lbool.Z3_L_FALSE: return Status.UNSATISFIABLE;
                default: return Status.UNKNOWN;
            }
        }
开发者ID:killbug2004,项目名称:Snippets,代码行数:35,代码来源:Deprecated.cs


示例2: AcceptorBase

 internal AcceptorBase(FuncDecl symbol, Expr guard, ExprSet[] lookahead)
 {
     this.symbol = symbol;
     this.guard = guard;
     this.lookahead = lookahead;
     this.lhs = new Pair<FuncDecl, Sequence<ExprSet>>(symbol, new Sequence<ExprSet>(lookahead));
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:7,代码来源:TreeRule.cs


示例3: DescribeExpr

 //bool CSmode = false;
 /// <summary>
 /// Returns a pretty printed view of the given term.
 /// </summary>
 /// <param name="term">the given term</param>
 /// <param name="lookupVarName">lookup function for variable names</param>
 public string DescribeExpr(Expr term, Func<Expr, string> lookupVarName)
 {
     __lookupVarName = lookupVarName;
     var str = DescribeExpr(term);
     __lookupVarName = null;
     return str;
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:13,代码来源:TermPrettyPrinter.cs


示例4: ConstInterp

        /// <summary>
        /// Retrieves the interpretation (the assignment) of <paramref name="a"/> in the model. 
        /// </summary>
        /// <param name="a">A Constant</param>
        /// <returns>An expression if the constant has an interpretation in the model, null otherwise.</returns>
        public Expr ConstInterp(Expr a)
        {
            Contract.Requires(a != null);

            Context.CheckContextMatch(a);
            return ConstInterp(a.FuncDecl);
        }
开发者ID:abhishekudupa,项目名称:z3-4.3.1,代码行数:12,代码来源:Model.cs


示例5: 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


示例6: Quantifier

        internal Quantifier(Context ctx, bool isForall, Expr[] bound, 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(body != null);

            Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null));
            Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null));
            Contract.Requires(bound == null || Contract.ForAll(bound, n => n != null));

            Context.CheckContextMatch(noPatterns);
            Context.CheckContextMatch(patterns);
            //Context.CheckContextMatch(bound);
            Context.CheckContextMatch(body);

            if (noPatterns == null && quantifierID == null && skolemID == null)
            {
                NativeObject = Native.Z3_mk_quantifier_const(ctx.nCtx, (isForall) ? 1 : 0, weight,
                                                 AST.ArrayLength(bound), AST.ArrayToNative(bound),
                                                 AST.ArrayLength(patterns), AST.ArrayToNative(patterns),
                                                 body.NativeObject);
            }
            else
            {
                NativeObject = Native.Z3_mk_quantifier_const_ex(ctx.nCtx, (isForall) ? 1 : 0, weight,
                                        AST.GetNativeObject(quantifierID), AST.GetNativeObject(skolemID),
                                        AST.ArrayLength(bound), AST.ArrayToNative(bound),
                                        AST.ArrayLength(patterns), AST.ArrayToNative(patterns),
                                        AST.ArrayLength(noPatterns), AST.ArrayToNative(noPatterns),
                                        body.NativeObject);
            }
        }
开发者ID:sslab-gatech,项目名称:juxta,代码行数:32,代码来源:Quantifier.cs


示例7: DescribeExprCS

 /// <summary>
 /// Returns a pretty printed view of the given term. Uses C# compliant expression notation.
 /// </summary>
 /// <param name="term">the given term</param>
 /// <param name="lookupVarName">lookup function for variable names</param>
 public string DescribeExprCS(Expr term, Func<Expr, string> lookupVarName)
 {
     //CSmode = true;
     __lookupVarName = lookupVarName;
     var str = DescribeExpr(term);
     __lookupVarName = null;
     //CSmode = false;
     return str;
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:14,代码来源:TermPrettyPrinter.cs


示例8: 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


示例9: GetInterpolant

        /// <summary> 
        /// Computes an interpolant.
        /// </summary>    
        /// <remarks>For more information on interpolation please refer
        /// too the function Z3_get_interpolant in the C/C++ API, which is 
        /// well documented.</remarks>
        public BoolExpr[] GetInterpolant(Expr pf, Expr pat, Params p)
        {
            Contract.Requires(pf != null);
            Contract.Requires(pat != null);
            Contract.Requires(p != null);
            Contract.Ensures(Contract.Result<Expr>() != null);

            CheckContextMatch(pf);
            CheckContextMatch(pat);
            CheckContextMatch(p);

            ASTVector seq = new ASTVector(this, Native.Z3_get_interpolant(nCtx, pf.NativeObject, pat.NativeObject, p.NativeObject));
            return seq.ToBoolExprArray();
        }
开发者ID:perillaseed,项目名称:z3,代码行数:20,代码来源:InterpolationContext.cs


示例10: ComputeInterpolant

        /// <summary> 
        /// Computes an interpolant.
        /// </summary>    
        /// <remarks>For more information on interpolation please refer
        /// too the function Z3_compute_interpolant in the C/C++ API, which is 
        /// well documented.</remarks>
        public Z3_lbool ComputeInterpolant(Expr pat, Params p, out BoolExpr[] interp, out Model model)
        {
            Contract.Requires(pat != null);
            Contract.Requires(p != null);
            Contract.Ensures(Contract.ValueAtReturn(out interp) != null);
            Contract.Ensures(Contract.ValueAtReturn(out model) != null);

            CheckContextMatch(pat);
            CheckContextMatch(p);

            IntPtr i = IntPtr.Zero, m = IntPtr.Zero;
            int r = Native.Z3_compute_interpolant(nCtx, pat.NativeObject, p.NativeObject, ref i, ref m);
            interp = new ASTVector(this, i).ToBoolExprArray();
            model = new Model(this, m);
            return (Z3_lbool)r;
        }
开发者ID:perillaseed,项目名称:z3,代码行数:22,代码来源:InterpolationContext.cs


示例11: CheckInterpolant

 /// <summary> 
 /// Checks the correctness of an interpolant.
 /// </summary>    
 /// <remarks>For more information on interpolation please refer
 /// too the function Z3_check_interpolant in the C/C++ API, which is 
 /// well documented.</remarks>
 public int CheckInterpolant(Expr[] cnsts, uint[] parents, BoolExpr[] interps, out string error, Expr[] theory)
 {
     Contract.Requires(cnsts.Length == parents.Length);
     Contract.Requires(cnsts.Length == interps.Length + 1);
     IntPtr n_err_str;
     int r = Native.Z3_check_interpolant(nCtx,
                                         (uint)cnsts.Length,
                                         Expr.ArrayToNative(cnsts),
                                         parents,
                                         Expr.ArrayToNative(interps),
                                         out n_err_str,
                                         (uint)theory.Length,
                                         Expr.ArrayToNative(theory));
     error = Marshal.PtrToStringAnsi(n_err_str);
     return r;
 }
开发者ID:jawline,项目名称:z3,代码行数:22,代码来源:InterpolationContext.cs


示例12: 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


示例13: GetInterpolant

        /// <summary> 
        /// Computes an interpolant.
        /// </summary>    
        /// <remarks>For more information on interpolation please refer
        /// too the function Z3_get_interpolant in the C/C++ API, which is 
        /// well documented.</remarks>
        Expr[] GetInterpolant(Expr pf, Expr pat, Params p)
        {
            Contract.Requires(pf != null);
            Contract.Requires(pat != null);
            Contract.Requires(p != null);
            Contract.Ensures(Contract.Result<Expr>() != null);

            CheckContextMatch(pf);
            CheckContextMatch(pat);
            CheckContextMatch(p);

            ASTVector seq = new ASTVector(this, Native.Z3_get_interpolant(nCtx, pf.NativeObject, pat.NativeObject, p.NativeObject));
            uint n = seq.Size;
            Expr[] res = new Expr[n];
            for (uint i = 0; i < n; i++)
                res[i] = Expr.Create(this, seq[i].NativeObject);
            return res;
        }
开发者ID:abhishekudupa,项目名称:z3-4.3.2,代码行数:24,代码来源:InterpolationContext.cs


示例14: 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


示例15: GetNumeralUInt

 public uint GetNumeralUInt(Expr t)
 {
     var ts = t.Sort;
     if (t is IntNum)
         return ((IntNum)t).UInt;
     if (t is BitVecNum)
         return ((BitVecNum)t).UInt;
     //avoiding z3 bug: (GetSort(t) is TupleSort) == false even when t is a tuple
     if ((t.Sort.Name.ToString().StartsWith("$")) && (GetTupleLength(t.Sort) == 1))
     {
         var v = t.Args[0];
         if (v is IntNum)
             return ((IntNum)v).UInt;
         if (v is BitVecNum)
             return ((BitVecNum)v).UInt;
         throw new Exception();
     }
     throw new Exception();
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:19,代码来源:TermPrettyPrinter.cs


示例16: 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


示例17: 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


示例18: SortUniverse

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


示例19: Evaluate

        /// <summary>
        /// Alias for <c>Eval</c>.
        /// </summary>        
        public Expr Evaluate(Expr t, bool completion = false)
        {
            Contract.Requires(t != null);
            Contract.Ensures(Contract.Result<Expr>() != null);

            return Eval(t, completion);
        }
开发者ID:MavenRain,项目名称:z3,代码行数:10,代码来源:Model.cs


示例20: Eval

        /// <summary>
        /// Evaluates the expression <paramref name="t"/> in the current model.
        /// </summary>
        /// <remarks>
        /// This function may fail if <paramref name="t"/> contains quantifiers, 
        /// is partial (MODEL_PARTIAL enabled), or if <paramref name="t"/> is not well-sorted.
        /// In this case a <c>ModelEvaluationFailedException</c> is thrown.
        /// </remarks>
        /// <param name="t">An expression</param>
        /// <param name="completion">
        /// When this flag is enabled, a model value will be assigned to any constant 
        /// or function that does not have an interpretation in the model.
        /// </param>
        /// <returns>The evaluation of <paramref name="t"/> in the model.</returns>        
        public Expr Eval(Expr t, bool completion = false)
        {
            Contract.Requires(t != null);
            Contract.Ensures(Contract.Result<Expr>() != null);

            IntPtr v = IntPtr.Zero;
            if (Native.Z3_model_eval(Context.nCtx, NativeObject, t.NativeObject, (completion) ? 1 : 0, ref v) == 0)
                throw new ModelEvaluationFailedException();
            else
                return Expr.Create(Context, v);
        }
开发者ID:MavenRain,项目名称:z3,代码行数:25,代码来源:Model.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Z3.FPExpr类代码示例发布时间:2022-05-26
下一篇:
C# Z3.Context类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap