public ConcurrentHoudini(int taskId, Program program, HoudiniSession.HoudiniStatistics stats, string cexTraceFile = "houdiniCexTrace.txt") { Contract.Assert(taskId >= 0); this.program = program; this.cexTraceFile = cexTraceFile; this.taskID = taskId; Initialize(program, stats); }
public ConcurrentHoudini(int id, Program program, HoudiniSession.HoudiniStatistics stats, string cexTraceFile = "houdiniCexTrace.bpl") { Contract.Assert(id >= 0); this.id = id; this.program = program; this.cexTraceFile = cexTraceFile; if (CommandLineOptions.Clo.Trace) Console.WriteLine("Collecting existential constants..."); this.houdiniConstants = CollectExistentialConstants(); if (CommandLineOptions.Clo.Trace) Console.WriteLine("Building call graph..."); this.callGraph = Program.BuildCallGraph(program); if (CommandLineOptions.Clo.Trace) Console.WriteLine("Number of implementations = {0}", callGraph.Nodes.Count); if (CommandLineOptions.Clo.HoudiniUseCrossDependencies) { if (CommandLineOptions.Clo.Trace) Console.WriteLine("Computing procedure cross dependencies ..."); this.crossDependencies = new CrossDependencies(this.houdiniConstants); this.crossDependencies.Visit(program); } Inline(); this.vcgen = new VCGen(program, CommandLineOptions.Clo.SimplifyLogFilePath, CommandLineOptions.Clo.SimplifyLogFileAppend, new List<Checker>()); this.proverInterface = ProverInterface.CreateProver(program, CommandLineOptions.Clo.SimplifyLogFilePath, CommandLineOptions.Clo.SimplifyLogFileAppend, CommandLineOptions.Clo.ProverKillTime, id); vcgenFailures = new HashSet<Implementation>(); Dictionary<Implementation, HoudiniSession> houdiniSessions = new Dictionary<Implementation, HoudiniSession>(); if (CommandLineOptions.Clo.Trace) Console.WriteLine("Beginning VC generation for Houdini..."); foreach (Implementation impl in callGraph.Nodes) { try { if (CommandLineOptions.Clo.Trace) Console.WriteLine("Generating VC for {0}", impl.Name); HoudiniSession session = new HoudiniSession(this, vcgen, proverInterface, program, impl, stats, taskID: id); houdiniSessions.Add(impl, session); } catch (VCGenException) { if (CommandLineOptions.Clo.Trace) Console.WriteLine("VC generation failed"); vcgenFailures.Add(impl); } } this.houdiniSessions = new ReadOnlyDictionary<Implementation, HoudiniSession>(houdiniSessions); if (CommandLineOptions.Clo.ExplainHoudini) { // Print results of ExplainHoudini to a dotty file explainHoudiniDottyFile = new StreamWriter("explainHoudini.dot"); explainHoudiniDottyFile.WriteLine("digraph explainHoudini {"); foreach (var constant in houdiniConstants) explainHoudiniDottyFile.WriteLine("{0} [ label = \"{0}\" color=black ];", constant.Name); explainHoudiniDottyFile.WriteLine("TimeOut [label = \"TimeOut\" color=red ];"); } }
protected override void HoudiniVerifyCurrent(HoudiniSession session, int stage, IEnumerable <int> completedStages) { while (true) { this.NotifyAssignment(currentHoudiniState.Assignment); //check the VC with the current assignment List <Counterexample> errors; ProverInterface.Outcome outcome = TryCatchVerify(session, stage, completedStages, out errors); this.NotifyOutcome(outcome); DebugRefutedCandidates(currentHoudiniState.Implementation, errors); #region Explain Houdini if (CommandLineOptions.Clo.ExplainHoudini && outcome == ProverInterface.Outcome.Invalid) { Contract.Assume(errors != null); // make a copy of this variable errors = new List <Counterexample>(errors); var refutedAnnotations = new List <RefutedAnnotation>(); foreach (Counterexample error in errors) { RefutedAnnotation refutedAnnotation = ExtractRefutedAnnotation(error); if (refutedAnnotation == null || refutedAnnotation.Kind == RefutedAnnotationKind.ASSERT) { continue; } refutedAnnotations.Add(refutedAnnotation); } foreach (var refutedAnnotation in refutedAnnotations) { session.Explain(proverInterface, currentHoudiniState.Assignment, refutedAnnotation.Constant); } } #endregion if (UpdateHoudiniOutcome(currentHoudiniState.Outcome, currentHoudiniState.Implementation, outcome, errors)) // abort { currentHoudiniState.WorkQueue.Dequeue(); this.NotifyDequeue(); FlushWorkList(stage, completedStages); return; } else if (UpdateAssignmentWorkList(outcome, errors)) { if (CommandLineOptions.Clo.UseUnsatCoreForContractInfer && outcome == ProverInterface.Outcome.Valid) { session.UpdateUnsatCore(proverInterface, currentHoudiniState.Assignment); } currentHoudiniState.WorkQueue.Dequeue(); this.NotifyDequeue(); return; } } }
protected override ProverInterface.Outcome TryCatchVerify(HoudiniSession session, int stage, IEnumerable <int> completedStages, out List <Counterexample> errors) { ProverInterface.Outcome outcome; try { outcome = session.Verify(proverInterface, GetAssignmentWithStages(stage, completedStages), out errors, taskID: id); } catch (UnexpectedProverOutputException upo) { Contract.Assume(upo != null); errors = null; outcome = ProverInterface.Outcome.Undetermined; } return(outcome); }
public ConcurrentHoudini(int id, Program program, HoudiniSession.HoudiniStatistics stats, string cexTraceFile = "houdiniCexTrace.bpl") { Contract.Assert(id >= 0); this.id = id; this.program = program; this.cexTraceFile = cexTraceFile; if (CommandLineOptions.Clo.Trace) { Console.WriteLine("Collecting existential constants..."); } this.houdiniConstants = CollectExistentialConstants(); if (CommandLineOptions.Clo.Trace) { Console.WriteLine("Building call graph..."); } this.callGraph = Program.BuildCallGraph(program); if (CommandLineOptions.Clo.Trace) { Console.WriteLine("Number of implementations = {0}", callGraph.Nodes.Count); } if (CommandLineOptions.Clo.HoudiniUseCrossDependencies) { if (CommandLineOptions.Clo.Trace) { Console.WriteLine("Computing procedure cross dependencies ..."); } this.crossDependencies = new CrossDependencies(this.houdiniConstants); this.crossDependencies.Visit(program); } Inline(); this.vcgen = new VCGen(program, CommandLineOptions.Clo.SimplifyLogFilePath, CommandLineOptions.Clo.SimplifyLogFileAppend, new List <Checker>()); this.proverInterface = ProverInterface.CreateProver(program, CommandLineOptions.Clo.SimplifyLogFilePath, CommandLineOptions.Clo.SimplifyLogFileAppend, CommandLineOptions.Clo.ProverKillTime, id); vcgenFailures = new HashSet <Implementation>(); Dictionary <Implementation, HoudiniSession> houdiniSessions = new Dictionary <Implementation, HoudiniSession>(); if (CommandLineOptions.Clo.Trace) { Console.WriteLine("Beginning VC generation for Houdini..."); } foreach (Implementation impl in callGraph.Nodes) { try { if (CommandLineOptions.Clo.Trace) { Console.WriteLine("Generating VC for {0}", impl.Name); } HoudiniSession session = new HoudiniSession(this, vcgen, proverInterface, program, impl, stats, taskID: id); houdiniSessions.Add(impl, session); } catch (VCGenException) { if (CommandLineOptions.Clo.Trace) { Console.WriteLine("VC generation failed"); } vcgenFailures.Add(impl); } } this.houdiniSessions = new ReadOnlyDictionary <Implementation, HoudiniSession>(houdiniSessions); if (CommandLineOptions.Clo.ExplainHoudini) { // Print results of ExplainHoudini to a dotty file explainHoudiniDottyFile = new StreamWriter("explainHoudini.dot"); explainHoudiniDottyFile.WriteLine("digraph explainHoudini {"); foreach (var constant in houdiniConstants) { explainHoudiniDottyFile.WriteLine("{0} [ label = \"{0}\" color=black ];", constant.Name); } explainHoudiniDottyFile.WriteLine("TimeOut [label = \"TimeOut\" color=red ];"); } }
protected override ProverInterface.Outcome TryCatchVerify(HoudiniSession session, int stage, IEnumerable<int> completedStages, out List<Counterexample> errors) { ProverInterface.Outcome outcome; try { outcome = session.Verify(proverInterface, GetAssignmentWithStages(stage, completedStages), out errors, taskID: id); } catch (UnexpectedProverOutputException upo) { Contract.Assume(upo != null); errors = null; outcome = ProverInterface.Outcome.Undetermined; } return outcome; }
protected override void HoudiniVerifyCurrent(HoudiniSession session, int stage, IEnumerable<int> completedStages) { while (true) { this.NotifyAssignment(currentHoudiniState.Assignment); //check the VC with the current assignment List<Counterexample> errors; ProverInterface.Outcome outcome = TryCatchVerify(session, stage, completedStages, out errors); this.NotifyOutcome(outcome); DebugRefutedCandidates(currentHoudiniState.Implementation, errors); #region Explain Houdini if (CommandLineOptions.Clo.ExplainHoudini && outcome == ProverInterface.Outcome.Invalid) { Contract.Assume(errors != null); // make a copy of this variable errors = new List<Counterexample>(errors); var refutedAnnotations = new List<RefutedAnnotation>(); foreach (Counterexample error in errors) { RefutedAnnotation refutedAnnotation = ExtractRefutedAnnotation(error); if (refutedAnnotation == null || refutedAnnotation.Kind == RefutedAnnotationKind.ASSERT) continue; refutedAnnotations.Add(refutedAnnotation); } foreach (var refutedAnnotation in refutedAnnotations) { session.Explain(proverInterface, currentHoudiniState.Assignment, refutedAnnotation.Constant); } } #endregion if (UpdateHoudiniOutcome(currentHoudiniState.Outcome, currentHoudiniState.Implementation, outcome, errors)) { // abort currentHoudiniState.WorkQueue.Dequeue(); this.NotifyDequeue(); FlushWorkList(stage, completedStages); return; } else if (UpdateAssignmentWorkList(outcome, errors)) { if (CommandLineOptions.Clo.UseUnsatCoreForContractInfer && outcome == ProverInterface.Outcome.Valid) session.UpdateUnsatCore(proverInterface, currentHoudiniState.Assignment); currentHoudiniState.WorkQueue.Dequeue(); this.NotifyDequeue(); return; } } }