/////////////////////////////////////////////////////////////////////////// public override bool Visit(VCExprNAry node, bool arg) { Contract.Requires(node != null); if (node.Op is VCExprStoreOp) { string name = TPTPExprLineariser.Lowercase(SimplifyLikeExprLineariser.StoreOpName(node)); if (!KnownStoreFunctions.Contains(name)) { var id = KnownStoreFunctions.Count; if (CommandLineOptions.Clo.MonomorphicArrays) { var sel = TPTPExprLineariser.Lowercase(SimplifyLikeExprLineariser.SelectOpName(node)); var eq = "="; if (node[node.Arity - 1].Type.IsBool) { eq = "<=>"; } string xS = "", yS = ""; string dist = ""; for (int i = 0; i < node.Arity - 2; i++) { if (i != 0) { dist += " | "; xS += ","; yS += ","; } var x = "X" + i; var y = "Y" + i; xS += x; yS += y; dist += string.Format("({0} != {1})", x, y); } string ax1 = "fof(selectEq" + id + ", axiom, ! [M,V," + xS + "] : (" + string.Format("{0}({1}(M,{2},V),{2}) {3} V", sel, name, xS, eq) + "))."; string ax2 = "fof(selectNeq" + id + ", axiom, ! [M,V," + xS + "," + yS + "] : (" + string.Format("( {0} ) => ", dist) + string.Format("{0}({1}(M,{2},V),{3}) {4} {0}(M,{3})", sel, name, xS, yS, eq) + "))."; AddDeclaration(ax1); AddDeclaration(ax2); } KnownStoreFunctions.Add(name); } // } return(base.Visit(node, arg)); }
public bool VisitStoreOp(VCExprNAry node, LineariserOptions options) { var name = SimplifyLikeExprLineariser.StoreOpName(node); name = ExprLineariser.Namer.GetQuotedName(name, name); if (CommandLineOptions.Clo.UseArrayTheory) { name = "store"; } WriteApplication(name, node, options); return(true); }
public bool VisitStoreOp(VCExprNAry node, LineariserOptions options) { //Contract.Requires(options != null); //Contract.Requires(node != null); var name = Lowercase(SimplifyLikeExprLineariser.StoreOpName(node)); wr.Write(name + "("); var cnt = 0; foreach (VCExpr e in node) { Contract.Assert(e != null); if (cnt++ > 0) { wr.Write(", "); } ExprLineariser.Linearise(e, options.SetAsTerm(!e.Type.IsBool)); } wr.Write(")"); return(true); }
private void RegisterStore(VCExprNAry node) { RegisterType(node.Type); // this is the map type, registering it should register also the index and value types if (CommandLineOptions.Clo.UseArrayTheory) { return; } string name = SimplifyLikeExprLineariser.StoreOpName(node); name = Namer.GetQuotedName(name, name); if (!KnownStoreFunctions.Contains(name)) { string decl = "(declare-fun " + name + " (" + node.MapConcat(n => TypeToString(n.Type), " ") + ") " + TypeToString(node.Type) + ")"; AddDeclaration(decl); if (CommandLineOptions.Clo.TypeEncodingMethod == CommandLineOptions.TypeEncoding.Monomorphic) { var sel = SimplifyLikeExprLineariser.SelectOpName(node); sel = Namer.GetQuotedName(sel, sel); if (!KnownSelectFunctions.Contains(sel)) { // need to declare it before reference var args = node.SkipEnd(1); var ret = node.Last(); string seldecl = "(declare-fun " + sel + " (" + args.MapConcat(n => TypeToString(n.Type), " ") + ") " + TypeToString(ret.Type) + ")"; AddDeclaration(seldecl); KnownSelectFunctions.Add(sel); } string ax1 = "(assert (forall ("; string ax2 = "(assert (forall ("; string argX = "", argY = ""; string dist = ""; for (int i = 0; i < node.Arity; i++) { var t = " " + TypeToString(node[i].Type); var x = " ?x" + i; var y = " ?y" + i; ax1 += " (" + x + t + ")"; ax2 += " (" + x + t + ")"; if (i != 0 && i != node.Arity - 1) { argX += x; argY += y; ax2 += " (" + y + t + ")"; dist += " (not (=" + x + y + "))"; } } string v = " ?x" + (node.Arity - 1); ax1 += ") (= (" + sel + " (" + name + " ?x0" + argX + v + ")" + argX + ") " + v + ")"; ax1 += "))"; if (node.Arity > 3) { dist = "(or " + dist + ")"; } ax2 += ") (=> " + dist + " (= (" + sel + " (" + name + " ?x0" + argX + v + ")" + argY + ") (" + sel + " ?x0" + argY + ")))"; ax2 += "))"; AddDeclaration(ax1); AddDeclaration(ax2); } KnownStoreFunctions.Add(name); } // }