public static string ToString(VCExpr e, UniqueNamer namer, TPTPProverOptions opts) { Contract.Requires(e != null); Contract.Requires(namer != null); Contract.Ensures(Contract.Result <string>() != null); StringWriter sw = new StringWriter(); TPTPExprLineariser lin = new TPTPExprLineariser(sw, namer, opts); Contract.Assert(lin != null); lin.Linearise(e, LineariserOptions.Default); return(cce.NonNull(sw.ToString())); }
private void WriteApplication(string termOp, IEnumerable <VCExpr> /*!>!*/ args, LineariserOptions options, // change the AsTerm option for the arguments? bool argsAsTerms) { Contract.Requires(termOp != null); Contract.Requires(cce.NonNullElements(args)); Contract.Requires(options != null); LineariserOptions newOptions = options.SetAsTerm(argsAsTerms); Contract.Assert(newOptions != null); var argCnt = 0; if (termOp == "~") { wr.Write("(~ "); foreach (var e in args) { ExprLineariser.Linearise(e, newOptions); argCnt++; } Contract.Assert(argCnt == 1); wr.Write(")"); } else if ("&|~=><".IndexOf(termOp[0]) >= 0) { wr.Write("("); foreach (var e in args) { ExprLineariser.Linearise(e, newOptions); argCnt++; if (argCnt == 1) { wr.Write(" {0} ", termOp); } } Contract.Assert(argCnt == 2); wr.Write(")"); } else { wr.Write(termOp); foreach (var e in args) { Contract.Assert(e != null); if (argCnt == 0) { wr.Write("("); } else { wr.Write(", "); } argCnt++; ExprLineariser.Linearise(e, newOptions); } if (argCnt > 0) { wr.Write(")"); } } }