protected override sealed ProofOutcome ValidateInternal(IFactQuery <BoxedExpression, Variable> query, ContractInferenceManager inferenceManager, IOutputResults output) { if (this.MethodDriver.Options.TraceChecks) { output.WriteLine("Validating proof obligation: {0}", this.Condition != null ? this.Condition.ToString() : "<null?>"); } var result = ValidateInternalSpecific(query, inferenceManager, output); if (result != ProofOutcome.Top) { return(result); } var condition = this.Condition; if (condition != null) { WeakestPreconditionProver.AdditionalInfo why; if (TryDischargeProofObligationWithWeakestPreconditions(condition, query, inferenceManager, output, out why)) { return(ProofOutcome.True); } else { this.AdditionalInformationOnTheWarning.AddRange(WarningContextFetcher.InferContext(this.PC, condition, this.Context, this.DecoderForMetaData.IsBoolean)); this.AdditionalInformationOnTheWarning.AddRange(why.GetWarningContexts()); } } return(ProofOutcome.Top); }
private bool TryDischargeProofObligationWithWeakestPreconditions(BoxedExpression condition, IFactQuery <BoxedExpression, Variable> query, ContractInferenceManager inferenceManager, IOutputResults output, out WeakestPreconditionProver.AdditionalInfo why) { var options = output.LogOptions; // Try to validate the assertion by WP inference if (options.UseWeakestPreconditions) { var driver = this.MethodDriver; bool messageAlreadyPrinted; if (driver.SyntacticComplexity.ShouldAvoidWPComputation(out messageAlreadyPrinted)) { if (!messageAlreadyPrinted) { output.WriteLine("Skipping backwards computation for this method ({0}) as cccheck thinks it will cause a timeout", driver.MetaDataDecoder.Name(driver.CurrentMethod)); } this.AdditionalInformationOnTheWarning.Add(new WarningContext(WarningContext.ContextType.WPSkippedBecauseAdaptiveAnalysis)); } else { var path = WeakestPreconditionProver.Discharge(this.PC, condition, options.MaxPathSize, this.MethodDriver, query, inferenceManager, out why); return(path == null); } } why = WeakestPreconditionProver.AdditionalInfo.None; return(false); }
public static ClousotAnalysisResults EmitStats(this AnalysisStatistics @this, int swallowedTop, int swallowedBottom, int swallowedFalse, string assemblyName, IOutputResults output) { Contract.Requires(swallowedTop >= 0); Contract.Requires(swallowedBottom >= 0); Contract.Requires(swallowedFalse >= 0); Contract.Requires(assemblyName != null); Contract.Ensures(Contract.Result <ClousotAnalysisResults>() != null); var result = new ClousotAnalysisResults(); if (@this.Total > 0) { var True = @this.True; var Top = Math.Max(@this.Top - swallowedTop, 0); var Bottom = Math.Max(@this.Bottom - swallowedBottom, 0); var False = Math.Max(@this.False - swallowedFalse, 0); var Total = True + Top + Bottom + False; var masked = swallowedTop + swallowedFalse + swallowedBottom; Contract.Assert(masked >= 0); Contract.Assert(Top >= 0); Contract.Assert(Bottom >= 0); Contract.Assert(False >= 0); var stats = String.Format("Checked {0} assertion{1}: {2}{3}{4}{5}{6}", @this.Total.ToString(), @this.Total > 1 ? "s" : "", True > 0 ? True + " correct " : "", Top > 0 ? Top + " unknown " : "", Bottom > 0 ? Bottom + " unreached " : "", False > 0 ? False + " false" : "", masked > 0 ? "(" + masked + " masked)" : ""); output.FinalStatistic(assemblyName, stats); double precision = Total != 0 ? True / (double)Total : 1.0; output.Statistic("Validated: {0,6:P1}", precision); // for scripts parsing msbuild output output.WriteLine(stats); // Update the result result.Total = @this.Total; result.True = True; result.False = False; result.Bottom = Bottom; result.Top = Top; result.Masked = masked; } else { output.FinalStatistic(assemblyName, "Checked 0 assertions."); } return(result); }
public static ClousotAnalysisResults EmitStats(this AnalysisStatistics @this, int swallowedTop, int swallowedBottom, int swallowedFalse, string assemblyName, IOutputResults output) { Contract.Requires(swallowedTop >= 0); Contract.Requires(swallowedBottom >= 0); Contract.Requires(swallowedFalse >= 0); Contract.Requires(assemblyName != null); Contract.Ensures(Contract.Result<ClousotAnalysisResults>() != null); var result = new ClousotAnalysisResults(); if (@this.Total > 0) { var True = @this.True; var Top = Math.Max(@this.Top - swallowedTop, 0); var Bottom = Math.Max(@this.Bottom - swallowedBottom, 0); var False = Math.Max(@this.False - swallowedFalse, 0); var Total = True + Top + Bottom + False; var masked = swallowedTop + swallowedFalse + swallowedBottom; Contract.Assert(masked >= 0); Contract.Assert(Top >= 0); Contract.Assert(Bottom >= 0); Contract.Assert(False >= 0); var stats = String.Format("Checked {0} assertion{1}: {2}{3}{4}{5}{6}", @this.Total.ToString(), @this.Total > 1 ? "s" : "", True > 0 ? True + " correct " : "", Top > 0 ? Top + " unknown " : "", Bottom > 0 ? Bottom + " unreached " : "", False > 0 ? False + " false" : "", masked > 0 ? "(" + masked + " masked)" : ""); output.FinalStatistic(assemblyName,stats); double precision = Total != 0 ? True / (double)Total : 1.0; output.Statistic("Validated: {0,6:P1}", precision); // for scripts parsing msbuild output output.WriteLine(stats); // Update the result result.Total = @this.Total; result.True = True; result.False = False; result.Bottom = Bottom; result.Top = Top; result.Masked = masked; } else { output.FinalStatistic(assemblyName, "Checked 0 assertions."); } return result; }