Beispiel #1
0
        /// <summary>
        /// Traverses the tree. Generates, resolves and verifies each leaf node until a
        /// valid proof is found
        /// </summary>
        /// <param name="solution_tree"></param>
        /// <returns></returns>
        private void VerifySolutionList()
        {
            List <Solution> final = new List <Solution>(); // list of verified solutions

            Microsoft.Dafny.Program program;
            foreach (var list in solution_list.GetFinal())
            {
                int index = 0;
                for (int i = 0; i < list.Count; i++)
                {
                    index = i;
                    var solution = list[i];
                    if (solution.isFinal)
                    {
                        final.Add(solution);
                        break;
                    }

                    program = tacnyProgram.ParseProgram();
                    solution.GenerateProgram(ref program);
                    tacnyProgram.MaybePrintProgram("debug" + i);
                    tacnyProgram.ClearBody(solution.state.globalContext.md);

                    tacnyProgram.VerifyProgram();

                    if (!tacnyProgram.HasError())
                    {
                        final.Add(solution);
                        break;
                    }
                    if (index == list.Count - 1)
                    {
                        final.Add(solution);
                    }
                }
            }


            program = tacnyProgram.ParseProgram();
            foreach (var solution in final)
            {
                solution.GenerateProgram(ref program);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Processes the file
        /// </summary>
        /// <param name="fileNames"></param>
        /// <param name="programId"></param>
        /// <returns></returns>
        static ExitValue ProcessFiles(IList <string /*!*/> /*!*/ fileNames, string programId = null)
        {
            //Contract.Requires(Tacny.tcce.NonNullElements(fileNames));

            if (programId == null)
            {
                programId = fileNames[0];
            }

            var exitValue = ExitValue.Verified;

            if (CommandLineOptions.Clo.VerifySeparately && 1 < fileNames.Count)
            {
                foreach (string f in fileNames)
                {
                    Console.WriteLine();
                    Console.WriteLine($"-------------------- {f} --------------------");
                    var ev = ProcessFiles(new List <string> {
                        f
                    }, f);
                    if (exitValue != ev && ev != ExitValue.Verified)
                    {
                        exitValue = ev;
                    }
                }
                return(exitValue);
            }

            using (new XmlFileScope(CommandLineOptions.Clo.XmlSink, fileNames[fileNames.Count - 1])) {
                Program tacnyProgram;
                string  programName = fileNames.Count == 1 ? fileNames[0] : "the program";
                // install Util.Printer
                try {
                    Debug.WriteLine("Initializing Tacny Program");
                    tacnyProgram = new Program(fileNames, programId);
                    // Initialize the printer
                    Printer.Install(fileNames[0]);
                    tacnyProgram.MaybePrintProgram(tacnyProgram.DafnyProgram, programName + "_src");
                } catch (ArgumentException ex) {
                    exitValue = ExitValue.DafnyError;
                    _printer.ErrorWriteLine(Console.Out, ex.Message);
                    return(exitValue);
                }


                var program = tacnyProgram.ParseProgram();
                int qq      = tacnyProgram.ResolveProgram(program);
                var md      = Interpreter.FindAndApplyTactic(tacnyProgram.ParseProgram(), ((ClassDecl)program.DefaultModuleDef.TopLevelDecls[0]).Members[0], null);
                Printer.P.GetConsolePrinter().PrintMethod(md as Method, 0, false);


                if (!CommandLineOptions.Clo.NoResolve && !CommandLineOptions.Clo.NoTypecheck && DafnyOptions.O.DafnyVerify)
                {
                    Debug.WriteLine("Starting lazy tactic evaluation");
                    LazyTacny.Interpreter r = new LazyTacny.Interpreter(tacnyProgram);
                    var prog = r.ResolveProgram();
                    tacnyProgram.PrintProgram(prog);
                    Debug.WriteLine("Fnished lazy tactic evaluation");
                }
                tacnyProgram.PrintAllDebugData(TacnyOptions.O.PrintCsv);
            }
            return(exitValue);
        }