public static VC.ConditionGeneration.Outcome MyVerifyImplementation(Implementation impl, Program prog) { VC.ConditionGeneration vcgen = BoogieVerify.InitializeVC(prog); List <Counterexample> errs; var outcome = vcgen.VerifyImplementation(impl, out errs); vcgen.Close(); return(outcome); }
public static VerificationResult VerifyImplementation(VC.ConditionGeneration vcgen, Implementation impl, Program prog, out SDiffCounterexamples cex, out List <Model> errModelList) { VerifyImplCleanup vic; vic = new VerifyImplCleanup(); vic.Visit(prog); cex = null; errModelList = null; if (impl == null) { Log.Out(Log.Urgent, "VerifyImplementation saw null implementation"); return(VerificationResult.Unknown); } //Log.Out(Log.Verifier, "Verifying implementation " + impl.Name); List <Counterexample> errors; List <Model> errorsModel; VerificationResult sdoutcome = VerificationResult.Unknown; VC.VCGen.Outcome outcome; //Log.Out(Log.Verifier, "Saving implementation before Boogie preprocessing"); var duper = new Duplicator(); var imperativeBlocks = new Dictionary <string, Block>(); foreach (Block b in impl.Blocks) { //new: to avoid repeated blocks (MYSTERY) if (!imperativeBlocks.ContainsKey(b.Label)) { imperativeBlocks.Add(b.Label, duper.VisitBlock(b)); } } try { var start = DateTime.Now; //outcome = vcgen.VerifyImplementation(impl, prog, out errors); outcome = vcgen.VerifyImplementation(impl, /*prog,*/ out errors, out errorsModel); errModelList = errorsModel; var end = DateTime.Now; TimeSpan elapsed = end - start; Console.WriteLine(string.Format(" [{0} s] ", elapsed.TotalSeconds)); } catch (VC.VCGenException e) { Log.Out(Log.Error, "Error BP5010: {0} Encountered in implementation {1}: " + e.Message); errors = null; outcome = VC.VCGen.Outcome.Inconclusive; } catch (UnexpectedProverOutputException upo) { Log.Out(Log.Error, "Advisory: {0} SKIPPED because of internal error: unexpected prover output: {1}" + upo.Message); errors = null; outcome = VC.VCGen.Outcome.Inconclusive; } catch (Exception e) { Log.Out(Log.Error, "Unknown error somewhere in verification: "); Log.Out(Log.Error, e.ToString()); return(VerificationResult.Unknown); } switch (outcome) { case VC.VCGen.Outcome.Correct: sdoutcome = VerificationResult.Verified; break; case VC.VCGen.Outcome.Errors: sdoutcome = VerificationResult.Error; break; case VC.VCGen.Outcome.Inconclusive: sdoutcome = VerificationResult.Inconclusive; break; case VC.VCGen.Outcome.OutOfMemory: sdoutcome = VerificationResult.OutOfMemory; break; case VC.VCGen.Outcome.TimedOut: sdoutcome = VerificationResult.TimeOut; break; } Log.Out(Log.Normal, outcome.ToString()); var eqVarName = ""; if (errors != null && errors.Count() == 1) { //eqVarName = errors[0]; } Log.Out(Log.Verifier, (errors == null ? 0 : errors.Count) + " counterexamples..."); if (errors != null) { cex = new SDiffCounterexamples(); for (int i = 0; i < errors.Count; i++) { if (Options.EnumerateAllPaths) { //just remove any time for this option cex.Add(new SDiffCounterexample(errors[i], null, impl)); continue; } //reconstruct trace in terms of imperative blocks var trace = ReconstructImperativeTrace(errors[i].Trace, imperativeBlocks); if (SymEx.TraceValidator.Validate(trace)) { Log.Out(Log.Cex, "Trace " + "[" + i + "]:"); Log.Out(Log.Cex, "Validating..."); Log.Out(Log.Cex, "Trace is not complete! Printing.."); SDiff.SymEx.CexDumper.PrintTrace(trace); continue; } else { //Log.Out(Log.Cex, "Trace OK"); if (Options.DumpValidTraces) { SDiff.SymEx.CexDumper.PrintTrace(trace); } } cex.Add(new SDiffCounterexample(errors[i], trace, impl)); } } return(sdoutcome); }