public MkUninterpretedSort ( |
||
s | ||
Résultat |
public void Run() { Dictionary<string, string> cfg = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { Sort A = ctx.MkUninterpretedSort("A"); Sort B = ctx.MkUninterpretedSort("B"); FuncDecl f = ctx.MkFuncDecl("f", A, B); Expr a1 = ctx.MkConst("a1", A); Expr a2 = ctx.MkConst("a2", A); Expr b = ctx.MkConst("b", B); Expr x = ctx.MkConst("x", A); Expr y = ctx.MkConst("y", A); Solver s = ctx.MkSolver(); s.Assert(ctx.MkNot(ctx.MkEq(a1, a2))); s.Assert(ctx.MkEq(f[a1], b)); s.Assert(ctx.MkEq(f[a2], b)); s.Assert(ctx.MkForall(new Expr[] { x, y }, ctx.MkImplies(ctx.MkEq(f[x], f[y]), ctx.MkEq(x, y)), 1, new Pattern[] { ctx.MkPattern(f[x], f[y]) })); Console.WriteLine(s); Console.WriteLine(s.Check()); } }
public void Run() { using (Context ctx = new Context()) { Sort U = ctx.MkUninterpretedSort("U"); Console.WriteLine(U); Expr a = ctx.MkConst("a", U); a = ctx.MkConst("a", U); Expr b = ctx.MkConst("b", U); Expr c = ctx.MkConst("c", U); IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); Console.WriteLine(ctx.MkAnd(ctx.MkEq(a, b), ctx.MkEq(a, c))); Console.WriteLine(U == ctx.IntSort); Sort U2 = ctx.MkUninterpretedSort("U"); Console.WriteLine(U == U2); U2 = ctx.MkUninterpretedSort("U2"); Console.WriteLine(U == U2); Console.WriteLine(ctx.MkDistinct(a, b, c)); FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { U, U }, U); Console.WriteLine(ctx.MkEq(f[a,b], b)); } }
public void Run() { using (Context ctx = new Context()) { Sort U = ctx.MkUninterpretedSort("U"); FuncDecl f = ctx.MkFuncDecl("f", U, U); Expr a = ctx.MkConst("a", U); Expr b = ctx.MkConst("b", U); Expr c = ctx.MkConst("c", U); Solver s = ctx.MkSolver(); s.Assert(ctx.MkEq(f[f[a]], b), ctx.MkNot(ctx.MkEq(f[b], c)), ctx.MkEq(f[c], c)); Console.WriteLine(s.Check()); Model m = s.Model; foreach (FuncDecl d in m.Decls) if (d.DomainSize == 0) Console.WriteLine(d.Name + " -> " + m.ConstInterp(d)); else Console.WriteLine(d.Name + " -> " + m.FuncInterp(d)); Console.WriteLine(m.NumSorts); Console.WriteLine(m.Sorts[0]); foreach(Sort srt in m.Sorts) Console.WriteLine(srt); foreach (Expr v in m.SortUniverse(U)) Console.WriteLine(v); } }
public void Run() { Dictionary<string, string> cfg = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { Sort A = ctx.MkUninterpretedSort("A"); Expr x = ctx.MkConst("x", A); Expr y = ctx.MkConst("y", A); FuncDecl f = ctx.MkFuncDecl("f", A, A); Solver s = ctx.MkSolver(); s.Assert(ctx.MkEq(f[f[x]], x), ctx.MkEq(f[x], y), ctx.MkNot(ctx.MkEq(x, y))); Console.WriteLine(s.Check()); Model m = s.Model; Console.WriteLine(m); Console.WriteLine("interpretation assigned to A: "); foreach (Expr a in m.SortUniverse(A)) Console.WriteLine(a); } }
public void Run() { using (Context ctx = new Context()) { Symbol s1 = ctx.MkSymbol(1); Symbol s2 = ctx.MkSymbol(1); Symbol s3 = ctx.MkSymbol(2); Sort[] domain = new Sort[0]; Sort range = ctx.IntSort; TestDriver.CheckAssertion("a1", s1 == s2); TestDriver.CheckAssertion("a2", s1 != s3); TestDriver.CheckAssertion("a3", ctx.MkSymbol("x") != s1); TestDriver.CheckAssertion("a4", ctx.MkSymbol("x") == ctx.MkSymbol("x")); TestDriver.CheckAssertion("a5", ctx.MkFuncDecl("f", domain, range) == ctx.MkFuncDecl("f", domain, range)); TestDriver.CheckAssertion("a6", ctx.MkFuncDecl("f", domain, range) != ctx.MkFuncDecl("g", domain, range)); TestDriver.CheckAssertion("a7", ctx.MkUninterpretedSort("s") == ctx.MkUninterpretedSort("s")); TestDriver.CheckAssertion("a8", ctx.MkUninterpretedSort("s") != ctx.MkUninterpretedSort("t")); TestDriver.CheckAssertion("a9", ctx.MkUninterpretedSort("s") != ctx.IntSort); TestDriver.CheckAssertion("a10", ctx.MkConst("x", range) == ctx.MkConst("x", range)); TestDriver.CheckAssertion("a11", ctx.MkConst("x", range) == ctx.MkConst(ctx.MkSymbol("x"), range)); TestDriver.CheckAssertion("a12", ctx.MkConst("x", range) != ctx.MkConst("y", range)); } }
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); } }
/// <summary> /// Prove <tt>x = y implies g(x) = g(y)</tt>, and /// disprove <tt>x = y implies g(g(x)) = g(y)</tt>. /// </summary> /// <remarks>This function demonstrates how to create uninterpreted /// types and functions.</remarks> public static void ProveExample1(Context ctx) { Console.WriteLine("ProveExample1"); /* create uninterpreted type. */ Sort U = ctx.MkUninterpretedSort(ctx.MkSymbol("U")); /* declare function g */ FuncDecl g = ctx.MkFuncDecl("g", U, U); /* create x and y */ Expr x = ctx.MkConst("x", U); Expr y = ctx.MkConst("y", U); /* create g(x), g(y) */ Expr gx = g[x]; Expr gy = g[y]; /* assert x = y */ BoolExpr eq = ctx.MkEq(x, y); /* prove g(x) = g(y) */ BoolExpr f = ctx.MkEq(gx, gy); Console.WriteLine("prove: x = y implies g(x) = g(y)"); Prove(ctx, ctx.MkImplies(eq, f)); /* create g(g(x)) */ Expr ggx = g[gx]; /* disprove g(g(x)) = g(y) */ f = ctx.MkEq(ggx, gy); Console.WriteLine("disprove: x = y implies g(g(x)) = g(y)"); Disprove(ctx, ctx.MkImplies(eq, f)); /* Print the model using the custom model printer */ Model m = Check(ctx, ctx.MkNot(f), Status.SATISFIABLE); Console.WriteLine(m); }