Esempio n. 1
0
        public async Task <string?> VerifyAsync(Dafny.Program program, CancellationToken cancellationToken)
        {
            if (program.reporter.AllMessages[ErrorLevel.Error].Count > 0)
            {
                // TODO Change logic so that the loader is responsible to ensure that the previous steps were sucessful.
                _logger.LogDebug("skipping program verification since the parser or resolvers already reported errors");
                return(null);
            }
            await _mutex.WaitAsync(cancellationToken);

            try {
                // The printer is responsible for two things: It logs boogie errors and captures the counter example model.
                var errorReporter = program.reporter;
                var printer       = new ModelCapturingOutputPrinter(_logger, errorReporter);
                ExecutionEngine.printer = printer;
                var translated = Translator.Translate(program, errorReporter, new Translator.TranslatorFlags {
                    InsertChecksums = true
                });
                foreach (var(_, boogieProgram) in translated)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    VerifyWithBoogie(boogieProgram, cancellationToken);
                }
                return(printer.SerializedCounterExamples);
            } finally {
                _mutex.Release();
            }
        }
        public async Task <string?> VerifyAsyncRecordInfo(Dafny.Program program, CancellationToken cancellationToken)
        {
            if (program.reporter.AllMessages[ErrorLevel.Error].Count > 0)
            {
                // TODO Change logic so that the loader is responsible to ensure that the previous steps were sucessful.
                _logger.LogDebug("skipping program verification since the parser or resolvers already reported errors");
                return(null);
            }
            await _mutex.WaitAsync(cancellationToken);

            try {
                // The printer is responsible for two things: It logs boogie errors and captures the counter example model.
                var errorReporter = program.reporter;
                List <Tuple <string, string, string> > callableName = new List <Tuple <string, string, string> >();
                List <long> callableInfo = new List <long>();
                var         printer      = new ModelCapturingOutputPrinter(_logger, errorReporter, callableName, callableInfo);
                ExecutionEngine.printer = printer;
                var translated = Translator.Translate(program, errorReporter, new Translator.TranslatorFlags {
                    InsertChecksums = true
                });
                foreach (var(CompileName, boogieProgram) in translated)
                {
                    // Console.WriteLine("------------------ Compile name of current boogie program is: " + CompileName  + "---------");
                    cancellationToken.ThrowIfCancellationRequested();
                    VerifyWithBoogie(boogieProgram, cancellationToken);
                }

                /*
                 * Console.WriteLine(">>>>>>>>>>>>>> Callable Name Count: " + callableName.Count + "<<<<<<<<<<<<<<");
                 * Console.WriteLine(">>>>>>>>>>>>>> Callable Info Count: " + callableInfo.Count + "<<<<<<<<<<<<<<");
                 *
                 * for(int i = 0; i < callableName.Count; ++i){
                 * Console.WriteLine(">>>>>>>>>>> Callable #"+i+": " + callableName[i].Item1 + "." + callableName[i].Item2 + "." + callableName[i].Item3 + ", Status: " + callableInfo[i]);
                 * }*/
                return(printer.SerializedCounterExamples);
            } finally {
                _mutex.Release();
            }
        }
        public async Task <string?> VerifyAsyncRecordInfoSpecifyName(Dafny.Program program, CancellationToken cancellationToken,
                                                                     List <Tuple <string, string, string> > callableName, List <long> callableTime,
                                                                     string ModuleName, string ClassName, string LemmaName)
        {
            if (program.reporter.AllMessages[ErrorLevel.Error].Count > 0)
            {
                // TODO Change logic so that the loader is responsible to ensure that the previous steps were sucessful.
                _logger.LogDebug("skipping program verification since the parser or resolvers already reported errors");
                return(null);
            }
            await _mutex.WaitAsync(cancellationToken);

            try {
                string toBeChecked = "*" + ModuleName + "." + ClassName + "." + LemmaName;
                DafnyOptions.O.procsToCheck.Add(toBeChecked);
                // Console.WriteLine(">>>>>>>>>>>> Specify: " + toBeChecked);
                // Console.WriteLine("User Constrained Procs To Check?" + DafnyOptions.O.UserConstrainedProcsToCheck);

                // The printer is responsible for two things: It logs boogie errors and captures the counter example model.
                var errorReporter = program.reporter;
                var printer       = new ModelCapturingOutputPrinter(_logger, errorReporter, callableName, callableTime);
                ExecutionEngine.printer = printer;
                var translated = Translator.Translate(program, errorReporter, new Translator.TranslatorFlags {
                    InsertChecksums = true
                });
                foreach (var(CompileName, boogieProgram) in translated)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    VerifyWithBoogie(boogieProgram, cancellationToken);
                }
                if (DafnyOptions.O.procsToCheck.Count > 0)
                {
                    DafnyOptions.O.procsToCheck.RemoveAt(DafnyOptions.O.procsToCheck.Count - 1);
                }
                return(printer.SerializedCounterExamples);
            } finally {
                _mutex.Release();
            }
        }