本文整理汇总了C#中Microsoft.Z3.Context.MkOr方法的典型用法代码示例。如果您正苦于以下问题:C# Context.MkOr方法的具体用法?C# Context.MkOr怎么用?C# Context.MkOr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Z3.Context
的用法示例。
在下文中一共展示了Context.MkOr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
RealExpr x = ctx.MkRealConst("x");
RealExpr y = ctx.MkRealConst("y");
RealExpr z = ctx.MkRealConst("z");
RealExpr zero = ctx.MkReal(0);
RealExpr one = ctx.MkReal(1);
Goal g = ctx.MkGoal();
g.Assert(ctx.MkOr(ctx.MkEq(x, zero), ctx.MkEq(x, one)));
g.Assert(ctx.MkOr(ctx.MkEq(y, zero), ctx.MkEq(y, one)));
g.Assert(ctx.MkOr(ctx.MkEq(z, zero), ctx.MkEq(z, one)));
g.Assert(ctx.MkGt(ctx.MkAdd(x, y, z), ctx.MkReal(2)));
Tactic t = ctx.Repeat(ctx.OrElse(ctx.MkTactic("split-clause"), ctx.MkTactic("skip")));
ApplyResult ar = t[g];
foreach (var sg in ar.Subgoals)
Console.WriteLine(sg);
}
}
示例2: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
BoolExpr a = ctx.MkBoolConst("a");
BoolExpr b = ctx.MkBoolConst("b");
BoolExpr c = ctx.MkBoolConst("c");
BoolExpr d = ctx.MkBoolConst("d");
BoolExpr e = ctx.MkBoolConst("e");
BoolExpr f = ctx.MkBoolConst("f");
BoolExpr g = ctx.MkBoolConst("g");
BoolExpr z = ctx.MkBoolConst("z");
Console.WriteLine("Check 1");
InstallCheck(ctx, new BoolExpr[] {
DependsOn(ctx, a, new BoolExpr[] { b, c, z }),
DependsOn(ctx, b, new BoolExpr[] { d }),
DependsOn(ctx, c, new BoolExpr[] { ctx.MkOr(d, e), ctx.MkOr(f, g) }),
Conflict(ctx, d, e),
Conflict(ctx, d, g),
a, z });
Console.WriteLine("Check 2");
InstallCheck(ctx, new BoolExpr[] {
DependsOn(ctx, a, new BoolExpr[] { b, c, z }),
DependsOn(ctx, b, new BoolExpr[] { d }),
DependsOn(ctx, c, new BoolExpr[] { ctx.MkOr(d, e), ctx.MkOr(f, g) }),
Conflict(ctx, d, e),
Conflict(ctx, d, g),
a, z, g });
}
}
示例3: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
RealExpr x = ctx.MkRealConst("x");
RealExpr y = ctx.MkRealConst("y");
RealExpr z = ctx.MkRealConst("z");
RealExpr zero = ctx.MkReal(0);
RealExpr one = ctx.MkReal(1);
Goal g = ctx.MkGoal();
g.Assert(ctx.MkOr(ctx.MkEq(x, zero), ctx.MkEq(x, one)));
g.Assert(ctx.MkOr(ctx.MkEq(y, zero), ctx.MkEq(y, one)));
g.Assert(ctx.MkOr(ctx.MkEq(z, zero), ctx.MkEq(z, one)));
g.Assert(ctx.MkGt(ctx.MkAdd(x, y, z), ctx.MkReal(2)));
Tactic t = ctx.Repeat(ctx.OrElse(ctx.MkTactic("split-clause"), ctx.MkTactic("skip")));
Console.WriteLine(t[g]);
t = ctx.Repeat(ctx.OrElse(ctx.MkTactic("split-clause"), ctx.MkTactic("skip")), 1);
Console.WriteLine(t[g]);
t = ctx.Then(ctx.Repeat(ctx.OrElse(ctx.MkTactic("split-clause"), ctx.MkTactic("skip"))), ctx.MkTactic("solve-eqs"));
Console.WriteLine(t[g]);
}
}
示例4: Run
public void Run()
{
using (Context ctx = new Context())
{
BoolExpr p = ctx.MkBoolConst("p");
BoolExpr q = ctx.MkBoolConst("q");
Console.WriteLine(ctx.MkAnd(p, q));
Console.WriteLine(ctx.MkOr(p, q));
Console.WriteLine(ctx.MkAnd(p, ctx.MkTrue()));
Console.WriteLine(ctx.MkOr(p, ctx.MkFalse()));
Console.WriteLine(ctx.MkNot(p));
Console.WriteLine(ctx.MkImplies(p, q));
Console.WriteLine(ctx.MkEq(p, q).Simplify());
Console.WriteLine(ctx.MkEq(p, q));
BoolExpr r = ctx.MkBoolConst("r");
Console.WriteLine(ctx.MkNot(ctx.MkEq(p, ctx.MkNot(ctx.MkEq(q, r)))));
Console.WriteLine(ctx.MkNot(ctx.MkEq(ctx.MkNot(ctx.MkEq(p, q)), r)));
Console.WriteLine(ctx.MkEq(p, ctx.MkTrue()));
Console.WriteLine(ctx.MkEq(p, ctx.MkFalse()));
Console.WriteLine(ctx.MkEq(p, ctx.MkTrue()).Simplify());
Console.WriteLine(ctx.MkEq(p, ctx.MkFalse()).Simplify());
Console.WriteLine(ctx.MkEq(p, p).Simplify());
Console.WriteLine(ctx.MkEq(p, q).Simplify());
Console.WriteLine(ctx.MkAnd(p, q, r));
Console.WriteLine(ctx.MkOr(p, q, r));
IntExpr x = ctx.MkIntConst("x");
Console.WriteLine(x is BoolExpr);
Console.WriteLine(p is BoolExpr);
Console.WriteLine(ctx.MkAnd(p, q) is BoolExpr);
Console.WriteLine(p is BoolExpr);
Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)) is BoolExpr);
Console.WriteLine(p.IsAnd);
Console.WriteLine(ctx.MkOr(p, q).IsOr);
Console.WriteLine(ctx.MkAnd(p, q).IsAnd);
Console.WriteLine(x.IsNot);
Console.WriteLine(p.IsNot);
Console.WriteLine(ctx.MkNot(p));
Console.WriteLine(ctx.MkNot(p).IsDistinct);
Console.WriteLine(ctx.MkEq(p, q).IsDistinct);
Console.WriteLine(ctx.MkDistinct(p, q).IsDistinct);
Console.WriteLine(ctx.MkDistinct(x, ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkAdd(x, ctx.MkInt(2))).IsDistinct);
Console.WriteLine();
Console.WriteLine(ctx.MkBool(true));
Console.WriteLine(ctx.MkBool(false));
Console.WriteLine(ctx.BoolSort);
Context ctx1 = new Context();
Console.WriteLine(ctx1.MkBool(true));
Console.WriteLine(ctx1.BoolSort);
Console.WriteLine(ctx1.MkBool(true).Sort == ctx1.BoolSort);
Console.WriteLine(ctx1.MkBool(true).Sort == ctx.BoolSort);
Console.WriteLine(ctx1.MkBool(true).Sort != ctx.BoolSort);
}
}
示例5: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
BoolExpr a = ctx.MkBoolConst("a");
BoolExpr b = ctx.MkBoolConst("b");
BoolExpr c = ctx.MkBoolConst("c");
BoolExpr d = ctx.MkBoolConst("d");
BoolExpr e = ctx.MkBoolConst("e");
BoolExpr f = ctx.MkBoolConst("f");
BoolExpr g = ctx.MkBoolConst("g");
BoolExpr z = ctx.MkBoolConst("z");
Solver s = ctx.MkSolver();
s.Assert(DependsOn(ctx, a, new BoolExpr[] { b, c, z }));
s.Assert(DependsOn(ctx, b, new BoolExpr[] { d }));
s.Assert(DependsOn(ctx, c, new BoolExpr[] { ctx.MkOr(d, e), ctx.MkOr(f, g) }));
s.Assert(Conflict(ctx, d, e));
s.Assert(a);
s.Assert(z);
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
}
}
示例6: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
BitVecExpr x = ctx.MkBVConst("x", 32);
BitVecExpr[] powers = new BitVecExpr[32];
for (uint i = 0; i < 32; i++)
powers[i] = ctx.MkBVSHL(ctx.MkBV(1, 32), ctx.MkBV(i, 32));
BoolExpr step_zero = ctx.MkEq(ctx.MkBVAND(x, ctx.MkBVSub(x, ctx.MkBV(1, 32))), ctx.MkBV(0, 32));
BoolExpr fast = ctx.MkAnd(ctx.MkNot(ctx.MkEq(x, ctx.MkBV(0, 32))),
step_zero);
BoolExpr slow = ctx.MkFalse();
foreach (BitVecExpr p in powers)
slow = ctx.MkOr(slow, ctx.MkEq(x, p));
TestDriver.CheckString(fast, "(and (not (= x #x00000000)) (= (bvand x (bvsub x #x00000001)) #x00000000))");
Solver s = ctx.MkSolver();
s.Assert(ctx.MkNot(ctx.MkEq(fast, slow)));
TestDriver.CheckUNSAT(s.Check());
s = ctx.MkSolver();
s.Assert(ctx.MkNot(step_zero));
TestDriver.CheckSAT(s.Check());
}
}
示例7: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
RealExpr x = ctx.MkRealConst("x");
RealExpr y = ctx.MkRealConst("y");
Solver s = ctx.MkSolver();
s.Assert(ctx.MkGt(x, ctx.MkReal(1)),
ctx.MkGt(y, ctx.MkReal(1)),
ctx.MkOr(ctx.MkGt(ctx.MkAdd(x, y), ctx.MkReal(1)),
ctx.MkLt(ctx.MkSub(x, y), ctx.MkReal(2))));
Console.WriteLine("asserted constraints: ");
foreach (var c in s.Assertions)
Console.WriteLine(c);
Console.WriteLine(s.Check());
Console.WriteLine(s.Statistics);
Console.WriteLine("stats for last check: ");
foreach (Statistics.Entry e in s.Statistics.Entries)
Console.WriteLine(e);
}
}
示例8: ArrayExample2
/// <summary>
/// Prove <tt>store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3))</tt>.
/// </summary>
/// <remarks>This example demonstrates how to use the array theory.</remarks>
public static void ArrayExample2(Context ctx)
{
Console.WriteLine("ArrayExample2");
Sort int_type = ctx.IntSort;
Sort array_type = ctx.MkArraySort(int_type, int_type);
ArrayExpr a1 = (ArrayExpr)ctx.MkConst("a1", array_type);
ArrayExpr a2 = ctx.MkArrayConst("a2", int_type, int_type);
Expr i1 = ctx.MkConst("i1", int_type);
Expr i2 = ctx.MkConst("i2", int_type);
Expr i3 = ctx.MkConst("i3", int_type);
Expr v1 = ctx.MkConst("v1", int_type);
Expr v2 = ctx.MkConst("v2", int_type);
Expr st1 = ctx.MkStore(a1, i1, v1);
Expr st2 = ctx.MkStore(a2, i2, v2);
Expr sel1 = ctx.MkSelect(a1, i3);
Expr sel2 = ctx.MkSelect(a2, i3);
/* create antecedent */
BoolExpr antecedent = ctx.MkEq(st1, st2);
/* create consequent: i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3) */
BoolExpr consequent = ctx.MkOr(new BoolExpr[] { ctx.MkEq(i1, i3), ctx.MkEq(i2, i3), ctx.MkEq(sel1, sel2) });
/* prove store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3)) */
BoolExpr thm = ctx.MkImplies(antecedent, consequent);
Console.WriteLine("prove: store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3))");
Console.WriteLine("{0}", (thm));
Prove(ctx, thm);
}
示例9: Conflict
public BoolExpr Conflict(Context ctx, params BoolExpr[] packs)
{
BoolExpr q = ctx.MkFalse();
foreach (BoolExpr p in packs)
q = ctx.MkOr(q, ctx.MkNot(p));
return q;
}
示例10: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" },
{ "MODEL", "true" } };
using (Context ctx = new Context(cfg))
{
Constructor cred = ctx.MkConstructor("red", "is_red");
Constructor cgreen = ctx.MkConstructor("green", "is_green");
Constructor cblue = ctx.MkConstructor("blue", "is_blue");
DatatypeSort color = ctx.MkDatatypeSort("Color", new Constructor[] { cred, cgreen, cblue });
Expr Red = ctx.MkConst(color.Constructors[0]);
Expr Green = ctx.MkConst(color.Constructors[1]);
Expr Blue = ctx.MkConst(color.Constructors[2]);
Expr c = ctx.MkConst("c", color);
Solver s = ctx.MkSolver();
s.Assert(ctx.MkNot(ctx.MkOr(ctx.MkEq(c, Red), ctx.MkEq(c, Green), ctx.MkEq(c, Blue))));
Console.WriteLine(s.Check()); // must be unsat
BoolExpr c_is_red = (BoolExpr)color.Recognizers[0][c];
BoolExpr c_is_green = (BoolExpr)color.Recognizers[1][c];
BoolExpr c_is_blue = (BoolExpr)color.Recognizers[2][c];
s = ctx.MkSolver();
s.Assert(ctx.MkOr(c_is_red, c_is_green, c_is_blue));
Console.WriteLine(s.Check()); // must be sat
s = ctx.MkSolver();
s.Assert(ctx.MkNot(ctx.MkOr(c_is_red, c_is_green, c_is_blue)));
Console.WriteLine(s.Check()); // must be unsat
}
}
示例11: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
BitVecExpr x = ctx.MkBVConst("x", 32);
BitVecExpr y = ctx.MkBVConst("y", 32);
BitVecExpr zero = ctx.MkBV(0, 32);
BoolExpr trick = ctx.MkBVSLT(ctx.MkBVXOR(x, y), zero);
BoolExpr opposite = ctx.MkOr(ctx.MkAnd(ctx.MkBVSLT(x, zero), ctx.MkBVSGE(y, zero)),
ctx.MkAnd(ctx.MkBVSGE(x, zero), ctx.MkBVSLT(y, zero)));
Solver s = ctx.MkSolver();
s.Assert(ctx.MkNot(ctx.MkEq(trick, opposite)));
Console.WriteLine(s.Check());
}
}
示例12: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
RealExpr x = ctx.MkRealConst("x");
RealExpr y = ctx.MkRealConst("y");
Goal g = ctx.MkGoal();
g.Assert(ctx.MkOr(ctx.MkLt(x, ctx.MkReal(0)),
ctx.MkGt(x, ctx.MkReal(0))));
g.Assert(ctx.MkEq(x, ctx.MkAdd(y, ctx.MkReal(1))));
g.Assert(ctx.MkLt(y, ctx.MkReal(0)));
Tactic t = ctx.MkTactic("split-clause");
ApplyResult ar = t[g];
foreach (var sg in ar.Subgoals)
Console.WriteLine(sg);
}
}
示例13: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
Sort T = ctx.MkUninterpretedSort("Type");
FuncDecl subtype = ctx.MkFuncDecl("subtype", new Sort[] { T, T }, ctx.BoolSort);
FuncDecl array_of = ctx.MkFuncDecl("array_of", T, T);
Expr root = ctx.MkConst("root", T);
Expr x = ctx.MkConst("x", T);
Expr y = ctx.MkConst("y", T);
Expr z = ctx.MkConst("z", T);
BoolExpr[] axioms = new BoolExpr[] {
ctx.MkForall(new Expr[] { x }, subtype[x, x]),
ctx.MkForall(new Expr[] { x, y , z }, ctx.MkImplies(ctx.MkAnd((BoolExpr)subtype[x,y], (BoolExpr)subtype[y,z]), (BoolExpr)subtype[x,z])),
ctx.MkForall(new Expr[] { x, y }, ctx.MkImplies(ctx.MkAnd((BoolExpr)subtype[x, y], (BoolExpr)subtype[y,x]), ctx.MkEq(x, y))),
ctx.MkForall(new Expr[] { x, y, z }, ctx.MkImplies(ctx.MkAnd((BoolExpr)subtype[x,y],(BoolExpr)subtype[x,z]),
ctx.MkOr((BoolExpr)subtype[y,z], (BoolExpr)subtype[z,y]))),
ctx.MkForall(new Expr[] { x, y }, ctx.MkImplies((BoolExpr)subtype[x,y], (BoolExpr)subtype[array_of[x], array_of[y]])),
ctx.MkForall(new Expr[] { x }, (BoolExpr) subtype[root, x])
};
Solver s = ctx.MkSolver();
s.Assert(axioms);
Console.WriteLine(s);
Console.WriteLine(s.Check());
Expr[] universe = s.Model.SortUniverse(T);
foreach (var e in universe)
Console.WriteLine(e);
Console.WriteLine(s.Model);
}
}
示例14: GtOrNe
public static Expr GtOrNe(String left1, int left2, String right1, int right2)
{
using (Context ctx = new Context())
{
Expr a = ctx.MkConst(left1, ctx.MkIntSort());
Expr b = ctx.MkNumeral(left2, ctx.MkIntSort());
Expr c = ctx.MkConst(right1, ctx.MkIntSort());
Expr d = ctx.MkNumeral(right2, ctx.MkIntSort());
Solver s = ctx.MkSolver();
s.Assert(ctx.MkOr(ctx.MkGt((ArithExpr)a, (ArithExpr)b), ctx.MkNot(ctx.MkEq((ArithExpr)c, (ArithExpr)d))));
s.Check();
BoolExpr testing = ctx.MkOr(ctx.MkGt((ArithExpr)a, (ArithExpr)b), ctx.MkNot(ctx.MkEq((ArithExpr)c, (ArithExpr)d)));
Model model = Check(ctx, testing, Status.SATISFIABLE);
Expr result2;
Model m2 = s.Model;
foreach (FuncDecl d2 in m2.Decls)
{
result2 = m2.ConstInterp(d2);
return result2;
}
}
return null;
}
示例15: UnsatCoreAndProofExample2
/// <summary>
/// Extract unsatisfiable core example with AssertAndTrack
/// </summary>
public static void UnsatCoreAndProofExample2(Context ctx)
{
Console.WriteLine("UnsatCoreAndProofExample2");
Solver solver = ctx.MkSolver();
BoolExpr pa = ctx.MkBoolConst("PredA");
BoolExpr pb = ctx.MkBoolConst("PredB");
BoolExpr pc = ctx.MkBoolConst("PredC");
BoolExpr pd = ctx.MkBoolConst("PredD");
BoolExpr f1 = ctx.MkAnd(new BoolExpr[] { pa, pb, pc });
BoolExpr f2 = ctx.MkAnd(new BoolExpr[] { pa, ctx.MkNot(pb), pc });
BoolExpr f3 = ctx.MkOr(ctx.MkNot(pa), ctx.MkNot(pc));
BoolExpr f4 = pd;
BoolExpr p1 = ctx.MkBoolConst("P1");
BoolExpr p2 = ctx.MkBoolConst("P2");
BoolExpr p3 = ctx.MkBoolConst("P3");
BoolExpr p4 = ctx.MkBoolConst("P4");
solver.AssertAndTrack(f1, p1);
solver.AssertAndTrack(f2, p2);
solver.AssertAndTrack(f3, p3);
solver.AssertAndTrack(f4, p4);
Status result = solver.Check();
if (result == Status.UNSATISFIABLE)
{
Console.WriteLine("unsat");
Console.WriteLine("core: ");
foreach (Expr c in solver.UnsatCore)
{
Console.WriteLine("{0}", c);
}
}
}