如何使用.NET API中的Z3使用琳,量词?量词、如何使用、API、NET

2023-09-04 04:07:49 作者:旧友终离

我找不到.NET API为(琳-量词(存在((X智力))(和(小于T1 X)(其中,X T2))))是一种战术?可能有人帮助我使用Z3的.NET API来实现以下脚本?

 (声明const的T1智力)
(声明const的T2智力)

(琳-量词(存在((X智力))(和(小于t1的x)的(小于,X t2的))))
 

解决方案

是的,你可以使用的一种战术。下面是使用.NET API的例子(我没有跑这个特殊的例子,因此它可能需要一些小的修改,但我用大约在我的节目一样的)。

  //(存在((X智力))(和(小于T1 X)(其中,X T2))))
上下文Z3 =新的上下文();
Expr的T1 = z3.MkIntConst(T1);
Expr的T2 = z3.MkIntConst(T2);
Expr的X = z3.MkIntConst(×);

EXPR P = z3.MkAnd(z3.MkLt((ArithExpr)T1,(ArithExpr)X),z3.MkLt((ArithExpr)X,(ArithExpr)T2));
EXPR恩= z3.MkExists(新EXPR [] {X},P);

目标G = z3.MkGoal(真,真,假);
g.Assert((BoolExpr)前);
战术TAC = Instance.Z3.MkTactic(QE); //量词消去
ApplyResult A = tac.Apply(G); //看看a.Subgoals
 

Minio 安装和使用详解,还有对.net api进行了二次封装

I can not find .net api for (elim-quantifiers (exists ((x Int)) (and (< t1 x) (< x t2)))) is it a Tactic? Could someone help me using .net API of Z3 to implement the following scripts?

(declare-const t1 Int)
(declare-const t2 Int)

(elim-quantifiers (exists ((x Int)) (and (< t1 x) (< x t2))))

解决方案

Yes, you can use a tactic. Here is an example using the .NET API (I didn't run this particular example so it may need some minor modification, but I use roughly the same in a program of mine).

// (exists ((x Int)) (and (< t1 x) (< x t2))))
Context z3 = new Context();
Expr t1 = z3.MkIntConst("t1");
Expr t2 = z3.MkIntConst("t2");
Expr x = z3.MkIntConst("x");

Expr p = z3.MkAnd(z3.MkLt((ArithExpr)t1, (ArithExpr)x), z3.MkLt((ArithExpr)x, (ArithExpr)t2));
Expr ex = z3.MkExists(new Expr[] { x }, p);

Goal g = z3.MkGoal(true, true, false);
g.Assert((BoolExpr)ex);
Tactic tac = Instance.Z3.MkTactic("qe"); // quantifier elimination
ApplyResult a = tac.Apply(g); // look at a.Subgoals