Solver.h

Go to the documentation of this file.
00001 //===-- Solver.h ------------------------------------------------*- C++ -*-===//
00002 //
00003 //                     The KLEE Symbolic Virtual Machine
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef KLEE_SOLVER_H
00011 #define KLEE_SOLVER_H
00012 
00013 #include "klee/Expr.h"
00014 
00015 #include <vector>
00016 
00017 namespace klee {
00018   class ConstraintManager;
00019   class Expr;
00020   class SolverImpl;
00021 
00022   struct Query {
00023   public:
00024     const ConstraintManager &constraints;
00025     ref<Expr> expr;
00026 
00027     Query(const ConstraintManager& _constraints, ref<Expr> _expr)
00028       : constraints(_constraints), expr(_expr) {
00029     }
00030 
00032     Query withExpr(ref<Expr> _expr) const {
00033       return Query(constraints, _expr);
00034     }
00035 
00037     Query withFalse() const {
00038       return Query(constraints, ConstantExpr::alloc(0, Expr::Bool));
00039     }
00040 
00042     Query negateExpr() const {
00043       return withExpr(Expr::createNot(expr));
00044     }
00045   };
00046 
00047   class Solver {
00048     // DO NOT IMPLEMENT.
00049     Solver(const Solver&);
00050     void operator=(const Solver&);
00051 
00052   public:
00053     enum Validity {
00054       True = 1,
00055       False = -1,
00056       Unknown = 0
00057     };
00058   
00059   public:
00061     static const char *validity_to_str(Validity v);
00062 
00063   public:
00064     SolverImpl *impl;
00065 
00066   public:
00067     Solver(SolverImpl *_impl) : impl(_impl) {};
00068     virtual ~Solver();
00069 
00077     bool evaluate(const Query&, Validity &result);
00078   
00085     bool mustBeTrue(const Query&, bool &result);
00086 
00093     bool mustBeFalse(const Query&, bool &result);
00094 
00102     bool mayBeTrue(const Query&, bool &result);
00103 
00111     bool mayBeFalse(const Query&, bool &result);
00112 
00119     bool getValue(const Query&, ref<ConstantExpr> &result);
00120 
00132     //
00133     // FIXME: This API is lame. We should probably just provide an API which
00134     // returns an Assignment object, then clients can get out whatever values
00135     // they want. This also allows us to optimize the representation.
00136     bool getInitialValues(const Query&, 
00137                           const std::vector<const Array*> &objects,
00138                           std::vector< std::vector<unsigned char> > &result);
00139 
00148     //
00149     // FIXME: This should go into a helper class, and should handle failure.
00150     virtual std::pair< ref<Expr>, ref<Expr> > getRange(const Query&);
00151   };
00152 
00154   class STPSolver : public Solver {
00155   public:
00160     STPSolver(bool useForkedSTP);
00161 
00162     
00163     
00166     char *getConstraintLog(const Query&);
00167     
00170     void setTimeout(double timeout);
00171   };
00172 
00173   /* *** */
00174 
00182   Solver *createValidatingSolver(Solver *s, Solver *oracle);
00183 
00188   Solver *createCachingSolver(Solver *s);
00189 
00196   Solver *createCexCachingSolver(Solver *s);
00197 
00203   Solver *createFastCexSolver(Solver *s);
00204 
00210   Solver *createIndependentSolver(Solver *s);
00211   
00214   Solver *createPCLoggingSolver(Solver *s, std::string path);
00215 
00216 }
00217 
00218 #endif

Generated on Fri Jun 5 03:31:31 2009 for klee by  doxygen 1.5.8