本文整理汇总了C#中Z3Provider.MkFuncDecl方法的典型用法代码示例。如果您正苦于以下问题:C# Z3Provider.MkFuncDecl方法的具体用法?C# Z3Provider.MkFuncDecl怎么用?C# Z3Provider.MkFuncDecl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Z3Provider
的用法示例。
在下文中一共展示了Z3Provider.MkFuncDecl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FuncDeclTest3
public void FuncDeclTest3()
{
try
{
Z3Provider Z = new Z3Provider();
Z.MainSolver.Push();
FuncDecl f = Z.MkFuncDecl("temp", Z.IntSort, Z.IntSort);
Z.MainSolver.Push();
Z.MainSolver.Push();
Z.MainSolver.Pop();
Z.MainSolver.Pop();
FuncDecl g = Z.MkFuncDecl("temp", Z.IntSort, Z.IntSort);
Z.MainSolver.Push();
Z.MainSolver.Pop();
}
catch (AutomataException e)
{
Assert.AreEqual(e.kind, AutomataExceptionKind.FunctionIsAlreadyDeclared);
}
}
示例2: TestFuncDecl
public void TestFuncDecl()
{
Z3Provider z3p = new Z3Provider();
FuncDecl f = z3p.MkFuncDecl("foo[56:205]", z3p.IntSort, z3p.IntSort);
//FuncDecl f = z3p.Z3.GetAppDecl(z3p.MkBvExtract(0, 0, z3p.MkNumeral(34, z3p.CharacterSort)));
uint[] p = z3p.GetDeclParameters(f);
Assert.AreEqual<int>(2, p.Length);
Assert.AreEqual<uint>(56, p[0]);
Assert.AreEqual<uint>(205, p[1]);
}
示例3: TupleTest
public void TupleTest()
{
Z3Provider z3p = new Z3Provider();
//create the tuple sort for mouth
FuncDecl mouth;
FuncDecl[] mouth_accessors;
var MOUTH = z3p.MkTupleSort("MOUTH", new string[] { "open", "teeth" }, new Sort[] { z3p.BoolSort, z3p.IntSort }, out mouth, out mouth_accessors);
Func<Expr,Expr,Expr> mk_mouth = ((o,t) => z3p.MkApp(mouth, o, t));
Func<Expr,Expr> get_open = (m => z3p.MkApp(mouth_accessors[0], m));
Func<Expr,Expr> get_teeth = (m => z3p.MkApp(mouth_accessors[1], m));
//create the tuple sort for nose
FuncDecl nose;
FuncDecl[] nose_accessors;
var NOSE = z3p.MkTupleSort("NOSE", new string[] { "size" }, new Sort[] { z3p.IntSort }, out nose, out nose_accessors);
Func<Expr,Expr> mk_nose = (s => z3p.MkApp(nose, s));
Func<Expr,Expr> get_size = (n => z3p.MkApp(nose_accessors[0], n));
//create the tuple sort for head
FuncDecl head;
FuncDecl[] head_accessors;
var HEAD = z3p.MkTupleSort("HEAD", new string[] { "bald", "nose", "mouth" }, new Sort[] { z3p.BoolSort, NOSE, MOUTH }, out head, out head_accessors);
Func<Expr,Expr,Expr,Expr> mk_head = ((b,n,m) => z3p.MkApp(head, b,n,m));
Func<Expr,Expr> get_bald = (h => z3p.MkApp(head_accessors[0], h));
Func<Expr,Expr> get_nose = (h => z3p.MkApp(head_accessors[1], h));
Func<Expr,Expr> get_mouth = (h => z3p.MkApp(head_accessors[2], h));
//------------------------
// create a transformation "punch" from HEAD tp HEAD that removes k teeth, k is the second parameter of the transformation
var punch = z3p.MkFuncDecl("punch", new Sort[]{HEAD, z3p.IntSort}, HEAD);
var x = z3p.MkVar(0, HEAD); // <-- this is the input HEAD
var y = z3p.MkVar(1, z3p.IntSort); // <-- this is the n parameter
//this is the actual transformation of x that removes one tooth
var new_mouth = mk_mouth(get_open(get_mouth(x)), z3p.MkSub(get_teeth(get_mouth(x)), y));
var old_nose = get_nose(x);
var old_bald = get_bald(x);
var punch_def = mk_head(old_bald, old_nose,new_mouth);
var punch_axiom = z3p.MkEqForall(z3p.MkApp(punch, x , y), punch_def, x, y);
Func<Expr,Expr,Expr> punch_app = ((h,k) => z3p.MkApp(punch, h,k));
z3p.MainSolver.Assert(punch_axiom);
//------------------------
// create a transformation "hit" from HEAD tp HEAD that doubles the size of the nose
var hit = z3p.MkFuncDecl("hit", HEAD, HEAD);
var hit_def = mk_head(get_bald(x), mk_nose(z3p.MkMul(z3p.MkInt(2),get_size(get_nose(x)))), get_mouth(x));
var hit_axiom = z3p.MkEqForall(z3p.MkApp(hit, x), hit_def, x);
Func<Expr,Expr> hit_app = (h => z3p.MkApp(hit, h));
z3p.MainSolver.Assert(hit_axiom);
//-------------------------------
// Analysis
var H = z3p.MkConst("H", HEAD);
var N = z3p.MkConst("N", z3p.IntSort);
// check that hit and punch commute
z3p.MainSolver.Push();
z3p.MainSolver.Assert(z3p.MkNeq(punch_app(hit_app(H), N), hit_app(punch_app(H, N))));
Status status = z3p.Check(); //here status must be UNSATISFIABLE
z3p.MainSolver.Pop(); //remove the temporary context
//check that hit is not idempotent
z3p.MainSolver.Push();
z3p.MainSolver.Assert(z3p.MkNeq(hit_app(hit_app(H)), hit_app(H)));
status = z3p.Check(); //here status must not be UNSATISFIABLE (it is UNKNOWN due to use of axioms)
var model1 = z3p.Z3S.Model;
var witness1 = model1.Evaluate(H, true); //a concrete instance of HEAD that shows when hitting twice is not the same as hitting once
z3p.MainSolver.Pop();
//but it is possible that hitting twice does no harm (when nose has size 0)
z3p.MainSolver.Push();
z3p.MainSolver.Assert(z3p.MkEq(hit_app(hit_app(H)), hit_app(H)));
status = z3p.Check();
var model2 = z3p.Z3S.Model;
var witness2 = model2.Evaluate(H, true);
z3p.MainSolver.Pop();
}
示例4: MkFuncDeclTest
public void MkFuncDeclTest()
{
try
{
Z3Provider Z = new Z3Provider();
var f = Z.MkFuncDecl("foo", Z.IntSort, Z.IntSort);
var g = Z.MkFuncDecl("foo", Z.IntSort, Z.BoolSort);
Assert.IsTrue(true);
}
catch (AutomataException e)
{
Assert.IsTrue(e.kind == AutomataExceptionKind.FunctionIsAlreadyDeclared);
}
}