예제 #1
0
    public TPTPProcessTheoremProver(ProverOptions options, VCExpressionGenerator gen,
                                      DeclFreeProverContext ctx)
      : base(options, "", "", "", "", gen)
    {
      Contract.Requires(options != null);
      Contract.Requires(gen != null);
      Contract.Requires(ctx != null);

      // No bg predicate at the moment
      // InitializeGlobalInformation("UnivBackPred.tptp");

      this.ctx = ctx;
      this.Gen = gen;

      TypeAxiomBuilder axBuilder;
      switch (CommandLineOptions.Clo.TypeEncodingMethod) {
        case CommandLineOptions.TypeEncoding.Arguments:
          axBuilder = new TypeAxiomBuilderArguments(gen);
          axBuilder.Setup();
          break;
        case CommandLineOptions.TypeEncoding.Monomorphic:
          axBuilder = new TypeAxiomBuilderPremisses(gen);
          break;
        default:
          axBuilder = new TypeAxiomBuilderPremisses(gen);
          axBuilder.Setup();
          break;
      }
      AxBuilder = axBuilder;
      UniqueNamer namer = new UniqueNamer();      
      Namer = namer;
      Namer.Spacer = "__";
      this.DeclCollector = new TypeDeclCollector(namer);

    }
예제 #2
0
        /////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Constructor.  Initialize a checker with the program and log file.
        /// Optionally, use prover context provided by parameter "ctx".
        /// </summary>
        public Checker(VC.ConditionGeneration vcgen, Program prog, string /*?*/ logFilePath, bool appendLogFile, int timeout, ProverContext ctx = null)
        {
            Contract.Requires(vcgen != null);
            Contract.Requires(prog != null);
            this.timeout = timeout;
            this.Program = prog;

            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;
            }

            options.Parse(CommandLineOptions.Clo.ProverOptions);

            ContextCacheKey key = new ContextCacheKey(prog);
            ProverInterface prover;

            if (vcgen.CheckerCommonState == null)
            {
                vcgen.CheckerCommonState = new Dictionary <ContextCacheKey, ProverContext>();
            }
            IDictionary <ContextCacheKey, ProverContext> /*!>!*/ cachedContexts = (IDictionary <ContextCacheKey, ProverContext /*!*/>)vcgen.CheckerCommonState;

            if (ctx == null && cachedContexts.TryGetValue(key, out ctx))
            {
                ctx    = (ProverContext)cce.NonNull(ctx).Clone();
                prover = (ProverInterface)
                         CommandLineOptions.Clo.TheProverFactory.SpawnProver(options, ctx);
            }
            else
            {
                if (ctx == null)
                {
                    ctx = (ProverContext)CommandLineOptions.Clo.TheProverFactory.NewProverContext(options);
                }

                Setup(prog, ctx);

                // we first generate the prover and then store a clone of the
                // context in the cache, so that the prover can setup stuff in
                // the context to be cached
                prover = (ProverInterface)
                         CommandLineOptions.Clo.TheProverFactory.SpawnProver(options, ctx);
                cachedContexts.Add(key, cce.NonNull((ProverContext)ctx.Clone()));
            }

            this.thmProver = prover;
            this.gen       = prover.VCExprGen;
        }
예제 #3
0
        public override object NewProverContext(ProverOptions options)
        {
            Contract.Requires(options != null);
            Contract.Ensures(Contract.Result <object>() != null);

            throw new NotImplementedException();
        }
예제 #4
0
파일: Check.cs 프로젝트: hertzel001/boogie
    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);
    }
예제 #5
0
        public override object SpawnProver(ProverOptions options, object ctxt)
        {
            //Contract.Requires(ctxt != null);
              //Contract.Requires(options != null);
              Contract.Ensures(Contract.Result<object>() != null);

              return this.SpawnProver(options,
                              cce.NonNull((SMTLibProverContext)ctxt).ExprGen,
                              cce.NonNull((SMTLibProverContext)ctxt));
        }
예제 #6
0
        protected virtual SMTLibProcessTheoremProver SpawnProver(ProverOptions options,
            VCExpressionGenerator gen,
            SMTLibProverContext ctx)
        {
            Contract.Requires(options != null);
              Contract.Requires(gen != null);
              Contract.Requires(ctx != null);
              Contract.Ensures(Contract.Result<SMTLibProcessTheoremProver>() != null);

              return new SMTLibProcessTheoremProver(options, gen, ctx);
        }
예제 #7
0
        public override object NewProverContext(ProverOptions options)
        {
            //Contract.Requires(options != null);
              Contract.Ensures(Contract.Result<object>() != null);

              VCExpressionGenerator gen = new VCExpressionGenerator();
              List<string>/*!>!*/ proverCommands = new List<string/*!*/>();
              proverCommands.Add("smtlib");
              var opts = (SMTLibProverOptions)options ;
              if (opts.Solver == SolverKind.Z3)
            proverCommands.Add("z3");
              else
            proverCommands.Add("external");
              VCGenerationOptions genOptions = new VCGenerationOptions(proverCommands);
              return new SMTLibProverContext(gen, genOptions);
        }
