繁体   English   中英

Visual Studio 2012中的C#Z3 API调用问题

[英]C# Z3 API calling problems in Visual studio 2012

在Visual Studio 2012中导入Z3之后,当我尝试在Visual Studio 2012中运行示例时,我发现Visual Studio无法找到Microsoft.Z3包,在尝试再次导入后它可以找到Microsoft.Z3,但是仍然找不到Config关键字,任何一天都能帮我吗? 或为我提供在Visual Studio 2012中使用Z3的详细方法? 我按照以下步骤操作,出现了上述问题。

要在您的C#项目中使用Microsoft Z3库,请按照下列步骤操作:

Go to http://research.microsoft.com/en-us/downloads/0a7db466-c2d7-4c51-8246-07e25900c7e7/ and download + install the Z3 package.

Switch to Visual Studio. In the Solution Explorer window right click on the References tree node and select "Add Reference".
In the "Add new reference" dialog navigate to the Microsoft.Z3.dll. You find the Microsoft.Z3.dll under c:\Program Files (x86)\Microsoft Research\Z3-3.2\bin on a Windows x64 bit machine or under c:\Program Files\Microsoft Research\Z3-3.2\bin on a Windows x86 machine. To use Parallel Z3 library choose the Microsoft.Z3.dll from the c:\Program Files (x86)\Microsoft Research\Z3-3.2\bin_mt or c:\Program Files\Microsoft Research\Z3-3.2\bin_mt directory.

我的代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Z3;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            using (Config cfg = new Config())
            {
                using (Context ctx = new Context(cfg))
                {
                    Term x = ctx.MkConst("x", ctx.MkIntSort());
                    Term y = ctx.MkConst("y", ctx.MkIntSort());
                    Term zero = ctx.MkConst(0, ctx.MkIntSort());
                    Term one = ctx.MkConst(1, ctx.MkIntSort());
                    Term three = ctx.MkConst(3, ctx.MkIntSort());
                    Term fml = x > zero & ctx.MkEq(y, x + one) & y < three;
                    ctx.AssertCnstr(fml);
                    Model m = null;
                    LBool is_sat = ctx.CheckAndModel(out m);
                    System.Console.WriteLine(is_sat);

                    if (m != null)
                    {
                        m.Display(Console.Out);
                        m.Dispose();
                    }

                }

            }
        }
    }
}

您似乎正在使用Z3(3.2)的一个非常过时的版本,最新的主要发行版是4.3.x,请按照此处的生成说明创建库(不稳定的分支可能是最佳选择):

http://z3.codeplex.com/SourceControl/latest#README

然后确保将库添加到解决方案/项目中的引用路径(这听起来像您尝试使用旧库),然后可以检查此示例以查看如何调用API:

http://z3.codeplex.com/SourceControl/latest#examples/dotnet/Program.cs

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM