Exemple #1
0
    public static ProverInterface CreateProver(Program prog, string/*?*/ logFilePath, bool appendLogFile, int timeout, int taskID = -1) {
      Contract.Requires(prog != null);

      ProverOptions options = cce.NonNull(CommandLineOptions.Clo.TheProverFactory).BlankProverOptions();

      if (logFilePath != null) {
        options.LogFilename = logFilePath;
        if (appendLogFile)
          options.AppendLogFile = appendLogFile;
      }

      if (timeout > 0) {
        options.TimeLimit = timeout * 1000;
      }

      if (taskID >= 0) {
        options.Parse(CommandLineOptions.Clo.Cho[taskID].ProverOptions);
      } else {
        options.Parse(CommandLineOptions.Clo.ProverOptions);
      }

      ProverContext ctx = (ProverContext)CommandLineOptions.Clo.TheProverFactory.NewProverContext(options);

      // set up the context
      foreach (Declaration decl in prog.TopLevelDeclarations) {
        Contract.Assert(decl != null);
        TypeCtorDecl t = decl as TypeCtorDecl;
        if (t != null) {
          ctx.DeclareType(t, null);
        }
      }
      foreach (Declaration decl in prog.TopLevelDeclarations) {
        Contract.Assert(decl != null);
        Constant c = decl as Constant;
        if (c != null) {
          ctx.DeclareConstant(c, c.Unique, null);
        }
        else {
          Function f = decl as Function;
          if (f != null) {
            ctx.DeclareFunction(f, null);
          }
        }
      }
      foreach (var ax in prog.Axioms) {
        ctx.AddAxiom(ax, null);
      }
      foreach (Declaration decl in prog.TopLevelDeclarations) {
        Contract.Assert(decl != null);
        GlobalVariable v = decl as GlobalVariable;
        if (v != null) {
          ctx.DeclareGlobalVariable(v, null);
        }
      }

      return (ProverInterface)CommandLineOptions.Clo.TheProverFactory.SpawnProver(options, ctx);
    }
Exemple #2
0
 /// <summary>
 /// Set up the context.
 /// </summary>
 private void Setup(Program prog, ProverContext ctx, Split s = null)
 {
     Program = prog;
     // TODO(wuestholz): Is this lock necessary?
     lock (Program.TopLevelDeclarations)
     {
         var decls = s == null ? prog.TopLevelDeclarations : s.TopLevelDeclarations;
         foreach (Declaration decl in decls)
         {
             Contract.Assert(decl != null);
             var typeDecl  = decl as TypeCtorDecl;
             var constDecl = decl as Constant;
             var funDecl   = decl as Function;
             var axiomDecl = decl as Axiom;
             var glVarDecl = decl as GlobalVariable;
             if (typeDecl != null)
             {
                 ctx.DeclareType(typeDecl, null);
             }
             else if (constDecl != null)
             {
                 ctx.DeclareConstant(constDecl, constDecl.Unique, null);
             }
             else if (funDecl != null)
             {
                 ctx.DeclareFunction(funDecl, null);
             }
             else if (axiomDecl != null)
             {
                 ctx.AddAxiom(axiomDecl, null);
             }
             else if (glVarDecl != null)
             {
                 ctx.DeclareGlobalVariable(glVarDecl, null);
             }
         }
     }
 }
Exemple #3
0
 /// <summary>
 /// Set up the context.
 /// </summary>
 private void Setup(Program prog, ProverContext ctx, Implementation impl = null)
 {
     Program = prog;
     // TODO(wuestholz): Is this lock necessary?
     lock (Program.TopLevelDeclarations)
     {
         foreach (Declaration decl in Prune.GetSuccinctDecl(prog, impl))
         {
             Contract.Assert(decl != null);
             var typeDecl  = decl as TypeCtorDecl;
             var constDecl = decl as Constant;
             var funDecl   = decl as Function;
             var axiomDecl = decl as Axiom;
             var glVarDecl = decl as GlobalVariable;
             if (typeDecl != null)
             {
                 ctx.DeclareType(typeDecl, null);
             }
             else if (constDecl != null)
             {
                 ctx.DeclareConstant(constDecl, constDecl.Unique, null);
             }
             else if (funDecl != null)
             {
                 ctx.DeclareFunction(funDecl, null);
             }
             else if (axiomDecl != null)
             {
                 ctx.AddAxiom(axiomDecl, null);
             }
             else if (glVarDecl != null)
             {
                 ctx.DeclareGlobalVariable(glVarDecl, null);
             }
         }
     }
 }
Exemple #4
0
 /// <summary>
 /// Set up the context.
 /// </summary>
 private void Setup(Program prog, ProverContext ctx)
 {
     Program = prog;
     lock (Program.TopLevelDeclarations)
     {
         foreach (Declaration decl in Program.TopLevelDeclarations)
         {
             Contract.Assert(decl != null);
             var typeDecl  = decl as TypeCtorDecl;
             var constDecl = decl as Constant;
             var funDecl   = decl as Function;
             var axiomDecl = decl as Axiom;
             var glVarDecl = decl as GlobalVariable;
             if (typeDecl != null)
             {
                 ctx.DeclareType(typeDecl, null);
             }
             else if (constDecl != null)
             {
                 ctx.DeclareConstant(constDecl, constDecl.Unique, null);
             }
             else if (funDecl != null)
             {
                 ctx.DeclareFunction(funDecl, null);
             }
             else if (axiomDecl != null)
             {
                 ctx.AddAxiom(axiomDecl, null);
             }
             else if (glVarDecl != null)
             {
                 ctx.DeclareGlobalVariable(glVarDecl, null);
             }
         }
     }
 }
Exemple #5
0
 /// <summary>
 /// Set up the context.
 /// </summary>
 private void Setup(Program prog, ProverContext ctx)
 {
     Program = prog;
       // TODO(wuestholz): Is this lock necessary?
       lock (Program.TopLevelDeclarations)
       {
     foreach (Declaration decl in Program.TopLevelDeclarations)
     {
       Contract.Assert(decl != null);
       var typeDecl = decl as TypeCtorDecl;
       var constDecl = decl as Constant;
       var funDecl = decl as Function;
       var axiomDecl = decl as Axiom;
       var glVarDecl = decl as GlobalVariable;
       if (typeDecl != null)
       {
     ctx.DeclareType(typeDecl, null);
       }
       else if (constDecl != null)
       {
     ctx.DeclareConstant(constDecl, constDecl.Unique, null);
       }
       else if (funDecl != null)
       {
     ctx.DeclareFunction(funDecl, null);
       }
       else if (axiomDecl != null)
       {
     ctx.AddAxiom(axiomDecl, null);
       }
       else if (glVarDecl != null)
       {
     ctx.DeclareGlobalVariable(glVarDecl, null);
       }
     }
       }
 }