예제 #1
0
        void Print()
        {
            List <Block> tmp = impl.Blocks;

            Contract.Assert(tmp != null);
            impl.Blocks = blocks;
            ConditionGeneration.EmitImpl(impl, false);
            impl.Blocks = tmp;
        }
예제 #2
0
        private static ResultCounter VerifyProgram(Program program)
        {
            var counters = new ResultCounter();

            ConditionGeneration vcgen = null;

            try {
                vcgen = new VCGen(program, CommandLineOptions.Clo.SimplifyLogFilePath, CommandLineOptions.Clo.SimplifyLogFileAppend, new List <Checker>());
            }
            catch (ProverException e) {
                GVUtil.IO.ErrorWriteLine("Fatal Error: ProverException: {0}", e);
                return(ResultCounter.GetNewCounterWithInternalError());
            }

            // operate on a stable copy, in case it gets updated while we're running
            var decls = program.TopLevelDeclarations.ToArray();

            foreach (Declaration decl in decls)
            {
                Contract.Assert(decl != null);

                int prevAssertionCount = vcgen.CumulativeAssertionCount;

                Implementation impl = decl as Implementation;
                if (impl != null && CommandLineOptions.Clo.UserWantsToCheckRoutine(cce.NonNull(impl.Name)) && !impl.SkipVerification)
                {
                    List <Counterexample /*!*/> /*?*/ errors;

                    DateTime start = new DateTime(); // to please compiler's definite assignment rules
                    if (CommandLineOptions.Clo.Trace)
                    {
                        start = DateTime.UtcNow;
                        if (CommandLineOptions.Clo.Trace)
                        {
                            Console.WriteLine();
                            Console.WriteLine("Verifying {0} ...", impl.Name);
                        }
                    }

                    VCGen.Outcome outcome;
                    try {
                        outcome = vcgen.VerifyImplementation(impl, out errors);
                    }
                    catch (VCGenException e) {
                        GVUtil.IO.ReportBplError(impl, string.Format("Error BP5010: {0}  Encountered in implementation {1}.", e.Message, impl.Name), true, true);
                        errors  = null;
                        outcome = VCGen.Outcome.Inconclusive;
                    }
                    catch (UnexpectedProverOutputException upo) {
                        GVUtil.IO.AdvisoryWriteLine("Advisory: {0} SKIPPED because of internal error: unexpected prover output: {1}", impl.Name, upo.Message);
                        errors  = null;
                        outcome = VCGen.Outcome.Inconclusive;
                    }

                    string   timeIndication = "";
                    DateTime end            = DateTime.UtcNow;
                    TimeSpan elapsed        = end - start;
                    if (CommandLineOptions.Clo.Trace)
                    {
                        int poCount = vcgen.CumulativeAssertionCount - prevAssertionCount;
                        timeIndication = string.Format("  [{0:F3} s, {1} proof obligation{2}]  ", elapsed.TotalSeconds, poCount, poCount == 1 ? "" : "s");
                    }
                    KernelAnalyser.ProcessOutcome(program, impl.Name, outcome, errors, timeIndication, ref counters);

                    if (outcome == VCGen.Outcome.Errors || CommandLineOptions.Clo.Trace)
                    {
                        Console.Out.Flush();
                    }
                }
            }

            vcgen.Close();
            cce.NonNull(CommandLineOptions.Clo.TheProverFactory).Close();

            GVUtil.IO.WriteTrailer(counters);
            return(counters);
        }
예제 #3
0
 public VerificationResult(string requestId, string checksum, string depsChecksum, ConditionGeneration.Outcome outcome, List<Counterexample> errors)
     : this(requestId, checksum, depsChecksum)
 {
     Outcome = outcome;
       Errors = errors;
 }