public override bool Visit(VCExprVar node, bool arg) { if (BoundTermVars.Contains(node)) { foreach (var instance in instancesOnStack) { instances.Remove(instance); } } return(base.Visit(node, arg)); }
public bool TranslateVCVar(VCExprVar v, out Variable result) { if (vcToBoogie.TryGetValue(v, out var resultInternal)) { result = resultInternal; return(true); } result = null; return(false); }
public Binding(VCExprVar v, VCExpr e, List <VCExprVar /*!*/> /*!*/ freeVars) { Contract.Requires(e != null); Contract.Requires(v != null); Contract.Requires(cce.NonNullElements(freeVars)); this.V = v; this.E = e; this.FreeVars = freeVars; this.Occurrences = new List <Binding>(); this.InvOccurrencesNum = 0; }
public bool TranslateBoogieVar(Variable v, out VCExprVar result) { if (boogieToVc.TryGetValue(v, out var resultInternal)) { result = resultInternal; return(true); } result = null; return(false); }
public override VCExpr Visit(VCExprVar node, VCExpr that) { Contract.Requires(that != null); Contract.Requires(node != null); Contract.Ensures(Contract.Result <VCExpr>() != null); if (node.Equals(that)) { return(node); } return(AbstractWithVariable(node, that)); }
protected override bool StandardResult(VCExpr node, IDictionary <VCExprVar /*!*/, VCExprVar /*!*/> /*!*/ globalVars) { //Contract.Requires(node != null); //Contract.Requires(cce.NonNullElements(globalVars)); VCExprVar nodeAsVar = node as VCExprVar; if (nodeAsVar == null || globalVars.ContainsKey(nodeAsVar)) { Size = Size + 1; } return(true); }
public void AddKnownVariable(VCExprVar variable) { if (KnownVariables.Contains(variable)) { return; } KnownVariables.Add(variable); if (declHandler != null) { declHandler.VarDecl(variable); } }
///////////////////////////////////////////////////////////////////////////////////// public bool Visit(VCExprQuantifier node, LineariserOptions options) { //Contract.Requires(node != null); //Contract.Requires(options != null); AssertAsFormula(node.Quan.ToString(), options); Contract.Assert(node.TypeParameters.Count == 0); Namer.PushScope(); try { string kind = node.Quan == Quantifier.ALL ? "!" : "?"; wr.Write("{0} [", kind); for (int i = 0; i < node.BoundVars.Count; i++) { VCExprVar var = node.BoundVars[i]; Contract.Assert(var != null); // ensure that the variable name starts with ? string printedName = Namer.GetLocalName(var, "V" + MakeIdPrintable(var.Name)); Contract.Assert(printedName != null); Contract.Assert(printedName[0] == 'V'); if (i > 0) { wr.Write(","); } wr.Write("{0}", printedName); } wr.Write("] : ("); /* if (options.QuantifierIds) { * // only needed for Z3 * VCQuantifierInfos! infos = node.Infos; * if (infos.qid != null) { * wr.Write("(QID "); * wr.Write(infos.qid); * wr.Write(") "); * } * if (0 <= infos.uniqueId) { * wr.Write("(SKOLEMID "); * wr.Write(infos.uniqueId); * wr.Write(") "); * } * } */ Linearise(node.Body, options); // WriteTriggers(node.Triggers, options); wr.Write(")"); return(true); } finally { Namer.PopScope(); } }
private VCExpr /*!*/ GenMapAxiom0(Function /*!*/ select, Function /*!*/ store, // bound type variables in the map type int mapTypeParamNum, // free type variables in the map // type (abstraction) int mapAbstractionVarNum) { Contract.Requires(select != null); Contract.Requires(store != null); Contract.Ensures(Contract.Result <VCExpr>() != null); int arity = select.InParams.Count - 1 - mapTypeParamNum - mapAbstractionVarNum; List <VCExprVar /*!*/> /*!*/ types = HelperFuns.VarVector("t", mapTypeParamNum + mapAbstractionVarNum, AxBuilder.T, Gen); List <Type /*!*/> indexTypes = new List <Type /*!*/>(); for (int i = mapTypeParamNum + mapAbstractionVarNum + 1; i < select.InParams.Count; i++) { indexTypes.Add(cce.NonNull(select.InParams[i]).TypedIdent.Type); } Contract.Assert(arity == indexTypes.Count); List <VCExprVar /*!*/> /*!*/ indexes = HelperFuns.VarVector("x", indexTypes, Gen); VCExprVar /*!*/ m = Gen.Variable("m", AxBuilder.U); Contract.Assert(m != null); VCExprVar /*!*/ val = Gen.Variable("val", cce.NonNull(select.OutParams[0]).TypedIdent.Type); Contract.Assert(val != null); VCExpr /*!*/ storeExpr = Store(store, types, m, indexes, val); Contract.Assert(storeExpr != null); VCExpr /*!*/ selectExpr = Select(select, types, storeExpr, indexes); Contract.Assert(selectExpr != null); List <VCExprVar /*!*/> /*!*/ quantifiedVars = new List <VCExprVar /*!*/>(); quantifiedVars.AddRange(types); quantifiedVars.Add(val); quantifiedVars.Add(m); quantifiedVars.AddRange(indexes); VCExpr /*!*/ eq = Gen.Eq(selectExpr, val); Contract.Assert(eq != null); return(Gen.Forall(quantifiedVars, new List <VCTrigger /*!*/>(), "mapAx0:" + select.Name, 0, eq)); }
private Term Doit(Term t) { VCExprVar v; if (bindingMap.TryGetValue(t, out v)) { return(v); } Term res = null; var kind = t.GetKind(); bool letok = false; if (kind == TermKind.App) { var f = t.GetAppDecl(); var args = t.GetAppArgs(); args = args.Select(x => Doit(x)).ToArray(); res = ctx.MkApp(f, args); letok = true; } else if (t is VCExprQuantifier) { var q = t as VCExprQuantifier; var newbody = ctx.Letify(q.Body); if (q.Quan == Quantifier.ALL) { res = ctx.Forall(q.BoundVars, q.Triggers, newbody); } else { res = ctx.Exists(q.BoundVars, q.Triggers, newbody); } letok = true; } else { res = t; } if (letok && refcnt[t].cnt > 1) { VCExprVar lv = ctx.MkConst("fpvc$" + Convert.ToString(letcnt), t.GetSort()) as VCExprVar; VCExprLetBinding b = ctx.LetBinding(lv, res); bindings.Add(b); bindingMap.Add(t, lv); res = lv; letcnt++; } return(res); }
private void GenBoundVarsForTypeParams(List <TypeVariable /*!*/> /*!*/ typeParams, List <VCExprVar /*!*/> /*!*/ newBoundVars, VariableBindings bindings) { Contract.Requires(bindings != null); Contract.Requires(cce.NonNullElements(typeParams)); Contract.Requires(cce.NonNullElements(newBoundVars)); foreach (TypeVariable /*!*/ tvar in typeParams) { Contract.Assert(tvar != null); VCExprVar /*!*/ var = Gen.Variable(tvar.Name, AxBuilder.T); Contract.Assert(var != null); newBoundVars.Add(var); bindings.TypeVariableBindings.Add(tvar, var); } }
public Term Visit(VCExprVar node, LineariserOptions options) { Contract.Requires(options != null); Contract.Requires(node != null); if (letBindings.ContainsKey(node)) { return(letBindings[node]); } else { string varName = namer.GetName(node, node.Name); return(cm.GetConstant(varName, node.Type, node)); } }
private VCExpr BuildAxiom(ProverInterface proverInterface, Dictionary <Variable, bool> currentAssignment) { ProverContext proverContext = proverInterface.Context; Boogie2VCExprTranslator exprTranslator = proverContext.BoogieExprTranslator; VCExpressionGenerator exprGen = proverInterface.VCExprGen; VCExpr expr = VCExpressionGenerator.True; foreach (KeyValuePair <Variable, bool> kv in currentAssignment) { Variable constant = kv.Key; VCExprVar exprVar = exprTranslator.LookupVariable(constant); if (kv.Value) { expr = exprGen.And(expr, exprVar); } else { expr = exprGen.And(expr, exprGen.Not(exprVar)); } } if (CommandLineOptions.Clo.ExplainHoudini) { // default values for ExplainHoudini control variables foreach (var constant in explainConstantsNegative.Concat(explainConstantsPositive)) { expr = exprGen.And(expr, exprTranslator.LookupVariable(constant)); } } /* * foreach (Variable constant in this.houdiniConstants) { * VCExprVar exprVar = exprTranslator.LookupVariable(constant); * if (currentAssignment[constant]) { * expr = exprGen.And(expr, exprVar); * } * else { * expr = exprGen.And(expr, exprGen.Not(exprVar)); * } * } */ if (CommandLineOptions.Clo.Trace) { Console.WriteLine("Houdini assignment axiom: " + expr); } return(expr); }
public override bool Visit(VCExprVar node, bool arg) { Contract.Requires(node != null); if (!BoundTermVars.Contains(node) && !KnownVariables.Contains(node)) { string printedName = Namer.GetQuotedName(node, node.Name); Contract.Assert(printedName != null); RegisterType(node.Type); string decl = "(declare-fun " + printedName + " () " + TypeToString(node.Type) + ")"; AddDeclaration(decl); KnownVariables.Add(node); } return(base.Visit(node, arg)); }
public VCExpr BestTypeVarExtractor( TypeVariable typeVar, VCExprVar dummyVariable, List <Type> vcFunctionValueTypes, List <VCExprVar> vcFunctionValueArgs) { var varBindings = new Dictionary <VCExprVar, VCExprVar>(); var typeVarBindings = new Dictionary <TypeVariable, VCExpr>(); typeVarBindings.Add(typeVar, dummyVariable); var b = new VariableBindings(varBindings, typeVarBindings); var binding = AxiomBuilder.BestTypeVarExtractors(new List <TypeVariable> { typeVar }, vcFunctionValueTypes, vcFunctionValueArgs, b); return(binding[0].E); }
public VCExpr Attach(StratifiedVC svc) { Contract.Assert(interfaceExprs.Count == svc.interfaceExprVars.Count); StratifiedInliningInfo info = svc.info; ProverInterface prover = info.vcgen.prover; VCExpressionGenerator gen = prover.VCExprGen; Dictionary<VCExprVar, VCExpr> substDict = new Dictionary<VCExprVar, VCExpr>(); for (int i = 0; i < svc.interfaceExprVars.Count; i++) { VCExprVar v = svc.interfaceExprVars[i]; substDict.Add(v, interfaceExprs[i]); } VCExprSubstitution subst = new VCExprSubstitution(substDict, new Dictionary<TypeVariable, Microsoft.Boogie.Type>()); SubstitutingVCExprVisitor substVisitor = new SubstitutingVCExprVisitor(prover.VCExprGen); svc.vcexpr = substVisitor.Mutate(svc.vcexpr, subst); foreach (StratifiedCallSite scs in svc.CallSites) { List<VCExpr> newInterfaceExprs = new List<VCExpr>(); foreach (VCExpr expr in scs.interfaceExprs) { newInterfaceExprs.Add(substVisitor.Mutate(expr, subst)); } scs.interfaceExprs = newInterfaceExprs; } foreach (StratifiedCallSite scs in svc.RecordProcCallSites) { List<VCExpr> newInterfaceExprs = new List<VCExpr>(); foreach (VCExpr expr in scs.interfaceExprs) { newInterfaceExprs.Add(substVisitor.Mutate(expr, subst)); } scs.interfaceExprs = newInterfaceExprs; } //return gen.Implies(callSiteExpr, svc.vcexpr); return svc.vcexpr; }
public VCExpr BindQuantifier(VCExprQuantifier node) { if (node.TypeParameters.Count > 0) { return(node); } var boundVariableToLabels = node.Info.instantiationLabels; if (boundVariableToLabels.Count < node.BoundVars.Count || boundVariableToLabels.Any(kv => kv.Value.Count == 0)) { return(node); } var v = new VCExprVar($"{quantifierBindingNamePrefix}{quantifierBinding.Count}", Type.Bool); quantifierBinding[v] = node; quantifierInstantiationInfo[node] = new QuantifierInstantiationInfo(boundVariableToLabels); return(v); }
///////////////////////////////////////////////////////////////////////////////////// public bool Visit(VCExprVar node, LineariserOptions options) { //Contract.Requires(node != null); //Contract.Requires(options != null); string printedName = Namer.GetName(node, MakeIdPrintable(Lowercase(node.Name))); Contract.Assert(printedName != null); if (options.AsTerm || // formula variables are easy to identify in SMT-Lib printedName[0] == '$') { wr.Write("{0}", printedName); } else { wr.Write("({0} = {1})", printedName, boolTrueName); } return(true); }
public override bool Visit(VCExprVar node, bool arg) { Contract.Requires(node != null); if (!BoundTermVars.Contains(node) && !KnownVariables.Contains(node)) { string printedName = Namer.GetQuotedName(node, node.Name); Contract.Assert(printedName != null); RegisterType(node.Type); string decl = "(declare-fun " + printedName + " () " + TypeToString(node.Type) + ")"; if (!(printedName.StartsWith("assume$$") || printedName.StartsWith("soft$$") || printedName.StartsWith("try$$"))) { AddDeclaration(decl); } KnownVariables.Add(node); if (declHandler != null) { declHandler.VarDecl(node); } } return(base.Visit(node, arg)); }
public override string Lookup(VCExprVar var) { return(exprTranslator.Lookup(var)); }
public override string Lookup(VCExprVar var) { Contract.Requires(var != null); Contract.Ensures(Contract.Result<string>() != null); throw new NotImplementedException(); }
public abstract string Lookup(VCExprVar var);
public override string Lookup(VCExprVar var) { return exprTranslator.Lookup(var); }
public override bool Visit(VCExprVar node, bool arg) { return(base.Visit(node, arg)); }
private Variable MakeVar(VCExprVar v){ var foo = new TypedIdent(Token.NoToken,v.Name.ToString(),v.Type); return new BoundVariable(Token.NoToken,foo); }
///////////////////////////////////////////////////////////////////////////////////// public bool Visit(VCExprVar node, LineariserOptions options) { wr.Write(Namer.GetQuotedName(node, node.Name)); return(true); }
public VCExpr GenVarTypeAxiom(VCExprVar var, Type originalType, IDictionary<TypeVariable/*!*/, VCExpr/*!*/>/*!*/ varMapping) { Contract.Requires(var != null); Contract.Requires(originalType != null); Contract.Requires(cce.NonNullDictionaryAndValues(varMapping)); Contract.Ensures(Contract.Result<VCExpr>() != null); if (!var.Type.Equals(originalType)) { VCExpr/*!*/ typeRepr = Type2Term(originalType, varMapping); return Gen.Eq(TypeOf(var), typeRepr); } return VCExpressionGenerator.True; }
// MAXSAT public void Explain(ProverInterface proverInterface, Dictionary <Variable, bool> assignment, Variable refutedConstant) { Contract.Assert(CommandLineOptions.Clo.ExplainHoudini); collector.examples.Clear(); // debugging houdiniAssertConstants.Iter(v => System.Diagnostics.Debug.Assert(assignment.ContainsKey(v))); houdiniAssumeConstants.Iter(v => System.Diagnostics.Debug.Assert(assignment.ContainsKey(v))); Contract.Assert(assignment.ContainsKey(refutedConstant)); Contract.Assert(houdiniAssertConstants.Contains(refutedConstant)); var hardAssumptions = new List <VCExpr>(); var softAssumptions = new List <VCExpr>(); Boogie2VCExprTranslator exprTranslator = proverInterface.Context.BoogieExprTranslator; VCExpressionGenerator exprGen = proverInterface.VCExprGen; var controlExpr = VCExpressionGenerator.True; foreach (var tup in assignment) { Variable constant = tup.Key; VCExprVar exprVar = exprTranslator.LookupVariable(constant); var val = tup.Value; if (houdiniAssumeConstants.Contains(constant)) { if (tup.Value) { hardAssumptions.Add(exprVar); } else { // Previously removed assumed candidates are the soft constraints softAssumptions.Add(exprVar); } } else if (houdiniAssertConstants.Contains(constant)) { if (constant == refutedConstant) { hardAssumptions.Add(exprVar); } else { hardAssumptions.Add(exprGen.Not(exprVar)); } } else { if (tup.Value) { hardAssumptions.Add(exprVar); } else { hardAssumptions.Add(exprGen.Not(exprVar)); } } // For an asserted condition (c ==> \phi), // ExplainHoudini's extra control constants (c_pos, c_neg) are used as follows: // (true, true): "assert \phi" // (false, _): "assert false" // (true, false): "assert true" if (constant != refutedConstant && constantToControl.ContainsKey(constant.Name)) { var posControl = constantToControl[constant.Name].Item1; var negControl = constantToControl[constant.Name].Item2; // Handle self-recursion if (houdiniAssertConstants.Contains(constant) && houdiniAssumeConstants.Contains(constant)) { // disable this assert controlExpr = exprGen.And(controlExpr, exprGen.And(exprTranslator.LookupVariable(posControl), exprGen.Not(exprTranslator.LookupVariable(negControl)))); } else { // default values for control variables controlExpr = exprGen.And(controlExpr, exprGen.And(exprTranslator.LookupVariable(posControl), exprTranslator.LookupVariable(negControl))); } } } hardAssumptions.Add(exprGen.Not(conjecture)); // default values for control variables Contract.Assert(constantToControl.ContainsKey(refutedConstant.Name)); var pc = constantToControl[refutedConstant.Name].Item1; var nc = constantToControl[refutedConstant.Name].Item2; var controlExprNoop = exprGen.And(controlExpr, exprGen.And(exprTranslator.LookupVariable(pc), exprTranslator.LookupVariable(nc))); var controlExprFalse = exprGen.And(controlExpr, exprGen.And(exprGen.Not(exprTranslator.LookupVariable(pc)), exprGen.Not(exprTranslator.LookupVariable(nc)))); if (CommandLineOptions.Clo.Trace) { Console.WriteLine("Verifying (MaxSat) " + descriptiveName); } DateTime now = DateTime.UtcNow; var el = CommandLineOptions.Clo.ProverCCLimit; CommandLineOptions.Clo.ProverCCLimit = 1; var outcome = ProverInterface.Outcome.Undetermined; do { List <int> unsatisfiedSoftAssumptions; hardAssumptions.Add(controlExprNoop); outcome = proverInterface.CheckAssumptions(hardAssumptions, softAssumptions, out unsatisfiedSoftAssumptions, handler); hardAssumptions.RemoveAt(hardAssumptions.Count - 1); if (outcome == ProverInterface.Outcome.TimeOut || outcome == ProverInterface.Outcome.OutOfMemory || outcome == ProverInterface.Outcome.OutOfResource || outcome == ProverInterface.Outcome.Undetermined) { break; } var reason = new HashSet <string>(); unsatisfiedSoftAssumptions.Iter(i => reason.Add(softAssumptions[i].ToString())); if (CommandLineOptions.Clo.Trace) { Console.Write("Reason for removal of {0}: ", refutedConstant.Name); reason.Iter(r => Console.Write("{0} ", r)); Console.WriteLine(); } // Get rid of those constants from the "reason" that can even make // "assert false" pass hardAssumptions.Add(controlExprFalse); var softAssumptions2 = new List <VCExpr>(); for (int i = 0; i < softAssumptions.Count; i++) { if (unsatisfiedSoftAssumptions.Contains(i)) { softAssumptions2.Add(softAssumptions[i]); continue; } hardAssumptions.Add(softAssumptions[i]); } var unsatisfiedSoftAssumptions2 = new List <int>(); outcome = proverInterface.CheckAssumptions(hardAssumptions, softAssumptions2, out unsatisfiedSoftAssumptions2, handler); if (outcome == ProverInterface.Outcome.TimeOut || outcome == ProverInterface.Outcome.OutOfMemory || outcome == ProverInterface.Outcome.OutOfResource || outcome == ProverInterface.Outcome.Undetermined) { break; } unsatisfiedSoftAssumptions2.Iter(i => reason.Remove(softAssumptions2[i].ToString())); var reason1 = new HashSet <string>(); //these are the reasons for inconsistency unsatisfiedSoftAssumptions2.Iter(i => reason1.Add(softAssumptions2[i].ToString())); if (CommandLineOptions.Clo.Trace) { Console.Write("Revised reason for removal of {0}: ", refutedConstant.Name); reason.Iter(r => Console.Write("{0} ", r)); Console.WriteLine(); } foreach (var r in reason) { Houdini.explainHoudiniDottyFile.WriteLine("{0} -> {1} [ label = \"{2}\" color=red ];", refutedConstant.Name, r, descriptiveName); } //also add the removed reasons using dotted edges (requires- x != 0, requires- x == 0 ==> assert x != 0) foreach (var r in reason1) { Houdini.explainHoudiniDottyFile.WriteLine("{0} -> {1} [ label = \"{2}\" color=blue style=dotted ];", refutedConstant.Name, r, descriptiveName); } } while (false); if (outcome == ProverInterface.Outcome.TimeOut || outcome == ProverInterface.Outcome.OutOfMemory || outcome == ProverInterface.Outcome.OutOfResource || outcome == ProverInterface.Outcome.Undetermined) { Houdini.explainHoudiniDottyFile.WriteLine("{0} -> {1} [ label = \"{2}\" color=red ];", refutedConstant.Name, "TimeOut", descriptiveName); } CommandLineOptions.Clo.ProverCCLimit = el; double queryTime = (DateTime.UtcNow - now).TotalSeconds; stats.proverTime += queryTime; stats.numProverQueries++; if (CommandLineOptions.Clo.Trace) { Console.WriteLine("Time taken = " + queryTime); } }
public override LineariserOptions AddLetVariable(VCExprVar furtherVar) { //Contract.Requires(furtherVar != null); Contract.Ensures(Contract.Result<LineariserOptions>() != null); List<VCExprVar/*!>!*/> allVars = new List<VCExprVar/*!*/>(); allVars.AddRange(LetVariables); allVars.Add(furtherVar); return new Z3LineariserOptions(AsTerm, opts, allVars); }
// Generate the constraints telling that parents of a constant are // strictly greater than the constant itself, and are the minimal // elements with this property private VCExpr GenParentConstraints(Constant c) { Contract.Requires(c != null); Contract.Ensures(Contract.Result <VCExpr>() != null); VCExpr res = VCExpressionGenerator.True; if (c.Parents == null) { return(res); } VCExprVar cAsVar = Translator.LookupVariable(c); VCExprVar w = Gen.Variable("w", c.TypedIdent.Type); // Parents of c are proper ancestors of c foreach (ConstantParent p in c.Parents) { Contract.Assert(p != null); VCExprVar par = Translator.LookupVariable(cce.NonNull(p.Parent.Decl)); res = Gen.AndSimp(res, Gen.Neq(cAsVar, par)); res = Gen.AndSimp(res, Gen.AtMost(cAsVar, par)); } // Parents are direct ancestors of c (no other elements are in // between c and a parent) foreach (ConstantParent p in c.Parents) { Contract.Assert(p != null); VCExprVar par = Translator.LookupVariable(cce.NonNull(p.Parent.Decl)); Contract.Assert(par != null); VCExpr antecedent1 = Gen.AtMost(cAsVar, w); Contract.Assert(antecedent1 != null); VCExpr antecedent2 = Gen.AtMost(w, par); Contract.Assert(antecedent2 != null); VCExpr body = Gen.Implies(Gen.And(antecedent1, antecedent2), Gen.Or(Gen.Eq(cAsVar, w), Gen.Eq(par, w))); Contract.Assert(body != null); res = Gen.AndSimp(res, Gen.Forall(w, Gen.Trigger(true, antecedent1, antecedent2), body)); } // Ancestors of c are only c itself and the ancestors of the // parents of c VCExpr minAncestors = Gen.Eq(cAsVar, w); Contract.Assert(minAncestors != null); foreach (ConstantParent p in c.Parents) { Contract.Assert(p != null); minAncestors = Gen.Or(minAncestors, Gen.AtMost(Translator.LookupVariable(cce.NonNull(p.Parent.Decl)), w)); } VCExpr antecedent = Gen.AtMost(cAsVar, w); Contract.Assert(antecedent != null); res = Gen.AndSimp(res, Gen.Forall(w, Gen.Trigger(true, antecedent), Gen.Implies(antecedent, minAncestors))); // Constraints for unique child-parent edges foreach (ConstantParent p in c.Parents) { Contract.Assert(p != null); if (p.Unique) { res = Gen.AndSimp(res, GenUniqueParentConstraint(c, cce.NonNull((Constant)p.Parent.Decl))); } } return(res); }
public VarAxiomInfo(VCExprVar vcVar, VCExpr expr) : base(expr) { this.VcVar = vcVar; }
public StratifiedVC(StratifiedInliningInfo siInfo, HashSet<string> procCalls) { info = siInfo; info.GenerateVC(); var vcgen = info.vcgen; var prover = vcgen.prover; VCExpressionGenerator gen = prover.VCExprGen; var bet = prover.Context.BoogieExprTranslator; vcexpr = info.vcexpr; id = vcgen.CreateNewId(); interfaceExprVars = new List<VCExprVar>(); Dictionary<VCExprVar, VCExpr> substDict = new Dictionary<VCExprVar, VCExpr>(); foreach (VCExprVar v in info.interfaceExprVars) { VCExprVar newVar = vcgen.CreateNewVar(v.Type); interfaceExprVars.Add(newVar); substDict.Add(v, newVar); } foreach (VCExprVar v in info.privateExprVars) { substDict.Add(v, vcgen.CreateNewVar(v.Type)); } if (info.controlFlowVariable != null) substDict.Add(bet.LookupVariable(info.controlFlowVariable), gen.Integer(BigNum.FromInt(id))); VCExprSubstitution subst = new VCExprSubstitution(substDict, new Dictionary<TypeVariable, Microsoft.Boogie.Type>()); SubstitutingVCExprVisitor substVisitor = new SubstitutingVCExprVisitor(prover.VCExprGen); vcexpr = substVisitor.Mutate(vcexpr, subst); // For BoolControlVC generation if (info.blockToControlVar != null) { blockToControlVar = new Dictionary<Block, VCExpr>(); foreach (var tup in info.blockToControlVar) blockToControlVar.Add(tup.Key, substDict[tup.Value]); } if (procCalls != null) vcexpr = RemoveProcedureCalls.Apply(vcexpr, info.vcgen.prover.VCExprGen, procCalls); callSites = new Dictionary<Block, List<StratifiedCallSite>>(); foreach (Block b in info.callSites.Keys) { callSites[b] = new List<StratifiedCallSite>(); foreach (CallSite cs in info.callSites[b]) { callSites[b].Add(new StratifiedCallSite(cs, substVisitor, subst)); } } recordProcCallSites = new Dictionary<Block, List<StratifiedCallSite>>(); foreach (Block b in info.recordProcCallSites.Keys) { recordProcCallSites[b] = new List<StratifiedCallSite>(); foreach (CallSite cs in info.recordProcCallSites[b]) { recordProcCallSites[b].Add(new StratifiedCallSite(cs, substVisitor, subst)); } } }
protected override void AddVarTypeAxiom(VCExprVar var, Type originalType) { //Contract.Requires(originalType != null); //Contract.Requires(var != null); // no axioms are needed for variable or function types }
//////////////////////////////////////////////////////////////////////////// protected override void AddVarTypeAxiom(VCExprVar var, Type originalType) { //Contract.Requires(originalType != null); //Contract.Requires(var != null); if (CommandLineOptions.Clo.TypeEncodingMethod == CommandLineOptions.TypeEncoding.None) return; AddTypeAxiom(GenVarTypeAxiom(var, originalType, // we don't have any bindings available new Dictionary<TypeVariable/*!*/, VCExpr/*!*/>())); }
public override void VarDecl(VCExprVar v){ var_map[v.Name] = v; }
///////////////////////////////////////////////////////////////////////////////////// public bool Visit(VCExprQuantifier node, LineariserOptions options) { Contract.Assert(node.TypeParameters.Count == 0); UnderQuantifier++; Namer.PushScope(); try { string kind = node.Quan == Quantifier.ALL ? "forall" : "exists"; wr.Write("({0} (", kind); for (int i = 0; i < node.BoundVars.Count; i++) { VCExprVar var = node.BoundVars[i]; Contract.Assert(var != null); string printedName = Namer.GetQuotedLocalName(var, var.Name); Contract.Assert(printedName != null); wr.Write("({0} {1}) ", printedName, TypeToString(var.Type)); } wr.Write(") "); VCQuantifierInfos infos = node.Infos; var weight = QKeyValue.FindIntAttribute(infos.attributes, "weight", 1); if (!ProverOptions.UseWeights) { weight = 1; } var hasAttrs = node.Triggers.Count > 0 || infos.qid != null || weight != 1 || infos.uniqueId != -1; if (hasAttrs) { wr.Write("(! "); } Linearise(node.Body, options); if (hasAttrs) { wr.Write("\n"); if (infos.qid != null) { wr.Write(" :qid {0}\n", SMTLibNamer.QuoteId(infos.qid)); } if (weight != 1) { wr.Write(" :weight {0}\n", weight); } if (infos.uniqueId != -1) { wr.Write(" :skolemid |{0}|\n", infos.uniqueId); } WriteTriggers(node.Triggers, options); wr.Write(")"); } wr.Write(")"); return(true); } finally { UnderQuantifier--; Namer.PopScope(); } }
public bool IsQuantifierBinding(VCExprVar vcExprVar) { return(this.quantifierBinding.ContainsKey(vcExprVar)); }
public abstract void VarDecl(VCExprVar v);
public override string Lookup(VCExprVar var) { VCExprVar v = parent.AxBuilder.TryTyped2Untyped(var); if (v != null) { var = v; } return parent.Namer.Lookup(var); }