本文整理匯總了C#中Microsoft.Z3.Context.MkFixedpoint方法的典型用法代碼示例。如果您正苦於以下問題:C# Context.MkFixedpoint方法的具體用法?C# Context.MkFixedpoint怎麽用?C# Context.MkFixedpoint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Microsoft.Z3.Context
的用法示例。
在下文中一共展示了Context.MkFixedpoint方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Run
public void Run()
{
using (Context ctx = new Context()) {
var s = ctx.MkFixedpoint();
BoolSort B = ctx.BoolSort;
Sort BV8 = ctx.MkBitVecSort(8);
FuncDecl edge = ctx.MkFuncDecl("edge", new Sort[]{BV8, BV8}, B);
FuncDecl path = ctx.MkFuncDecl("path", new Sort[]{BV8, BV8}, B);
BitVecExpr x = (BitVecExpr)ctx.MkBound(0,BV8);
BitVecExpr y = (BitVecExpr)ctx.MkBound(1,BV8);
BitVecExpr z = (BitVecExpr)ctx.MkBound(2,BV8);
s.RegisterRelation(edge);
s.RegisterRelation(path);
s.AddRule(ctx.MkImplies((BoolExpr)edge[x,y],(BoolExpr)path[x,y]));
s.AddRule(ctx.MkImplies(ctx.MkAnd((BoolExpr)path[x,y],(BoolExpr)path[y,z]),
(BoolExpr)path[x,z]));
for (uint i = 0; i < 128; ++i) {
s.AddFact(edge, i, i+1);
}
Console.WriteLine(s.Query((BoolExpr)path[ctx.MkBV(0,8),ctx.MkBV(129,8)]));
Console.WriteLine(s.GetAnswer());
Console.WriteLine(s.Query((BoolExpr)path[ctx.MkBV(0,8),ctx.MkBV(128,8)]));
Console.WriteLine(s.GetAnswer());
Console.WriteLine(s.Query((BoolExpr)path[x,ctx.MkBV(20,8)]));
Console.WriteLine(s.GetAnswer());
Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)path[x,y],
(BoolExpr)path[y,ctx.MkBV(20,8)])));
Console.WriteLine(s.GetAnswer());
}
}
示例2: Run
public void Run()
{
using (Context ctx = new Context()) {
ctx.UpdateParamValue("DL_ENGINE","1");
ctx.UpdateParamValue("DL_PDR_USE_FARKAS","true");
// ctx.UpdateParamValue("VERBOSE","2");
var s = ctx.MkFixedpoint();
BoolSort B = ctx.BoolSort;
IntSort I = ctx.IntSort;
FuncDecl mc = ctx.MkFuncDecl("mc", new Sort[]{I, I}, B);
ArithExpr x = (ArithExpr)ctx.MkBound(0,I);
ArithExpr y = (ArithExpr)ctx.MkBound(1,I);
ArithExpr z = (ArithExpr)ctx.MkBound(2,I);
s.RegisterRelation(mc);
BoolExpr gt = ctx.MkGt(x, ctx.MkInt(100));
s.AddRule(ctx.MkImplies(gt,(BoolExpr)mc[x,ctx.MkSub(x,ctx.MkInt(10))]));
s.AddRule(ctx.MkImplies(ctx.MkAnd(ctx.MkNot(gt),
(BoolExpr) mc[ctx.MkAdd(x,ctx.MkInt(11)),y],
(BoolExpr) mc[y,z]),
(BoolExpr) mc[x,z]));
Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)mc[x,y], ctx.MkGt(y,ctx.MkInt(100)))));
Console.WriteLine(s.GetAnswer());
Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)mc[x,y], ctx.MkLt(y,ctx.MkInt(91)))));
Console.WriteLine(s.GetAnswer());
}
}
示例3: Run
public void Run()
{
using (Context ctx = new Context()) {
var s = ctx.MkFixedpoint();
BoolExpr a = ctx.MkBoolConst("a");
BoolExpr b = ctx.MkBoolConst("b");
BoolExpr c = ctx.MkBoolConst("c");
s.RegisterRelation(a.FuncDecl);
s.RegisterRelation(b.FuncDecl);
s.RegisterRelation(c.FuncDecl);
s.AddRule(ctx.MkImplies(a, b));
s.AddRule(ctx.MkImplies(b, c));
Console.WriteLine(s.Query(c));
s.AddRule(a);
Console.WriteLine(s.Query(c));
}
}
示例4: Run
public void Run()
{
using (Context ctx = new Context())
{
Console.WriteLine("Simplify");
Symbol[] sp = ctx.SimplifyParameterDescriptions.Names;
foreach (var s in sp) {
Console.WriteLine("{0}",s);
}
Console.WriteLine("Fixedpoint");
Fixedpoint fp = ctx.MkFixedpoint();
sp = fp.ParameterDescriptions.Names;
foreach (var s in sp) {
Console.WriteLine("{0}",s);
}
}
}
示例5: Run
public void Run()
{
using (Context ctx = new Context()) {
var s = ctx.MkFixedpoint();
BoolSort B = ctx.BoolSort;
Sort BV8 = ctx.MkBitVecSort(8);
FuncDecl f = ctx.MkFuncDecl("f", BV8, B);
FuncDecl g = ctx.MkFuncDecl("g", BV8, B);
BitVecExpr b0 = (BitVecExpr)ctx.MkBound(0,BV8);
s.RegisterRelation(f);
s.RegisterRelation(g);
s.AddRule((BoolExpr)f[b0]);
BitVecExpr mask0 = ctx.MkBV(0xFE,8);
BoolExpr even = ctx.MkEq(b0,ctx.MkBVAND(b0,mask0));
s.AddRule(ctx.MkImplies(ctx.MkAnd((BoolExpr)f[b0],even), (BoolExpr)g[b0]));
Console.WriteLine(s.Query((BoolExpr)g[b0]));
Console.WriteLine(s.GetAnswer());
}
}
示例6: Run
public void Run()
{
using (Context ctx = new Context())
{
this.ctx = ctx;
ctx.UpdateParamValue("DL_GENERATE_EXPLANATIONS", "true");
red_car = new Car(false, 2, 2, 3, "red");
cars = new Car[]{
new Car(true, 0, 3, 0, "yellow"),
new Car(false, 3, 3, 0, "blue"),
new Car(false, 5, 2, 0, "brown"),
new Car(false, 0, 2, 1, "lgreen"),
new Car(true, 1, 2, 1, "light blue"),
new Car(true, 2, 2, 1, "pink"),
new Car(true, 2, 2, 4, "dark green"),
red_car,
new Car(true, 3, 2, 3, "purple"),
new Car(false, 5, 2, 3, "light yellow"),
new Car(true, 4, 2, 0, "orange"),
new Car(false, 4, 2, 4, "black"),
new Car(true, 5, 3, 1, "light purple")
};
this.num_cars = cars.Length;
this.B = ctx.MkBoolSort();
this.bv3 = ctx.MkBitVecSort(3);
List<Sort> domain = new List<Sort>();
foreach (var c in cars) domain.Add(bv3);
this.state = ctx.MkFuncDecl("state", domain.ToArray(), B);
this.fp = ctx.MkFixedpoint();
this.fp.RegisterRelation(state);
// Initial state:
Expr[] args = new Expr[num_cars];
for (int i = 0; i < num_cars; ++i) args[i] = num(cars[i].start);
fp.AddRule((BoolExpr)state[args]);
// Transitions:
for (int pos = 0; pos < num_cars; ++pos)
{
Car car = cars[pos];
for (int i = 0; i < dimension; ++i)
if (car.is_vertical)
{
move_down(i, pos, car);
move_up(i, pos, car);
}
else
{
move_left(i, pos, car);
move_right(i, pos, car);
}
}
// Print the current context:
Console.WriteLine("{0}", fp);
// Prepare the query:
for (int i = 0; i < num_cars; ++i) args[i] = (cars[i] == red_car) ? num(4) : bound(i);
BoolExpr goal = (BoolExpr)state[args];
fp.Query(goal);
// Extract a path:
get_instructions(fp.GetAnswer());
}
}