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

Method LogicExample

examples/dotnet/Program.cs:1023–1051  ·  view source on GitHub ↗

Shows how to use Solver(logic)

(Context ctx)

Source from the content-addressed store, hash-verified

1021 /// </summary>
1022 /// <param name="ctx"></param>
1023 static void LogicExample(Context ctx)
1024 {
1025 Console.WriteLine("LogicTest");
1026
1027 Microsoft.Z3.Global.ToggleWarningMessages(true);
1028
1029 BitVecSort bvs = ctx.MkBitVecSort(32);
1030 Expr x = ctx.MkConst("x", bvs);
1031 Expr y = ctx.MkConst("y", bvs);
1032 BoolExpr eq = ctx.MkEq(x, y);
1033
1034 // Use a solver for QF_BV
1035 Solver s = ctx.MkSolver("QF_BV");
1036 s.Assert(eq);
1037 Status res = s.Check();
1038 Console.WriteLine("solver result: " + res);
1039
1040
1041 // Or perhaps a tactic for QF_BV
1042 Goal g = ctx.MkGoal(true);
1043 g.Assert(eq);
1044
1045 Tactic t = ctx.MkTactic("qfbv");
1046 ApplyResult ar = t.Apply(g);
1047 Console.WriteLine("tactic result: " + ar);
1048
1049 if (ar.NumSubgoals != 1 || !ar.Subgoals[0].IsDecidedSat)
1050 throw new TestFailedException();
1051 }
1052
1053 /// <summary>
1054 /// Demonstrates how to use the ParOr tactic.

Callers

nothing calls this directly

Calls 10

MkBitVecSortMethod · 0.80
MkSolverMethod · 0.80
ToggleWarningMessagesMethod · 0.45
MkConstMethod · 0.45
MkEqMethod · 0.45
AssertMethod · 0.45
CheckMethod · 0.45
MkGoalMethod · 0.45
MkTacticMethod · 0.45
ApplyMethod · 0.45

Tested by

no test coverage detected