A simple array example.
(Context ctx)
| 331 | /// </summary> |
| 332 | /// <param name="ctx"></param> |
| 333 | static void ArrayExample1(Context ctx) |
| 334 | { |
| 335 | Console.WriteLine("ArrayExample1"); |
| 336 | |
| 337 | Goal g = ctx.MkGoal(true); |
| 338 | ArraySort asort = ctx.MkArraySort(ctx.IntSort, ctx.MkBitVecSort(32)); |
| 339 | ArrayExpr aex = (ArrayExpr)ctx.MkConst(ctx.MkSymbol("MyArray"), asort); |
| 340 | Expr sel = ctx.MkSelect(aex, ctx.MkInt(0)); |
| 341 | g.Assert(ctx.MkEq(sel, ctx.MkBV(42, 32))); |
| 342 | Symbol xs = ctx.MkSymbol("x"); |
| 343 | IntExpr xc = (IntExpr)ctx.MkConst(xs, ctx.IntSort); |
| 344 | |
| 345 | Symbol fname = ctx.MkSymbol("f"); |
| 346 | Sort[] domain = { ctx.IntSort }; |
| 347 | FuncDecl fd = ctx.MkFuncDecl(fname, domain, ctx.IntSort); |
| 348 | Expr[] fargs = { ctx.MkConst(xs, ctx.IntSort) }; |
| 349 | IntExpr fapp = (IntExpr)ctx.MkApp(fd, fargs); |
| 350 | |
| 351 | g.Assert(ctx.MkEq(ctx.MkAdd(xc, fapp), ctx.MkInt(123))); |
| 352 | |
| 353 | Solver s = ctx.MkSolver(); |
| 354 | foreach (BoolExpr a in g.Formulas) |
| 355 | s.Assert(a); |
| 356 | Console.WriteLine("Solver: " + s); |
| 357 | |
| 358 | Status q = s.Check(); |
| 359 | Console.WriteLine("Status: " + q); |
| 360 | |
| 361 | if (q != Status.SATISFIABLE) |
| 362 | throw new TestFailedException(); |
| 363 | |
| 364 | Console.WriteLine("Model = " + s.Model); |
| 365 | |
| 366 | Console.WriteLine("Interpretation of MyArray:\n" + s.Model.ConstInterp(aex.FuncDecl)); |
| 367 | Console.WriteLine("Interpretation of x:\n" + s.Model.ConstInterp(xc)); |
| 368 | Console.WriteLine("Interpretation of f:\n" + s.Model.FuncInterp(fd)); |
| 369 | Console.WriteLine("Interpretation of MyArray as Term:\n" + s.Model.ConstInterp(aex.FuncDecl)); |
| 370 | } |
| 371 | |
| 372 | /// <summary> |
| 373 | /// Prove <tt>store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3))</tt>. |
nothing calls this directly
no test coverage detected