bool ReCheckImpl(Variable reachvar, Implementation impl, VerifierCallback callback, out ProverInterface.Outcome outcome) { Contract.Requires(reachvar != null); Contract.Requires(impl != null); Contract.Requires(callback != null); Checker checker = FindCheckerFor(impl, 1000); Contract.Assert(checker != null); DoomCheck dc = new DoomCheck(impl, this.exitBlock, checker, m_UncheckableBlocks); dc.ErrorHandler = new DoomErrorHandler(dc.Label2Absy, callback); outcome = ProverInterface.Outcome.Undetermined; List <Variable> rv = new List <Variable>(); rv.Add(reachvar); if (!dc.CheckLabel(rv, null, out outcome)) { checker.Close(); return(false); } checker.Close(); return(true); }
bool ReCheckImpl(Variable reachvar, Implementation impl, VerifierCallback callback, out ProverInterface.Outcome outcome) { Contract.Requires(reachvar != null); Contract.Requires(impl != null); Contract.Requires(callback != null); Checker checker = FindCheckerFor(impl, 1000); Contract.Assert(checker != null); DoomCheck dc = new DoomCheck(impl, this.exitBlock, checker, m_UncheckableBlocks); dc.ErrorHandler = new DoomErrorHandler(dc.Label2Absy, callback); outcome = ProverInterface.Outcome.Undetermined; List<Variable> rv = new List<Variable>(); rv.Add(reachvar); if (!dc.CheckLabel(rv,null, out outcome)) { checker.Close(); return false; } checker.Close(); return true; }
/// <summary> /// MSchaef: /// - remove loops and add reach variables /// - make it a passive program /// - compute the wlp for each block /// - check if |= (reach=false) => wlp.S.false holds for each reach /// /// </summary> public override Outcome VerifyImplementation(Implementation impl, VerifierCallback callback) { Contract.EnsuresOnThrow<UnexpectedProverOutputException>(true); Console.WriteLine(); Console.WriteLine("Checking function {0}", impl.Name); callback.OnProgress("doomdetector", 0, 0, 0); bool restartTP = CommandLineOptions.Clo.DoomRestartTP ; //Impl2Dot(impl, String.Format("c:/dot/{0}_orig.dot", impl.Name)); Transform4DoomedCheck(impl); //Impl2Dot(impl, String.Format("c:/dot/{0}_fin.dot", impl.Name)); Checker checker = FindCheckerFor(1000); Contract.Assert(checker != null); int assertionCount; DoomCheck dc = new DoomCheck(impl, this.exitBlock, checker, m_UncheckableBlocks, out assertionCount); CumulativeAssertionCount += assertionCount; //EmitImpl(impl, false); int _totalchecks = 0; ProverInterface.Outcome outcome; dc.ErrorHandler = new DoomErrorHandler(dc.Label2Absy, callback); System.TimeSpan ts = new TimeSpan(); if (_print_time) Console.WriteLine("Total number of blocks {0}", impl.Blocks.Count); List<Block> lb; List<Variable> lv = new List<Variable>(); while (dc.GetNextBlock(out lb)) { Contract.Assert(lb != null); outcome = ProverInterface.Outcome.Undetermined; Variable v = null; lv.Clear(); foreach (Block b_ in lb) { if (!m_BlockReachabilityMap.TryGetValue(b_, out v)) { // This should cause an error continue; } //Console.Write("{0}, ",b_.Label); lv.Add(v); } //Console.WriteLine(); Dictionary<Expr, int> finalreachvars = m_GetPostconditionVariables(impl.Blocks,lb); if (lv.Count < 1) { continue; } Contract.Assert(lv != null); _totalchecks++; if (!dc.CheckLabel(lv,finalreachvars, out outcome)) { return Outcome.Inconclusive; } ts += dc.DEBUG_ProverTime.Elapsed; if (restartTP) { checker.Close(); checker = FindCheckerFor(1000); dc.RespawnChecker(impl, checker); dc.ErrorHandler = new DoomErrorHandler(dc.Label2Absy, callback); } } checker.Close(); if (_print_time) { Console.WriteLine("Number of Checkes / #Blocks: {0} of {1}", _totalchecks, impl.Blocks.Count); dc.__DEBUG_PrintStatistics(); Console.WriteLine("Total time for this method: {0}", ts.ToString()); } #region Try to produce a counter example (brute force) if (dc.DoomedSequences.Count > 0) { int counter = 0; List<Block> _all = new List<Block>(); foreach (List<Block> lb_ in dc.DoomedSequences) { foreach (Block b_ in lb_) { if (!_all.Contains(b_) && !m_UncheckableBlocks.Contains(b_)) { _all.Add(b_); counter++; if (!_print_time) Console.WriteLine(b_.Label); } } } if (_all.Count > 0) { Console.WriteLine("#Dead Blocks found: {0}: ", counter); return Outcome.Errors; } } #endregion return Outcome.Correct; }
/// <summary> /// MSchaef: /// - remove loops and add reach variables /// - make it a passive program /// - compute the wlp for each block /// - check if |= (reach=false) => wlp.S.false holds for each reach /// /// </summary> public override Outcome VerifyImplementation(Implementation impl, VerifierCallback callback) { Contract.EnsuresOnThrow <UnexpectedProverOutputException>(true); Console.WriteLine(); Console.WriteLine("Checking function {0}", impl.Name); callback.OnProgress("doomdetector", 0, 0, 0); bool restartTP = CommandLineOptions.Clo.DoomRestartTP; //Impl2Dot(impl, String.Format("c:/dot/{0}_orig.dot", impl.Name)); Transform4DoomedCheck(impl); //Impl2Dot(impl, String.Format("c:/dot/{0}_fin.dot", impl.Name)); Checker checker = FindCheckerFor(1000); Contract.Assert(checker != null); int assertionCount; DoomCheck dc = new DoomCheck(impl, this.exitBlock, checker, m_UncheckableBlocks, out assertionCount); CumulativeAssertionCount += assertionCount; //EmitImpl(impl, false); int _totalchecks = 0; ProverInterface.Outcome outcome; dc.ErrorHandler = new DoomErrorHandler(dc.Label2Absy, callback); System.TimeSpan ts = new TimeSpan(); if (_print_time) { Console.WriteLine("Total number of blocks {0}", impl.Blocks.Count); } List <Block> lb; List <Variable> lv = new List <Variable>(); while (dc.GetNextBlock(out lb)) { Contract.Assert(lb != null); outcome = ProverInterface.Outcome.Undetermined; Variable v = null; lv.Clear(); foreach (Block b_ in lb) { if (!m_BlockReachabilityMap.TryGetValue(b_, out v)) { // This should cause an error continue; } //Console.Write("{0}, ",b_.Label); lv.Add(v); } //Console.WriteLine(); Dictionary <Expr, int> finalreachvars = m_GetPostconditionVariables(impl.Blocks, lb); if (lv.Count < 1) { continue; } Contract.Assert(lv != null); _totalchecks++; if (!dc.CheckLabel(lv, finalreachvars, out outcome)) { return(Outcome.Inconclusive); } ts += dc.DEBUG_ProverTime.Elapsed; if (restartTP) { checker.Close(); checker = FindCheckerFor(1000); dc.RespawnChecker(impl, checker); dc.ErrorHandler = new DoomErrorHandler(dc.Label2Absy, callback); } } checker.Close(); if (_print_time) { Console.WriteLine("Number of Checkes / #Blocks: {0} of {1}", _totalchecks, impl.Blocks.Count); dc.__DEBUG_PrintStatistics(); Console.WriteLine("Total time for this method: {0}", ts.ToString()); } #region Try to produce a counter example (brute force) if (dc.DoomedSequences.Count > 0) { int counter = 0; List <Block> _all = new List <Block>(); foreach (List <Block> lb_ in dc.DoomedSequences) { foreach (Block b_ in lb_) { if (!_all.Contains(b_) && !m_UncheckableBlocks.Contains(b_)) { _all.Add(b_); counter++; if (!_print_time) { Console.WriteLine(b_.Label); } } } } if (_all.Count > 0) { Console.WriteLine("#Dead Blocks found: {0}: ", counter); return(Outcome.Errors); } } #endregion return(Outcome.Correct); }