/// <summary> /// Erases the types in <paramref name="vc" /> (if program is polymorphic) and sort let binding. /// Note that this has a side-effect on <paramref name="vc" />.. /// </summary> public VCExpr EraseAndSortLet(VCExpr vc, int polarity = -1) { var exprWithoutTypes = ProgramIsPolymorphic ? Eraser.Erase(vc, polarity) : vc; var letSorter = new LetBindingSorter(_vcExprGen); Contract.Assert(letSorter != null); return(letSorter.Mutate(exprWithoutTypes, true)); }
protected string VCExpr2String(VCExpr expr, int polarity) { Contract.Requires(expr != null); Contract.Ensures(Contract.Result<string>() != null); lock (gen) { DateTime start = DateTime.UtcNow; //if (CommandLineOptions.Clo.Trace) // Console.Write("Linearising ... "); // handle the types in the VCExpr TypeEraser eraser; switch (CommandLineOptions.Clo.TypeEncodingMethod) { case CommandLineOptions.TypeEncoding.Arguments: eraser = new TypeEraserArguments((TypeAxiomBuilderArguments)AxBuilder, gen); break; case CommandLineOptions.TypeEncoding.Monomorphic: eraser = null; break; default: eraser = new TypeEraserPremisses((TypeAxiomBuilderPremisses)AxBuilder, gen); break; } VCExpr exprWithoutTypes = eraser == null ? expr : eraser.Erase(expr, polarity); Contract.Assert(exprWithoutTypes != null); LetBindingSorter letSorter = new LetBindingSorter(gen); Contract.Assert(letSorter != null); VCExpr sortedExpr = letSorter.Mutate(exprWithoutTypes, true); Contract.Assert(sortedExpr != null); VCExpr sortedAxioms = letSorter.Mutate(AxBuilder.GetNewAxioms(), true); Contract.Assert(sortedAxioms != null); DeclCollector.Collect(sortedAxioms); DeclCollector.Collect(sortedExpr); FeedTypeDeclsToProver(); AddAxiom(SMTLibExprLineariser.ToString(sortedAxioms, Namer, options, namedAssumes: NamedAssumes)); string res = SMTLibExprLineariser.ToString(sortedExpr, Namer, options, NamedAssumes, OptimizationRequests); Contract.Assert(res != null); if (CommandLineOptions.Clo.Trace) { DateTime end = DateTime.UtcNow; TimeSpan elapsed = end - start; if (elapsed.TotalSeconds > 0.5) Console.WriteLine("Linearising [{0} s]", elapsed.TotalSeconds); } return res; } }