public bool VisitStoreOp(VCExprNAry node, LineariserOptions options) { //Contract.Requires(options != null); //Contract.Requires(node != null); wr.Write("(" + StoreOpName(node)); foreach (VCExpr e in node) { Contract.Assert(e != null); wr.Write(" "); ExprLineariser.Linearise(e, options.SetAsTerm(!e.Type.IsBool)); } wr.Write(")"); return(true); }
public bool VisitIfThenElseOp(VCExprNAry node, LineariserOptions options) { //Contract.Requires(options != null); //Contract.Requires(node != null); wr.Write("(ITE "); ExprLineariser.Linearise(node[0], options.SetAsTerm(false)); wr.Write(" "); ExprLineariser.Linearise(node[1], options); wr.Write(" "); ExprLineariser.Linearise(node[2], options); wr.Write(")"); return(true); }
public bool VisitBoogieFunctionOp(VCExprNAry node, LineariserOptions options) { //Contract.Requires(options != null); //Contract.Requires(node != null); VCExprBoogieFunctionOp op = (VCExprBoogieFunctionOp)node.Op; Contract.Assert(op != null); string funcName = op.Func.Name; Contract.Assert(funcName != null); string bvzName = op.Func.FindStringAttribute("external"); string printedName = ExprLineariser.Namer.GetName(op.Func, funcName); Contract.Assert(printedName != null); if (bvzName != null) { printedName = bvzName; } if (options.UseTypes) { // we use term notation for arguments whose type is not bool, and // formula notation for boolean arguments wr.Write("("); ExprLineariser.WriteId(printedName); foreach (VCExpr e in node) { Contract.Assert(e != null); wr.Write(" "); ExprLineariser.Linearise(e, options.SetAsTerm(!e.Type.IsBool)); } wr.Write(")"); } else { // arguments are always terms WriteApplicationTermOnly(SimplifyLikeExprLineariser.MakeIdPrintable(printedName), node, options); } return(true); }
private void WriteApplication(string termOp, string predOp, IEnumerable <VCExpr /*!*/> /*!*/ args, LineariserOptions options, bool argsAsTerms) { Contract.Requires(options != null); Contract.Requires(predOp != null); Contract.Requires(termOp != null); Contract.Requires(cce.NonNullElements(args));// change the AsTerm option for the arguments? wr.Write("({0}", options.AsTerm ? termOp : predOp); LineariserOptions newOptions = options.SetAsTerm(argsAsTerms); foreach (VCExpr e in args) { Contract.Assert(e != null); wr.Write(" "); ExprLineariser.Linearise(e, newOptions); } wr.Write(")"); }
///////////////////////////////////////////////////////////////////////////////////// public bool Visit(VCExprLet node, LineariserOptions options) { //Contract.Requires(options != null); //Contract.Requires(node != null); Namer.PushScope(); try { wr.Write("(LET ("); LineariserOptions optionsWithVars = options.AddLetVariables(node.BoundVars); Contract.Assert(optionsWithVars != null); string s = "("; foreach (VCExprLetBinding b in node) { Contract.Assert(b != null); wr.Write(s); string printedName = Namer.GetLocalName(b.V, b.V.Name); bool formula = b.V.Type.IsBool; if (formula) { wr.Write("FORMULA "); } else { wr.Write("TERM "); } WriteId(printedName); wr.Write(" "); Linearise(b.E, optionsWithVars.SetAsTerm(!formula)); wr.Write(")"); s = " ("; } wr.Write(") "); Linearise(node.Body, optionsWithVars); wr.Write(")"); return(true); } finally { Namer.PopScope(); } }
public void LineariseAsTerm(VCExpr expr, LineariserOptions options) { Contract.Requires(options != null); Contract.Requires(expr != null); Linearise(expr, options.SetAsTerm(true)); }