MCPcopy Create free account
hub / github.com/Z3Prover/z3 / BasicTests

Method BasicTests

examples/dotnet/Program.cs:726–838  ·  view source on GitHub ↗

Some basic tests.

(Context ctx)

Source from the content-addressed store, hash-verified

724 /// Some basic tests.
725 /// </summary>
726 static void BasicTests(Context ctx)
727 {
728 Console.WriteLine("BasicTests");
729
730 Symbol fname = ctx.MkSymbol("f");
731 Symbol x = ctx.MkSymbol("x");
732 Symbol y = ctx.MkSymbol("y");
733
734 Sort bs = ctx.MkBoolSort();
735
736 Sort[] domain = { bs, bs };
737 FuncDecl f = ctx.MkFuncDecl(fname, domain, bs);
738 Expr fapp = ctx.MkApp(f, ctx.MkConst(x, bs), ctx.MkConst(y, bs));
739
740 Expr[] fargs2 = { ctx.MkFreshConst("cp", bs) };
741 Sort[] domain2 = { bs };
742 Expr fapp2 = ctx.MkApp(ctx.MkFreshFuncDecl("fp", domain2, bs), fargs2);
743
744 BoolExpr trivial_eq = ctx.MkEq(fapp, fapp);
745 BoolExpr nontrivial_eq = ctx.MkEq(fapp, fapp2);
746
747 Goal g = ctx.MkGoal(true);
748 g.Assert(trivial_eq);
749 g.Assert(nontrivial_eq);
750 Console.WriteLine("Goal: " + g);
751
752 Solver solver = ctx.MkSolver();
753
754 foreach (BoolExpr a in g.Formulas)
755 solver.Assert(a);
756
757 if (solver.Check() != Status.SATISFIABLE)
758 throw new TestFailedException();
759
760 ApplyResult ar = ApplyTactic(ctx, ctx.MkTactic("simplify"), g);
761 if (ar.NumSubgoals == 1 && (ar.Subgoals[0].IsDecidedSat || ar.Subgoals[0].IsDecidedUnsat))
762 throw new TestFailedException();
763
764 ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g);
765 if (ar.NumSubgoals != 1 || !ar.Subgoals[0].IsDecidedSat)
766 throw new TestFailedException();
767
768 g.Assert(ctx.MkEq(ctx.MkNumeral(1, ctx.MkBitVecSort(32)),
769 ctx.MkNumeral(2, ctx.MkBitVecSort(32))));
770 ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g);
771 if (ar.NumSubgoals != 1 || !ar.Subgoals[0].IsDecidedUnsat)
772 throw new TestFailedException();
773
774
775 Goal g2 = ctx.MkGoal(true, true);
776 ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g2);
777 if (ar.NumSubgoals != 1 || !ar.Subgoals[0].IsDecidedSat)
778 throw new TestFailedException();
779
780 g2 = ctx.MkGoal(true, true);
781 g2.Assert(ctx.MkFalse());
782 ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g2);
783 if (ar.NumSubgoals != 1 || !ar.Subgoals[0].IsDecidedUnsat)

Callers

nothing calls this directly

Calls 15

MkSymbolMethod · 0.80
MkFreshConstMethod · 0.80
MkSolverMethod · 0.80
MkBitVecSortMethod · 0.80
ToDecimalStringMethod · 0.80
MkBoolSortMethod · 0.45
MkFuncDeclMethod · 0.45
MkAppMethod · 0.45
MkConstMethod · 0.45
MkFreshFuncDeclMethod · 0.45
MkEqMethod · 0.45
MkGoalMethod · 0.45

Tested by

no test coverage detected