/************************************************************************************************** MiniSat -- Copyright (c) 2003-2005, Niklas Een, Niklas Sorensson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************************************/ #ifndef SolverTypes_h #define SolverTypes_h #ifndef Global_h #include "Global.h" #endif //================================================================================================= // Variables, literals: // NOTE! Variables are just integers. No abstraction here. They should be chosen from 0..N, // so that they can be used as array indices. typedef int Var; #define var_Undef (-1) class Lit { int x; public: Lit(void) /* unspecifed value allowed for efficiency */ { } explicit Lit(Var var, bool sign = false) : x((var+var) + sign) { } friend Lit operator ~ (Lit p) { Lit q; q.x = p.x ^ 1; return q; } friend bool sign (Lit p) { return p.x & 1; } friend int var (Lit p) { return p.x >> 1; } friend int index(Lit p) { return p.x; } // A "toInt" method that guarantees small, positive integers suitable for array indexing. friend Lit toLit(int i) { Lit p; p.x = i; return p; } friend bool operator == (Lit p, Lit q) { return index(p) == index(q); } friend bool operator < (Lit p, Lit q) { return index(p) < index(q); } // '<' guarantees that p, ~p are adjacent in the ordering. }; const Lit lit_Undef(var_Undef, false); // }- Useful special constants. const Lit lit_Error(var_Undef, true ); // } //================================================================================================= #endif