예제 #8
0
    public SMTLibProcessTheoremProver(ProverOptions options, VCExpressionGenerator gen,
                                      SMTLibProverContext ctx)
    {
      Contract.Requires(options != null);
      Contract.Requires(gen != null);
      Contract.Requires(ctx != null);
      
      InitializeGlobalInformation();
      
      this.options = (SMTLibProverOptions)options;
      this.ctx = ctx;
      this.gen = gen;
      this.usingUnsatCore = false;

      SetupAxiomBuilder(gen);

      Namer = new SMTLibNamer();
      ctx.parent = this;
      this.DeclCollector = new TypeDeclCollector((SMTLibProverOptions)options, Namer);

      if (CommandLineOptions.Clo.PrintFixedPoint != null || CommandLineOptions.Clo.PrintConjectures != null)
      {
          declHandler = new MyDeclHandler();
          DeclCollector.SetDeclHandler(declHandler);
      }

      SetupProcess();

      if (CommandLineOptions.Clo.StratifiedInlining > 0 || CommandLineOptions.Clo.ContractInfer
          || CommandLineOptions.Clo.SecureVcGen != null)
      {
          // Prepare for ApiChecker usage
          if (options.LogFilename != null && currentLogFile == null)
          {
              currentLogFile = OpenOutputFile("");
          }
          PrepareCommon();
      }
    }
예제 #9
0
 public override object SpawnProver(ProverOptions options, object ctxt)
 {
     return new Z3apiProcessTheoremProver((Z3InstanceOptions) options, (Z3apiProverContext) ctxt);
 }
예제 #10
0
 // Really returns ProverInterface.
 //public abstract object! SpawnProver(ProverOptions! options, object! ctxt);
 public abstract object SpawnProver(ProverOptions options, object ctxt);
예제 #11
0
 // Really returns ProverContext
 public abstract object /*!*/ NewProverContext(ProverOptions /*!*/ options);
예제 #12
0
 public virtual bool SupportsLabels(ProverOptions options)
 {
     return true;
 }
예제 #13
0
        public override object NewProverContext(ProverOptions options)
        {
            Contract.Requires(options != null);
              Contract.Ensures(Contract.Result<object>() != null);

              throw new NotImplementedException();
        }
예제 #14
0
 // Really returns ProverContext
 /*!*/
 public abstract object NewProverContext(ProverOptions/*!*/ options);
예제 #15
0
 // Really returns ProverInterface.
 //public abstract object! SpawnProver(ProverOptions! options, object! ctxt);
 public abstract object SpawnProver(ProverOptions options, object ctxt);
예제 #16
0
        public SMTLibProcessTheoremProver(ProverOptions options, VCExpressionGenerator gen,
            SMTLibProverContext ctx)
        {
            Contract.Requires(options != null);
              Contract.Requires(gen != null);
              Contract.Requires(ctx != null);

              InitializeGlobalInformation();

              this.options = (SMTLibProverOptions)options;
              this.ctx = ctx;
              this.gen = gen;
              this.usingUnsatCore = false;

              SetupAxiomBuilder(gen);

              Namer = new SMTLibNamer();
              ctx.parent = this;
              this.DeclCollector = new TypeDeclCollector((SMTLibProverOptions)options, Namer);

              SetupProcess();

              if (CommandLineOptions.Clo.StratifiedInlining > 0 || CommandLineOptions.Clo.ContractInfer)
              {
              // Prepare for ApiChecker usage
              if (options.LogFilename != null && currentLogFile == null)
              {
              currentLogFile = OpenOutputFile("");
              }
              if (CommandLineOptions.Clo.ContractInfer)
              {
              SendThisVC("(set-option :produce-unsat-cores true)");
              this.usingUnsatCore = true;
              }
              PrepareCommon();
              }
        }
예제 #17
0
    public override object NewProverContext(ProverOptions options)
    {
      //Contract.Requires(options != null);
      Contract.Ensures(Contract.Result<object>() != null);

      if (CommandLineOptions.Clo.BracketIdsInVC < 0) {
        CommandLineOptions.Clo.BracketIdsInVC = 0;
      }

      VCExpressionGenerator gen = new VCExpressionGenerator();
      List<string>/*!>!*/ proverCommands = new List<string/*!*/>();
      proverCommands.Add("tptp");
      proverCommands.Add("external");
      VCGenerationOptions genOptions = new VCGenerationOptions(proverCommands);
      Contract.Assert(genOptions != null);

      return new DeclFreeProverContext(gen, genOptions);
    }
예제 #18
0
파일: VCExp.cs 프로젝트: luckysunda/hice-dt
 public virtual bool SupportsLabels(ProverOptions options)
 {
     return(true);
 }
예제 #19
0
        public override object NewProverContext(ProverOptions opts)
        {
            if (CommandLineOptions.Clo.BracketIdsInVC < 0)
            {
                CommandLineOptions.Clo.BracketIdsInVC = 0;
            }

            VCExpressionGenerator gen = new VCExpressionGenerator();
            return new Z3apiProverContext((Z3InstanceOptions)opts, gen);
        }
예제 #20
0
 public override bool SupportsLabels(ProverOptions options)
 {
   return ((SMTLibProverOptions)options).SupportsLabels;
 }
예제 #21
0
 private static ProverOptions AddInterpOption(ProverOptions options)
 {
     var opts = (SMTLibProverOptions)options;
     opts.AddSmtOption("produce-interpolants", "true");
     if (CommandLineOptions.Clo.PrintFixedPoint == null)
         CommandLineOptions.Clo.PrintFixedPoint = "itp.fixedpoint.bpl";
     return opts;
 }
예제 #22
0
      public SMTLibInterpolatingProcessTheoremProver(ProverOptions options, VCExpressionGenerator gen,
                                        SMTLibProverContext ctx)
          : base(AddInterpOption(options), gen, ctx)
      {

      }