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 bool ExchangeRefutedAnnotations() { int count = 0; if (CommandLineOptions.Clo.DebugConcurrentHoudini) { Console.WriteLine("# number of shared refuted annotations: " + refutedSharedAnnotations.Count); } foreach (string key in refutedSharedAnnotations.Keys) { KeyValuePair <Variable, bool> kv = currentHoudiniState.Assignment.FirstOrDefault(entry => entry.Key.Name.Equals(key) && entry.Value); if (kv.Key != null) { RefutedAnnotation ra = null; Implementation refutationSite = null; foreach (var r in program.Implementations) { if (r.Name.Equals(refutedSharedAnnotations[key].RefutationSite.Name)) { refutationSite = r; break; } } Debug.Assert(refutationSite != null); if (refutedSharedAnnotations[key].Kind == RefutedAnnotationKind.REQUIRES) { Procedure proc = null; foreach (var p in program.Procedures) { if (p.Name.Equals(refutedSharedAnnotations[key].CalleeProc.Name)) { proc = p; break; } } Debug.Assert(proc != null); ra = RefutedAnnotation.BuildRefutedRequires(kv.Key, proc, refutationSite); } else if (refutedSharedAnnotations[key].Kind == RefutedAnnotationKind.ENSURES) { ra = RefutedAnnotation.BuildRefutedEnsures(kv.Key, refutationSite); } else if (refutedSharedAnnotations[key].Kind == RefutedAnnotationKind.ASSERT) { ra = RefutedAnnotation.BuildRefutedAssert(kv.Key, refutationSite); } Debug.Assert(ra != null); if (CommandLineOptions.Clo.DebugConcurrentHoudini) { Console.WriteLine("(+) " + ra.Constant + "," + ra.Kind + "," + ra.CalleeProc + "," + ra.RefutationSite); } AddRelatedToWorkList(ra); UpdateAssignment(ra); count++; } } return(count > 0 ? true : false); }
protected override void ShareRefutedAnnotation(RefutedAnnotation refutedAnnotation) { refutedSharedAnnotations.TryAdd(refutedAnnotation.Constant.Name, refutedAnnotation); }
protected override void ShareRefutedAnnotation(RefutedAnnotation refutedAnnotation) { refutedSharedAnnotations.TryAdd(refutedAnnotation.Constant.Name, refutedAnnotation); }
protected override bool UpdateAssignmentWorkList(ProverInterface.Outcome outcome, List <Counterexample> errors) { Contract.Assume(currentHoudiniState.Implementation != null); bool dequeue = true; switch (outcome) { case ProverInterface.Outcome.Valid: //yeah, dequeue break; case ProverInterface.Outcome.Invalid: Contract.Assume(errors != null); foreach (Counterexample error in errors) { RefutedAnnotation refutedAnnotation = ExtractRefutedAnnotation(error); // some candidate annotation removed if (refutedAnnotation != null) { refutedSharedAnnotations.TryAdd(refutedAnnotation.Constant.Name, refutedAnnotation); AddRelatedToWorkList(refutedAnnotation); UpdateAssignment(refutedAnnotation); dequeue = false; #region Extra debugging output if (CommandLineOptions.Clo.Trace) { using (var cexWriter = new System.IO.StreamWriter(cexTraceFile, true)) { cexWriter.WriteLine("Counter example for " + refutedAnnotation.Constant); cexWriter.Write(error.ToString()); cexWriter.WriteLine(); using (var writer = new Microsoft.Boogie.TokenTextWriter(cexWriter)) foreach (Microsoft.Boogie.Block blk in error.Trace) { blk.Emit(writer, 15); } //cexWriter.WriteLine(); } } #endregion } } if (ExchangeRefutedAnnotations()) { dequeue = false; } break; default: if (CommandLineOptions.Clo.Trace) { Console.WriteLine("Timeout/Spaceout while verifying " + currentHoudiniState.Implementation.Name); } HoudiniSession houdiniSession; houdiniSessions.TryGetValue(currentHoudiniState.Implementation, out houdiniSession); foreach (Variable v in houdiniSession.houdiniAssertConstants) { if (CommandLineOptions.Clo.Trace) { Console.WriteLine("Removing " + v); } currentHoudiniState.Assignment.Remove(v); currentHoudiniState.Assignment.Add(v, false); this.NotifyConstant(v.Name); } currentHoudiniState.addToBlackList(currentHoudiniState.Implementation.Name); break; } return(dequeue); }