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


C# Z3Provider.MkGt方法代码示例

本文整理汇总了C#中Z3Provider.MkGt方法的典型用法代码示例。如果您正苦于以下问题:C# Z3Provider.MkGt方法的具体用法?C# Z3Provider.MkGt怎么用?C# Z3Provider.MkGt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Z3Provider的用法示例。


在下文中一共展示了Z3Provider.MkGt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestComposition1

        public void TestComposition1()
        {
            Z3Provider Z = new Z3Provider();
            var A = (Z.TT.MkRankedAlphabet("A", Z.IntSort, new string[] { "zeroA", "oneA", "twoA" }, new int[] { 0, 1, 2 }));
            var B = (Z.TT.MkRankedAlphabet("B", Z.IntSort, new string[] { "zeroB", "oneB", "twoB" }, new int[] { 0, 1, 2 }));
            var C = (Z.TT.MkRankedAlphabet("C", Z.IntSort, new string[] { "zeroC", "oneC", "twoC" }, new int[] { 0, 1, 2 }));

            //(two (plus 1 x0) (one (plus 1 x0) (q x1)) (one (plus 2 x0) (q x2)))
            var b = Z.MkApp(B["twoB"],
                        Z.MkAdd(Z.MkInt(1), A.AttrVar),
                        B.MkTree("oneB", Z.MkAdd(Z.MkInt(1), A.AttrVar), A.MkTrans(B, 0, 1)),
                        B.MkTree("oneB", Z.MkAdd(Z.MkInt(2), A.AttrVar), A.MkTrans(B, 0, 2)));

            //(two (plus 1 x0) (zero x0) (one (plus 100 x0) (q x2)))
            var b2 = Z.MkApp(B["twoB"],
                        Z.MkAdd(Z.MkInt(1), A.AttrVar),
                        B.MkTree("zeroB", A.AttrVar),
                        B.MkTree("oneB", Z.MkAdd(Z.MkInt(9), A.AttrVar), A.MkTrans(B, 0, 2)));

            var rule0 = Z.TT.MkTreeRule(A, B, 0, "zeroA", Z.True, B.MkTree("zeroB", A.AttrVar));
            var rule1 = Z.TT.MkTreeRule(A, B, 0, "twoA", Z.MkGt(A.AttrVar, Z.MkInt(0)), b);
            var rule2 = Z.TT.MkTreeRule(A, B, 0, "twoA", Z.MkGt(A.AttrVar, Z.MkInt(0)), b2);
            var rule3 = Z.TT.MkTreeRule(A, B, 0, "oneA", Z.MkGt(A.AttrVar, Z.MkInt(0)), B.MkTree("oneB", A.AttrVar, A.MkTrans(B, 0, 1)));

            var trans1 = Z.TT.MkTreeAutomaton(0, A, B, new TreeRule[] { rule0, rule1, rule2, rule3 });

            //(two x0 (one (plus 1 x0) (p x1)) (one (plus 2 x0) (p x2)))
            var a = A.MkTree("twoA", C.AttrVar,
             A.MkTree("oneA", Z.MkAdd(Z.MkInt(1), C.AttrVar), C.MkTrans(A, 1, 1)),
             A.MkTree("oneA", Z.MkAdd(Z.MkInt(2), C.AttrVar), C.MkTrans(A, 1, 2)));

            var a2 = A.MkTree("zeroA", C.AttrVar);

            var rule4 = Z.TT.MkTreeRule(C, A, 1, "twoC", Z.MkGt(C.AttrVar, Z.MkInt(-2)), a);
            var rule5 = Z.TT.MkTreeRule(C, A, 1, "zeroC", Z.MkGt(C.AttrVar, Z.MkInt(-3)), a2);

            var trans2 = Z.TT.MkTreeAutomaton(1, C, A, new TreeRule[] { rule4, rule5 });

            var trans12 = trans2.Compose(trans1);

            var rulesOut = trans12.GetRules(trans12.Root, C["twoC"]);
            Assert.AreEqual<int>(2, rulesOut.Count);

            var rulesOut2 = trans12.GetRules(trans12.Root, C["zeroC"]);
            Assert.AreEqual<int>(1, rulesOut2.Count);

            var tin = C.MkTree("twoC", Z.MkInt(55), C.MkTree("zeroC", Z.MkInt(66)), C.MkTree("zeroC", Z.MkInt(77)));
            var res = trans12[tin];
            Assert.AreEqual<int>(2, res.Length);
            Assert.AreEqual<int>(3, trans12.RuleCount);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:51,代码来源:TreeTransducerTests.cs

示例2: SolverTest

 public void SolverTest()
 {
     var z3c = new Z3Provider();
     var z3s = z3c.MkSolver();
     var phi = z3c.MkLe(z3c.MkVar(0, z3c.IntSort), z3c.MkVar(1, z3c.IntSort));
     var psi = z3c.MkGt(z3c.MkVar(0, z3c.IntSort), z3c.MkVar(2, z3c.IntSort));
     var eq = z3c.MkEq(z3c.MkVar(1, z3c.IntSort), z3c.MkVar(2, z3c.IntSort));
     z3s.Push();
     z3s.Assert(phi);
     z3s.Assert(psi);
     z3s.Push();
     z3s.Assert(eq);
     var isSat1 = z3s.Check();
     z3s.Pop();
     var isSat2 = z3s.Check();
     z3s.Pop();
     Assert.IsFalse(isSat1);
     Assert.IsTrue(isSat2);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:19,代码来源:UnitTest1.cs


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