示例#1
0
        private HoudiniOutcome UnifyOutcomes()
        {
            HoudiniOutcome result          = new HoudiniOutcome();
            var            scheduledStages = outcomes.Keys.ToList();

            result.assignment = new Dictionary <string, bool>();
            foreach (var c in outcomes[scheduledStages[0]].assignment.Keys)
            {
                result.assignment[c] = outcomes.Select(Item => Item.Value).Select(Item => Item.assignment[c]).All(Item => Item);
            }

            result.implementationOutcomes = new Dictionary <string, VCGenOutcome>();
            foreach (var p in outcomes[scheduledStages[0]].implementationOutcomes.Keys)
            {
                var unifiedImplementationOutcome = outcomes[scheduledStages[0]].implementationOutcomes[p];
                for (int i = 1; i < scheduledStages.Count(); i++)
                {
                    unifiedImplementationOutcome = ChooseOutcome(unifiedImplementationOutcome,
                                                                 outcomes[scheduledStages[i]].implementationOutcomes[p]);
                }

                result.implementationOutcomes[p] = unifiedImplementationOutcome;
            }

            return(result);
        }
示例#2
0
        private void ExecuteStage(ScheduledStage s)
        {
            Task.WaitAll(tasks.Where(
                             Item => plan.GetDependences(s).Contains(Item.stage)).
                         Select(Item => Item.parallelTask).ToArray());

            if (s.Count() == 0)
            {
                // This is the trivial first stage, so don't launch Houdini;
                // give this a null outcome
                return;
            }

            List <Houdini> h = AcquireHoudiniInstance();

            if (h.Count() == 0)
            {
                h.Add(new Houdini(ProgramFromFile(tempFilename), new HoudiniSession.HoudiniStatistics(), "houdiniCexTrace_" + s.GetId() + ".txt"));
            }

            System.Diagnostics.Debug.Assert(h.Count() == 1);

            Dictionary <string, bool> mergedAssignment = null;

            List <Dictionary <string, bool> > relevantAssignments;
            IEnumerable <int> completedStages;

            lock (outcomes)
            {
                relevantAssignments =
                    outcomes.Where(Item => plan.Contains(Item.Key)).
                    Select(Item => Item.Value).
                    Select(Item => Item.assignment).ToList();
                completedStages = plan.GetDependences(s).Select(Item => Item.GetId());
            }

            if (relevantAssignments.Count() > 0)
            {
                mergedAssignment = new Dictionary <string, bool>();
                foreach (var v in relevantAssignments[0].Keys)
                {
                    mergedAssignment[v] = relevantAssignments.Select(Item => Item[v]).ToList().All(Item => Item);
                }
            }

            HoudiniOutcome outcome = h[0].PerformHoudiniInference(
                s.GetId(),
                completedStages,
                mergedAssignment);

            lock (outcomes)
            {
                outcomes[s] = outcome;
            }

            ReleaseHoudiniInstance(h);
        }
示例#3
0
        private void ApplyInvariants(ref HoudiniOutcome outcome)
        {
            if (this.Houdini != null)
            {
                Houdini.ApplyAssignment(this.PostAC.Program, outcome);
//         this.Houdini.ApplyAssignment(this.PostAC.Program);
                this.Houdini.Close();
                WhoopCruncherCommandLineOptions.Get().TheProverFactory.Close();
            }
        }
示例#4
0
 private bool AllImplementationsValid(HoudiniOutcome outcome)
 {
     foreach (var vcgenOutcome in outcome.implementationOutcomes.Values.Select(i => i.outcome))
     {
         if (vcgenOutcome != VC.VCGen.Outcome.Correct)
         {
             return(false);
         }
     }
     return(true);
 }
示例#5
0
        private void PerformHoudini()
        {
            var houdiniStats = new HoudiniSession.HoudiniStatistics();

            GC.Collect();

            try
            {
                this.Houdini = new Houdini(this.AC.BoogieProgram, houdiniStats);
                this.Outcome = this.Houdini.PerformHoudiniInference();
            }
            catch (OutOfMemoryException)
            {
                Lockpwn.IO.Reporter.WarningWriteLine("Warning: Houdini run out of memory");
                GC.Collect();
                throw new AnalysisFailedException();
            }
            catch (Exception ex)
            {
                Lockpwn.IO.Reporter.WarningWriteLine("Warning: Houdini failed: " + ex.Message);
                GC.Collect();
                throw new AnalysisFailedException();
            }

            if (CommandLineOptions.Clo.PrintAssignment)
            {
                Output.PrintLine("..... Assignment computed by Houdini:");
                foreach (var x in this.Outcome.assignment)
                {
                    Output.PrintLine(x.Key + " = " + x.Value);
                }
            }

            if (ToolCommandLineOptions.Get().SuperVerboseMode)
            {
                int numTrueAssigns = 0;
                foreach (var x in this.Outcome.assignment)
                {
                    if (x.Value)
                    {
                        numTrueAssigns++;
                    }
                }

                Output.PrintLine("..... Number of true assignments = " + numTrueAssigns);
                Output.PrintLine("..... Number of false assignments = " + (this.Outcome.assignment.Count - numTrueAssigns));
                Output.PrintLine("..... Prover time = " + houdiniStats.proverTime.ToString("F2"));
                Output.PrintLine("..... Unsat core prover time = " + houdiniStats.unsatCoreProverTime.ToString("F2"));
                Output.PrintLine("..... Number of prover queries = " + houdiniStats.numProverQueries);
                Output.PrintLine("..... Number of unsat core prover queries = " + houdiniStats.numUnsatCoreProverQueries);
                Output.PrintLine("..... Number of unsat core prunings = " + houdiniStats.numUnsatCorePrunings);
            }
        }
