/// <summary> /// As a side effect, updates "this.parent.CumulativeAssertionCount". /// </summary> public void BeginCheck(Checker checker, VerifierCallback callback, ModelViewInfo mvInfo, int no, int timeout, int rlimit) { Contract.Requires(checker != null); Contract.Requires(callback != null); splitNum = no; impl.Blocks = blocks; this.checker = checker; Dictionary <int, Absy> label2absy = new Dictionary <int, Absy>(); ProverContext ctx = checker.TheoremProver.Context; Boogie2VCExprTranslator bet = ctx.BoogieExprTranslator; var cc = new VCGen.CodeExprConversionClosure(label2absy, ctx); bet.SetCodeExprConverter(cc.CodeExprToVerificationCondition); var exprGen = ctx.ExprGen; VCExpr controlFlowVariableExpr = exprGen.Integer(BigNum.ZERO); VCExpr vc = parent.GenerateVCAux(impl, controlFlowVariableExpr, label2absy, checker.TheoremProver.Context); Contract.Assert(vc != null); vc = QuantifierInstantiationEngine.Instantiate(impl, exprGen, bet, vc); VCExpr controlFlowFunctionAppl = exprGen.ControlFlowFunctionApplication(exprGen.Integer(BigNum.ZERO), exprGen.Integer(BigNum.ZERO)); VCExpr eqExpr = exprGen.Eq(controlFlowFunctionAppl, exprGen.Integer(BigNum.FromInt(impl.Blocks[0].UniqueId))); vc = exprGen.Implies(eqExpr, vc); reporter = new VCGen.ErrorReporter(gotoCmdOrigins, label2absy, impl.Blocks, parent.debugInfos, callback, mvInfo, this.Checker.TheoremProver.Context, parent.program); if (CommandLineOptions.Clo.TraceVerify && no >= 0) { Console.WriteLine("-- after split #{0}", no); Print(); } string desc = cce.NonNull(impl.Name); if (no >= 0) { desc += "_split" + no; } checker.BeginCheck(desc, vc, reporter, timeout, rlimit, impl.RandomSeed); }
public void GenerateVC() { if (initialized) return; if (CommandLineOptions.Clo.SIBoolControlVC) { GenerateVCBoolControl(); initialized = true; return; } List<Variable> outputVariables = new List<Variable>(); List<Expr> assertConjuncts = new List<Expr>(); foreach (Variable v in impl.OutParams) { Constant c = new Constant(Token.NoToken, new TypedIdent(Token.NoToken, impl.Name + "_" + v.Name, v.TypedIdent.Type)); outputVariables.Add(c); Expr eqExpr = Expr.Eq(new IdentifierExpr(Token.NoToken, c), new IdentifierExpr(Token.NoToken, v)); assertConjuncts.Add(eqExpr); } foreach (IdentifierExpr e in impl.Proc.Modifies) { if (e.Decl == null) continue; Variable v = e.Decl; Constant c = new Constant(Token.NoToken, new TypedIdent(Token.NoToken, impl.Name + "_" + v.Name, v.TypedIdent.Type)); outputVariables.Add(c); Expr eqExpr = Expr.Eq(new IdentifierExpr(Token.NoToken, c), new IdentifierExpr(Token.NoToken, v)); assertConjuncts.Add(eqExpr); } exitAssertCmd = new AssertCmd(Token.NoToken, Expr.Not(Expr.BinaryTreeAnd(assertConjuncts))); Program program = vcgen.program; ProverInterface proverInterface = vcgen.prover; vcgen.ConvertCFG2DAG(impl); vcgen.PassifyImpl(impl, out mvInfo); VCExpressionGenerator gen = proverInterface.VCExprGen; var exprGen = proverInterface.Context.ExprGen; var translator = proverInterface.Context.BoogieExprTranslator; controlFlowVariable = new LocalVariable(Token.NoToken, new TypedIdent(Token.NoToken, "@cfc", Microsoft.Boogie.Type.Int)); VCExpr controlFlowVariableExpr = translator.LookupVariable(controlFlowVariable); vcgen.InstrumentCallSites(impl); if (PassiveImplInstrumentation != null) PassiveImplInstrumentation(impl); label2absy = new Dictionary<int, Absy>(); VCGen.CodeExprConversionClosure cc = new VCGen.CodeExprConversionClosure(label2absy, proverInterface.Context); translator.SetCodeExprConverter(cc.CodeExprToVerificationCondition); vcexpr = gen.Not(vcgen.GenerateVCAux(impl, controlFlowVariableExpr, label2absy, proverInterface.Context)); if (controlFlowVariableExpr != null) { VCExpr controlFlowFunctionAppl = exprGen.ControlFlowFunctionApplication(controlFlowVariableExpr, exprGen.Integer(BigNum.ZERO)); VCExpr eqExpr = exprGen.Eq(controlFlowFunctionAppl, exprGen.Integer(BigNum.FromInt(impl.Blocks[0].UniqueId))); vcexpr = exprGen.And(eqExpr, vcexpr); } callSites = vcgen.CollectCallSites(impl); recordProcCallSites = vcgen.CollectRecordProcedureCallSites(impl); privateExprVars = new List<VCExprVar>(); foreach (Variable v in impl.LocVars) { privateExprVars.Add(translator.LookupVariable(v)); } foreach (Variable v in impl.OutParams) { privateExprVars.Add(translator.LookupVariable(v)); } interfaceExprVars = new List<VCExprVar>(); foreach (Variable v in program.GlobalVariables) { interfaceExprVars.Add(translator.LookupVariable(v)); } foreach (Variable v in impl.InParams) { interfaceExprVars.Add(translator.LookupVariable(v)); } foreach (Variable v in outputVariables) { interfaceExprVars.Add(translator.LookupVariable(v)); } initialized = true; }
/// <summary> /// As a side effect, updates "this.parent.CumulativeAssertionCount". /// </summary> public void BeginCheck(Checker checker, VerifierCallback callback, ModelViewInfo mvInfo, int no, int timeout, int rlimit) { Contract.Requires(checker != null); Contract.Requires(callback != null); splitNo = no; impl.Blocks = blocks; this.checker = checker; Dictionary <int, Absy> label2absy = new Dictionary <int, Absy>(); ProverContext ctx = checker.TheoremProver.Context; Boogie2VCExprTranslator bet = ctx.BoogieExprTranslator; var cc = new VCGen.CodeExprConversionClosure(label2absy, ctx); bet.SetCodeExprConverter(cc.CodeExprToVerificationCondition); var exprGen = ctx.ExprGen; VCExpr controlFlowVariableExpr = exprGen.Integer(BigNum.ZERO); #region proofgen TypePremiseEraserFactory typePremiseEraserFactory; switch (CommandLineOptions.Clo.TypeEncodingMethod) { case CommandLineOptions.TypeEncoding.Predicates: typePremiseEraserFactory = new TypePremiseEraserFactory(checker.VCExprGen, bet, true); break; case CommandLineOptions.TypeEncoding.Monomorphic: typePremiseEraserFactory = new TypePremiseEraserFactory(checker.VCExprGen, bet, false); break; default: throw new NotImplementedException(); } ProofGenerationLayer.SetTypeEraserFactory(typePremiseEraserFactory); #endregion /* PROOF GEN: we pass "null" as the control flow variable expression, such that labels are not produced as they are * not relevant for proof generation of programs that verify */ VCExpr vc = parent.GenerateVCAux(impl, null, label2absy, checker.TheoremProver.Context); Contract.Assert(vc != null); #region proofgen if (!(ctx is DeclFreeProverContext)) { throw new NotImplementedException("Proof Generation only supports DeclFreeProverContext as context."); } var declFreeProverContext = ctx as DeclFreeProverContext; var premiseEraserProvider = typePremiseEraserFactory?.NewEraser(); VCExpr eraseVC(VCExpr vc, int polarity) { return(!premiseEraserProvider.ProgramIsPolymorphic ? vc : premiseEraserProvider.EraseAndSortLet(vc, polarity)); } VCExpr erasedVC = eraseVC(vc, 1); VCExpr erasedAxioms = eraseVC(declFreeProverContext.Axioms, -1); VCExpr typeAxioms = null; List <VCAxiomInfo> vcAxiomsInfo = null; if (premiseEraserProvider.ProgramIsPolymorphic) { typeAxioms = premiseEraserProvider.AxiomBuilder.GetNewAxiomsAndInfo(out vcAxiomsInfo); } ProofGenerationLayer.VCGenerateAllProofs( erasedVC, erasedAxioms, typeAxioms, vcAxiomsInfo, checker.TheoremProver.VCExprGen, checker.TheoremProver.Context.BoogieExprTranslator, premiseEraserProvider?.AxiomBuilder); #endregion /* PROOF GEN: comment out label specific parts * VCExpr controlFlowFunctionAppl = * exprGen.ControlFlowFunctionApplication(exprGen.Integer(BigNum.ZERO), exprGen.Integer(BigNum.ZERO)); * VCExpr eqExpr = exprGen.Eq(controlFlowFunctionAppl, exprGen.Integer(BigNum.FromInt(impl.Blocks[0].UniqueId))); * vc = exprGen.Implies(eqExpr, vc); */ reporter = new VCGen.ErrorReporter(gotoCmdOrigins, label2absy, impl.Blocks, parent.debugInfos, callback, mvInfo, this.Checker.TheoremProver.Context, parent.program); if (CommandLineOptions.Clo.TraceVerify && no >= 0) { Console.WriteLine("-- after split #{0}", no); Print(); } string desc = cce.NonNull(impl.Name); if (no >= 0) { desc += "_split" + no; } checker.BeginCheck(desc, vc, reporter, timeout, rlimit, impl.RandomSeed); }