public void VerifyProgram(Microsoft.Dafny.Program prog) { Debug.WriteLine("Verifying Dafny program"); IncCallsToBoogie(CurrentDebug); //disable Dafny output var cOut = Console.Out; // Console.SetOut(TextWriter.Null); double start = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds; var pl = new Pipeline(); Po = pl.VerifyProgram(prog, _fileNames, ProgramId, out Stats, out ErrList, out ErrorInfo); double end = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds; Console.SetOut(cOut); IncTimeAtBoogie(CurrentDebug, end - start); if (Stats.ErrorCount == 0) { Debug.WriteLine("Dafny program VERIFIED"); IncVerificationSuccess(CurrentDebug); } else { Debug.WriteLine("Dafny program NOT VERIFIED"); IncVerificationFailure(CurrentDebug); } }
public static List <Bpl.ErrorInformation> ResolveAndVerify(Program program, Bpl.ErrorReporterDelegate er) { Contract.Requires <ArgumentNullException>(program != null); var r = new Resolver(program); //var start = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds; r.ResolveProgram(program); //var end = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds var boogieProg = Translate(program, program.Name, er); Bpl.PipelineStatistics stats; List <Bpl.ErrorInformation> errorList; Bpl.PipelineOutcome tmp = BoogiePipeline(boogieProg, new List <string> { program.Name }, program.Name, er, out stats, out errorList, program); return(errorList); }
/// <summary> /// Pipeline the boogie program to Dafny where it is valid /// </summary> /// <returns>Exit value</returns> public static Bpl.PipelineOutcome BoogiePipeline(Bpl.Program program, IList <string> fileNames, string programId, Bpl.ErrorReporterDelegate er, out Bpl.PipelineStatistics stats, out List <Bpl.ErrorInformation> errorList, Program tmpDafnyProgram = null) { Contract.Requires(program != null); Contract.Ensures(0 <= Contract.ValueAtReturn(out stats).InconclusiveCount&& 0 <= Contract.ValueAtReturn(out stats).TimeoutCount); Bpl.LinearTypeChecker ltc; Bpl.CivlTypeChecker ctc; string baseName = cce.NonNull(Path.GetFileName(fileNames[fileNames.Count - 1])); baseName = cce.NonNull(Path.ChangeExtension(baseName, "bpl")); string bplFileName = Path.Combine(Path.GetTempPath(), baseName); errorList = new List <Bpl.ErrorInformation>(); stats = new Bpl.PipelineStatistics(); Bpl.PipelineOutcome oc = Bpl.ExecutionEngine.ResolveAndTypecheck(program, bplFileName, out ltc, out ctc); switch (oc) { case Bpl.PipelineOutcome.ResolvedAndTypeChecked: Bpl.ExecutionEngine.EliminateDeadVariables(program); Bpl.ExecutionEngine.CollectModSets(program); Bpl.ExecutionEngine.CoalesceBlocks(program); Bpl.ExecutionEngine.Inline(program); errorList = new List <Bpl.ErrorInformation>(); var tmp = new List <Bpl.ErrorInformation>(); oc = Bpl.ExecutionEngine.InferAndVerify(program, stats, programId, errorInfo => { tmp.Add(errorInfo); er?.Invoke(new CompoundErrorInformation(errorInfo.Tok, errorInfo.Msg, errorInfo, tmpDafnyProgram)); }); errorList.AddRange(tmp); return(oc); default: Contract.Assert(false); throw new cce.UnreachableException(); // unexpected outcome } }