示例#6
0
        public void Run()
        {
            this.AC.EliminateDeadVariables();
            this.AC.Inline();

            if (WhoopCruncherCommandLineOptions.Get().MeasurePassExecutionTime)
            {
                Console.WriteLine(" |------ [{0}]", this.EP.Name);
                Console.WriteLine(" |  |");
                this.Timer = new ExecutionTimer();
                this.Timer.Start();
            }

            HoudiniOutcome outcome = null;

            this.PerformHoudini(ref outcome);
            this.ApplyInvariants(ref outcome);

            this.AC.ResetToProgramTopLevelDeclarations();

            ModelCleaner.RemoveGenericTopLevelDeclerations(this.PostAC, this.EP);
            ModelCleaner.RemoveUnusedTopLevelDeclerations(this.AC);
            ModelCleaner.RemoveGlobalLocksets(this.PostAC);
            ModelCleaner.RemoveExistentials(this.PostAC);

            if (!(WhoopCruncherCommandLineOptions.Get().InliningBound > 0 &&
                  this.AC.GetNumOfEntryPointRelatedFunctions(this.EP.Name) <=
                  WhoopCruncherCommandLineOptions.Get().InliningBound))
            {
                ModelCleaner.RemoveWhoopFunctions(this.PostAC);
                ModelCleaner.RemoveConstants(this.PostAC);
                ModelCleaner.RemoveImplementations(this.PostAC);
            }

            if (WhoopCruncherCommandLineOptions.Get().MeasurePassExecutionTime)
            {
                this.Timer.Stop();
                Console.WriteLine(" |  |");
                Console.WriteLine(" |  |--- [Total] {0}", this.Timer.Result());
                Console.WriteLine(" |");
            }

            Whoop.IO.BoogieProgramEmitter.Emit(this.PostAC.TopLevelDeclarations, WhoopCruncherCommandLineOptions.Get().Files[
                                                   WhoopCruncherCommandLineOptions.Get().Files.Count - 1], this.EP.Name + "$summarised", "wbpl");
        }
示例#7
0
        private void PerformHoudini(ref HoudiniOutcome outcome)
        {
            var houdiniStats = new HoudiniSession.HoudiniStatistics();

            this.Houdini = new Houdini(this.AC.Program, houdiniStats);
            outcome      = this.Houdini.PerformHoudiniInference();

            if (CommandLineOptions.Clo.PrintAssignment)
            {
                Console.WriteLine("Assignment computed by Houdini:");
                foreach (var x in outcome.assignment)
                {
                    Console.WriteLine(x.Key + " = " + x.Value);
                }
            }

            if (CommandLineOptions.Clo.Trace)
            {
                int numTrueAssigns = 0;
                foreach (var x in outcome.assignment)
                {
                    if (x.Value)
                    {
                        numTrueAssigns++;
                    }
                }

                Console.WriteLine("Number of true assignments = " + numTrueAssigns);
                Console.WriteLine("Number of false assignments = " + (outcome.assignment.Count - numTrueAssigns));
                Console.WriteLine("Prover time = " + houdiniStats.proverTime.ToString("F2"));
                Console.WriteLine("Unsat core prover time = " + houdiniStats.unsatCoreProverTime.ToString("F2"));
                Console.WriteLine("Number of prover queries = " + houdiniStats.numProverQueries);
                Console.WriteLine("Number of unsat core prover queries = " + houdiniStats.numUnsatCoreProverQueries);
                Console.WriteLine("Number of unsat core prunings = " + houdiniStats.numUnsatCorePrunings);
            }
        }
示例#8
0
        private void PerformHoudini()
        {
            var houdiniStats = new HoudiniSession.HoudiniStatistics();

            this.Houdini = new Houdini(this.AC.BoogieProgram, houdiniStats);
            this.Outcome = this.Houdini.PerformHoudiniInference();

            if (CommandLineOptions.Clo.PrintAssignment)
            {
                Output.PrintLine("..... Assignment computed by Houdini:");
                foreach (var x in this.Outcome.assignment)
                {
                    Output.PrintLine(x.Key + " = " + x.Value);
                }
            }

            if (ToolCommandLineOptions.Get().SuperVerboseMode)
            {
                int numTrueAssigns = 0;
                foreach (var x in this.Outcome.assignment)
                {
                    if (x.Value)
                    {
                        numTrueAssigns++;
                    }
                }

                Output.PrintLine("..... Number of true assignments = " + numTrueAssigns);
                Output.PrintLine("..... Number of false assignments = " + (this.Outcome.assignment.Count - numTrueAssigns));
                Output.PrintLine("..... Prover time = " + houdiniStats.proverTime.ToString("F2"));
                Output.PrintLine("..... Unsat core prover time = " + houdiniStats.unsatCoreProverTime.ToString("F2"));
                Output.PrintLine("..... Number of prover queries = " + houdiniStats.numProverQueries);
                Output.PrintLine("..... Number of unsat core prover queries = " + houdiniStats.numUnsatCoreProverQueries);
                Output.PrintLine("..... Number of unsat core prunings = " + houdiniStats.numUnsatCorePrunings);
            }
        }