diff --git a/CASC/PortfolioMode.hpp b/CASC/PortfolioMode.hpp index 553616668..8640281d8 100644 --- a/CASC/PortfolioMode.hpp +++ b/CASC/PortfolioMode.hpp @@ -30,7 +30,6 @@ namespace CASC { -using namespace Lib; using namespace Shell; class PortfolioMode { @@ -54,7 +53,7 @@ class PortfolioMode { [[noreturn]] void runSlice(Options& strategyOpt); #if VDEBUG - DHSet childIds; + Lib::DHSet childIds; #endif unsigned _numWorkers; // file that will contain a proof @@ -66,7 +65,7 @@ class PortfolioMode { * Note that in the current process this child object is the only one that * will be using the problem object. */ - ScopedPtr _prb; + Lib::ScopedPtr _prb; float _slowness; }; diff --git a/DP/DecisionProcedure.hpp b/DP/DecisionProcedure.hpp index 3153978b8..cf0b0ea9f 100644 --- a/DP/DecisionProcedure.hpp +++ b/DP/DecisionProcedure.hpp @@ -19,7 +19,6 @@ namespace DP { -using namespace Lib; using namespace Kernel; /** diff --git a/DP/ShortConflictMetaDP.cpp b/DP/ShortConflictMetaDP.cpp index 900939a24..38873a70f 100644 --- a/DP/ShortConflictMetaDP.cpp +++ b/DP/ShortConflictMetaDP.cpp @@ -18,6 +18,7 @@ namespace DP { using namespace std; +using namespace Lib; /** * Computes number of literals in core not implied at the zero level diff --git a/DP/ShortConflictMetaDP.hpp b/DP/ShortConflictMetaDP.hpp index dbfd04a75..70eaff9b7 100644 --- a/DP/ShortConflictMetaDP.hpp +++ b/DP/ShortConflictMetaDP.hpp @@ -28,7 +28,6 @@ namespace DP { -using namespace Lib; using namespace Kernel; using namespace SAT; @@ -70,9 +69,9 @@ class ShortConflictMetaDP : public DecisionProcedure { unsigned getCoreSize(const LiteralStack& core); - Stack _unsatCores; + Lib::Stack _unsatCores; - ScopedPtr _inner; + Lib::ScopedPtr _inner; SAT2FO& _sat2fo; SATSolver& _solver; }; diff --git a/DP/SimpleCongruenceClosure.cpp b/DP/SimpleCongruenceClosure.cpp index 6ef37706b..381a3cf30 100644 --- a/DP/SimpleCongruenceClosure.cpp +++ b/DP/SimpleCongruenceClosure.cpp @@ -32,6 +32,7 @@ namespace DP { using namespace std; +using namespace Lib; const unsigned SimpleCongruenceClosure::NO_SIG_SYMBOL = 0xFFFFFFFF; diff --git a/DP/SimpleCongruenceClosure.hpp b/DP/SimpleCongruenceClosure.hpp index 321e47f75..67a8342c5 100644 --- a/DP/SimpleCongruenceClosure.hpp +++ b/DP/SimpleCongruenceClosure.hpp @@ -29,7 +29,6 @@ namespace DP { -using namespace Lib; using namespace Kernel; /** @@ -163,7 +162,7 @@ class SimpleCongruenceClosure : public DecisionProcedure void propagate(); unsigned getProofDepth(unsigned c); - void collectUnifyingPath(unsigned c1, unsigned c2, Stack& path); + void collectUnifyingPath(unsigned c1, unsigned c2, Lib::Stack& path); static const unsigned NO_SIG_SYMBOL; struct ConstInfo @@ -202,14 +201,14 @@ class SimpleCongruenceClosure : public DecisionProcedure /** If reprConst==0, contains other constants whose representative * this constant is */ - Stack classList; + Lib::Stack classList; /** * If reprConst==0, contains list of pair names in whose pairs this * constant appears as a representative of one of the arguments. * Irregardless of the value of reprConst, also contains representatives * of all pairs that have this very constant as one of arguments. */ - Stack useList; + Lib::Stack useList; // needed for getModel: /** @@ -219,7 +218,7 @@ class SimpleCongruenceClosure : public DecisionProcedure /** * Meaningful for representatives. A list of edges leaving the class "upwards". */ - Stack upEdges; + Lib::Stack upEdges; /** * Meaningful for namedPairs. * @@ -239,7 +238,7 @@ class SimpleCongruenceClosure : public DecisionProcedure }; struct ConstOrderingComparator; - typedef DHMap NFMap; + typedef Lib::DHMap NFMap; void computeConstsNormalForm(unsigned c, NFMap& normalForms); #if VDEBUG @@ -253,7 +252,7 @@ class SimpleCongruenceClosure : public DecisionProcedure * of constants in special cases, such as to indicate that there is * no constant. */ - DArray _cInfos; + Lib::DArray _cInfos; /** Positive literals are made equivalent to this constant */ unsigned _posLitConst; @@ -263,31 +262,31 @@ class SimpleCongruenceClosure : public DecisionProcedure /** * Map from signature symbols to the local constant numbers. */ - DHMap,unsigned> _sigConsts; + Lib::DHMap,unsigned> _sigConsts; - typedef DHMap PairMap; + typedef Lib::DHMap PairMap; /** Names of constant pairs (modulo the congruence!)*/ PairMap _pairNames; /** Constants corresponding to terms */ - DHMap _termNames; + Lib::DHMap _termNames; /** Constants corresponding to literals */ - DHMap _litNames; + Lib::DHMap _litNames; /** * Equality that caused unsatisfiability; if CEq::isInvalid(), there isn't such. */ - Stack _unsatEqs; - Deque _pendingEqualities; - Stack _negEqualities; + Lib::Stack _unsatEqs; + Lib::Deque _pendingEqualities; + Lib::Stack _negEqualities; struct DistinctEntry { DistinctEntry(Literal* l) : _lit(l) {} Literal* _lit; - Stack _consts; + Lib::Stack _consts; }; - typedef Stack DistinctStack; + typedef Lib::Stack DistinctStack; DistinctStack _distinctConstraints; /** Negated distinct constraints, these can lead to an UNKNOWN satisfiability result * diff --git a/Debug/RuntimeStatistics.cpp b/Debug/RuntimeStatistics.cpp index eabcacf4f..385fd3a13 100644 --- a/Debug/RuntimeStatistics.cpp +++ b/Debug/RuntimeStatistics.cpp @@ -25,6 +25,7 @@ namespace Debug { using namespace std; +using namespace Lib; void RSMultiCounter::print(ostream& out) { diff --git a/Debug/RuntimeStatistics.hpp b/Debug/RuntimeStatistics.hpp index 0f87e9ff9..6d84c97b1 100644 --- a/Debug/RuntimeStatistics.hpp +++ b/Debug/RuntimeStatistics.hpp @@ -87,7 +87,6 @@ square's last digit: namespace Debug { -using namespace Lib; class RSObject { @@ -127,13 +126,13 @@ class RSMultiCounter void print(std::ostream& out); void inc(size_t index) { _counters[index]++; } private: - ZIArray _counters; + Lib::ZIArray _counters; }; class RSMultiStatistic : public RSObject { - typedef List ValList; + typedef Lib::List ValList; public: RSMultiStatistic(const char* name) : RSObject(name) {} ~RSMultiStatistic(); @@ -141,7 +140,7 @@ class RSMultiStatistic void print(std::ostream& out); void addRecord(size_t index, int value) { ValList::push(value, _values[index]); } private: - ZIArray _values; + Lib::ZIArray _values; }; class RuntimeStatistics @@ -151,8 +150,9 @@ class RuntimeStatistics struct RSObjComparator { - static Comparison compare(const char* name, RSObject* o2) + static Lib::Comparison compare(const char* name, RSObject* o2) { + using namespace Lib; int res=strcmp(name, o2->name()); return (res>0) ? GREATER : ((res==0) ? EQUAL : LESS); } @@ -175,7 +175,7 @@ class RuntimeStatistics RuntimeStatistics(); ~RuntimeStatistics(); - typedef SkipList ObjSkipList; + typedef Lib::SkipList ObjSkipList; ObjSkipList _objs; }; diff --git a/Debug/Tracer.cpp b/Debug/Tracer.cpp index d063b45c3..c8d876476 100644 --- a/Debug/Tracer.cpp +++ b/Debug/Tracer.cpp @@ -54,7 +54,7 @@ void Debug::Tracer::printStack(std::ostream& str) { str << ' ' << call_stack[sz - (i + 1)]; str << std::endl; - if (env.options->traceback()) { + if (Lib::env.options->traceback()) { // UNIX-like systems, including BSD and Linux but not MacOS #if defined(__unix__) str << "invoking addr2line(1) ..." << std::endl; diff --git a/FMB/ClauseFlattening.cpp b/FMB/ClauseFlattening.cpp index f792ef201..829ca1ab9 100644 --- a/FMB/ClauseFlattening.cpp +++ b/FMB/ClauseFlattening.cpp @@ -29,6 +29,7 @@ namespace FMB{ using namespace std; +using namespace Lib; bool ClauseFlattening::isShallow(Literal* lit) { diff --git a/FMB/CliqueFinder.hpp b/FMB/CliqueFinder.hpp index 1d22491fb..41b69a0c3 100644 --- a/FMB/CliqueFinder.hpp +++ b/FMB/CliqueFinder.hpp @@ -21,23 +21,23 @@ namespace FMB { class CliqueFinder { public: - static unsigned findMaxCliqueSize(DHMap*>* Ngraph) + static unsigned findMaxCliqueSize(Lib::DHMap*>* Ngraph) { //std::cout << "findMaxCliqueSize with " << Ngraph->size() << std::endl; // at least stores the number of nodes with at least index neighbours - DArray> atleast; + Lib::DArray> atleast; atleast.ensure(Ngraph->size()+1); // the +1 is to protect against a self-loop sneaking in - DHMap*>::Iterator miter(*Ngraph); + Lib::DHMap*>::Iterator miter(*Ngraph); while(miter.hasNext()){ unsigned c; - DHSet* nbs; + Lib::DHSet* nbs; miter.next(c,nbs); unsigned size = nbs->size(); //std::cout << ">> " << c << ": " << size << std::endl; - //DHSet::Iterator dit(*nbs); + //Lib::DHSet::Iterator dit(*nbs); //while(dit.hasNext()){ std::cout << dit.next() << std::endl; } for(;size>0;size--){ @@ -61,13 +61,13 @@ namespace FMB { else if (atleast[i].size() > i+1){ //std::cout << "CASE 2" << std::endl; unsigned left = atleast[i].size(); - Stack::Iterator niter(atleast[i]); + Lib::Stack::Iterator niter(atleast[i]); while(niter.hasNext() && left >= i+1){ unsigned c = niter.next(); //std::cout << ">> " << c << std::endl; auto ns = Ngraph->get(c); if(ns->size()==i){ - Stack clique; + Lib::Stack clique; clique.loadFromIterator(ns->iterator()); clique.push(c); if(checkClique(Ngraph,clique)){ @@ -89,7 +89,7 @@ namespace FMB { private: // check if a clique is a clique - static bool checkClique(DHMap*>* Ngraph, Stack& clique) + static bool checkClique(Lib::DHMap*>* Ngraph, Lib::Stack& clique) { //std::cout << "CHECK "; for(unsigned j=0;jget(c1); //std::cout << c1 << " neighbours: "; - //DHSet::Iterator pit(*ns);while(pit.hasNext()){std::cout << pit.next() << " ";};std::cout<::Iterator pit(*ns);while(pit.hasNext()){std::cout << pit.next() << " ";};std::cout<fmbNonGroundDefs(); + //_ng = Lib::env.options->fmbNonGroundDefs(); } @@ -59,7 +59,7 @@ namespace FMB { void process(Clause* c){ //std::cout << "Process " << c->toString() << std::endl; - static Stack lits; // to rebuild the clause + static Lib::Stack lits; // to rebuild the clause lits.reset(); bool anyUpdated = false; @@ -70,7 +70,7 @@ namespace FMB { //std::cout << " process " << l->toString() << std::endl; - Stack args; + Lib::Stack args; for(TermList* ts = l->args(); ts->isNonEmpty(); ts = ts->next()){ // do not add definitions for variables or constants if(ts->isVar() || ts->term()->arity()==0 || !ts->term()->ground()){ @@ -116,9 +116,9 @@ namespace FMB { //std::cout << "Considering " << t->toString() << std::endl; if(t->arity()==0) continue; if(!_introduced.find(t)){ - unsigned newConstant = env.signature->addFreshFunction(0,"fmbdef"); + unsigned newConstant = Lib::env.signature->addFreshFunction(0,"fmbdef"); TermList srt = SortHelper::getResultSort(t); - Signature::Symbol* newConstantSymb = env.signature->getFunction(newConstant); + Signature::Symbol* newConstantSymb = Lib::env.signature->getFunction(newConstant); newConstantSymb->setType(OperatorType::getConstantsType(srt)); newConstantSymb->incUsageCnt(); Term* c = Term::createConstant(newConstant); @@ -127,7 +127,7 @@ namespace FMB { //Now apply definitions to t bool updated = false; - Stack args; + Lib::Stack args; for(TermList* ts = t->args(); ts->isNonEmpty(); ts = ts->next()){ ASS(ts->term()->ground()); // do not add definitions for constants @@ -143,7 +143,7 @@ namespace FMB { } TermList sort = SortHelper::getResultSort(t); //TODO set sort of c as this Literal* l = Literal::createEquality(true,TermList(t),TermList(c),sort); - static Stack lstack; + static Lib::Stack lstack; lstack.reset(); lstack.push(l); Clause* def = Clause::fromStack(lstack,NonspecificInference1(InferenceRule::FMB_DEF_INTRO,from)); @@ -184,13 +184,13 @@ namespace FMB { unsigned vars = t->vars(); // then create a fresh function symbol for the definition - newf = env.signature->addFreshFunction(vars,"fmbdef"); + newf = Lib::env.signature->addFreshFunction(vars,"fmbdef"); // and save it _introducedNG.insert(t,newf); // next create the definition clause - Stack varTerms; + Lib::Stack varTerms; for(unsigned v=0;v lstack; + static Lib::Stack lstack; lstack.reset(); lstack.push(l); Clause* def = Clause::fromStack(lstack,from->inputType(), @@ -219,10 +219,10 @@ namespace FMB { bool _ng; */ ClauseIterator _cit; - Stack _processed; + Lib::Stack _processed; - DHMap _introduced; - DHMap _introducedNG; + Lib::DHMap _introduced; + Lib::DHMap _introducedNG; }; diff --git a/FMB/FiniteModel.hpp b/FMB/FiniteModel.hpp index 169a54669..8e03aa3aa 100644 --- a/FMB/FiniteModel.hpp +++ b/FMB/FiniteModel.hpp @@ -27,7 +27,6 @@ namespace FMB { -using namespace Lib; using namespace Kernel; /** @@ -43,10 +42,10 @@ class FiniteModel { // Assume def is an equality literal with a // function application on lhs and constant on rhs void addConstantDefinition(unsigned f, unsigned res); - void addFunctionDefinition(unsigned f, const DArray& args, unsigned res); + void addFunctionDefinition(unsigned f, const Lib::DArray& args, unsigned res); // Assume def is non-equality ground literal void addPropositionalDefinition(unsigned f, bool res); - void addPredicateDefinition(unsigned f, const DArray& args, bool res); + void addPredicateDefinition(unsigned f, const Lib::DArray& args, bool res); bool isPartial(); @@ -65,23 +64,23 @@ class FiniteModel { // The model is partial if there is a operation with arity n that does not have // coverage size^n in its related coverage map bool _isPartial; - DHMap _functionCoverage; - DHMap _predicateCoverage; + Lib::DHMap _functionCoverage; + Lib::DHMap _predicateCoverage; - DArray f_offsets; - DArray p_offsets; - DArray f_interpretation; - DArray p_interpretation; // 0 is undef, 1 false, 2 true + Lib::DArray f_offsets; + Lib::DArray p_offsets; + Lib::DArray f_interpretation; + Lib::DArray p_interpretation; // 0 is undef, 1 false, 2 true - DHMap _domainConstants; - DHMap _domainConstantsRev; + Lib::DHMap _domainConstants; + Lib::DHMap _domainConstantsRev; public: Term* getDomainConstant(unsigned c) { Term* t; if(_domainConstants.find(c,t)) return t; std::string name = "domainConstant";//+Lib::Int::toString(c); - unsigned f = env.signature->addFreshFunction(0,name.c_str()); + unsigned f = Lib::env.signature->addFreshFunction(0,name.c_str()); t = Term::createConstant(f); _domainConstants.insert(c,t); _domainConstantsRev.insert(t,c); diff --git a/FMB/FiniteModelBuilder.cpp b/FMB/FiniteModelBuilder.cpp index fa8b7704d..350d92684 100644 --- a/FMB/FiniteModelBuilder.cpp +++ b/FMB/FiniteModelBuilder.cpp @@ -73,6 +73,7 @@ namespace FMB { using namespace std; +using namespace Lib; FiniteModelBuilder::FiniteModelBuilder(Problem& prb, const Options& opt) : MainLoop(prb, opt), _sortedSignature(0), _groundClauses(0), _clauses(0), diff --git a/FMB/FiniteModelBuilder.hpp b/FMB/FiniteModelBuilder.hpp index 374ca2641..6929dcdef 100644 --- a/FMB/FiniteModelBuilder.hpp +++ b/FMB/FiniteModelBuilder.hpp @@ -29,7 +29,6 @@ #include "Lib/BinaryHeap.hpp" namespace FMB { -using namespace Lib; using namespace Kernel; using namespace Inferences; using namespace Shell; @@ -42,7 +41,7 @@ using namespace SAT; */ struct GroundedTerm{ unsigned f; - DArray grounding; + Lib::DArray grounding; std::string toString(){ std::string ret = Lib::Int::toString(f)+"["; @@ -89,9 +88,9 @@ class FiniteModelBuilder : public MainLoop { void addNewTotalityDefs(); // Add constraints for symmetry ordering i.e. the first modelSize groundedTerms are ordered - void addNewSymmetryOrderingAxioms(unsigned modelSize,Stack& groundedTerms); + void addNewSymmetryOrderingAxioms(unsigned modelSize,Lib::Stack& groundedTerms); // Add constraints for canonicity of symmetry order i.e. if a groundedTerm uses a constant smaller terms use smaller constants - void addNewSymmetryCanonicityAxioms(unsigned modelSize,Stack& groundedTerms,unsigned maxModelSize); + void addNewSymmetryCanonicityAxioms(unsigned modelSize,Lib::Stack& groundedTerms,unsigned maxModelSize); // Add all symmetry constraints // For each model size up to the maximum add both ordering and canonicity constraints for each (inferred) sort @@ -115,7 +114,7 @@ class FiniteModelBuilder : public MainLoop { // Converts a grounded term (literal) into a SATLiteral // The elements are the domain constants to use as parameters // polarity is used if isFunction is false - SATLiteral getSATLiteral(unsigned func, const DArray& elements,bool polarity, + SATLiteral getSATLiteral(unsigned func, const Lib::DArray& elements,bool polarity, bool isFunction); // resets all structures and SAT solver using _sortModelSizes @@ -124,22 +123,22 @@ class FiniteModelBuilder : public MainLoop { // make the symmetry orderings void createSymmetryOrdering(); // The per-sort ordering of grounded terms used for symmetry breaking - DArray> _sortedGroundedTerms; + Lib::DArray> _sortedGroundedTerms; unsigned _curMaxVar; // SAT solver used to solve constraints (a new one is used for each model size) - ScopedPtr _solver; + Lib::ScopedPtr _solver; // Structures to record symbols removed during preprocessing i.e. via definition elimination // These are ignored throughout finite model building and then the definitions (recorded here) // are used to give the interpretation of the function/predicate if a model is found - DHMap _deletedFunctions; - DHMap _deletedPredicates; - DHMap _partiallyDeletedPredicates; - DHMap _trivialPredicates; + Lib::DHMap _deletedFunctions; + Lib::DHMap _deletedPredicates; + Lib::DHMap _partiallyDeletedPredicates; + Lib::DHMap _trivialPredicates; // if del_f[i] (resp del_p[i]) is true then that function (resp predicate) should be ignored - DArray del_f; - DArray del_p; + Lib::DArray del_f; + Lib::DArray del_p; // Add a SATClause to the SAT solver void addSATClause(SATClause* cl); @@ -160,16 +159,16 @@ class FiniteModelBuilder : public MainLoop { ClauseList* _clauses; // Record for function symbol the minimum bound of the return sort or any parameter sorts - DArray _fminbound; + Lib::DArray _fminbound; // Record for each clause the sorts of the variables // As clauses are normalized variables will be numbered 0,1,... - DHMap*> _clauseVariableSorts; + Lib::DHMap*> _clauseVariableSorts; // There is a implicit mapping from ground terms to SAT variables // These offsets give the SAT variable for the *first* grounding of each function or predicate symbol // Then the SAT variables for other groundings can be computed from this - DArray f_offsets; - DArray p_offsets; + Lib::DArray f_offsets; + Lib::DArray p_offsets; // do contour encoding instead of point-wise bool _xmass; @@ -179,7 +178,7 @@ class FiniteModelBuilder : public MainLoop { /* Each distinctSort has as many markers as is its current size. * Their offsets are stored on per sort basis. */ - DArray marker_offsets; + Lib::DArray marker_offsets; // } else { @@ -224,8 +223,8 @@ class FiniteModelBuilder : public MainLoop { unsigned _sizeWeightRatio; // sizes to use for each sort - DArray _sortModelSizes; - DArray _distinctSortSizes; + Lib::DArray _sortModelSizes; + Lib::DArray _distinctSortSizes; enum ConstraintSign { EQ, // the value has to matched @@ -234,13 +233,13 @@ class FiniteModelBuilder : public MainLoop { STAR // we don't care about this value }; - typedef DArray> Constraint_Generator_Vals; + typedef Lib::DArray> Constraint_Generator_Vals; class DSAEnumerator { // Domain Size Assignment Enumerator - for the point-wise encoding case public: - virtual bool init(unsigned, DArray&, Stack>&, Stack>&) { return true; } + virtual bool init(unsigned, Lib::DArray&, Lib::Stack>&, Lib::Stack>&) { return true; } virtual void learnNogood(Constraint_Generator_Vals& nogood, unsigned weight) = 0; - virtual bool increaseModelSizes(DArray& newSortSizes, DArray& sortMaxes) = 0; + virtual bool increaseModelSizes(Lib::DArray& newSortSizes, Lib::DArray& sortMaxes) = 0; virtual bool isFmbComplete(unsigned noDomains) { return false; } virtual ~DSAEnumerator() {} }; @@ -259,14 +258,17 @@ class FiniteModelBuilder : public MainLoop { }; struct Constraint_Generator_Compare { - static Comparison compare (Constraint_Generator* c1, Constraint_Generator* c2) - { return c1->_weight < c2->_weight ? LESS : c1->_weight == c2->_weight ? EQUAL : GREATER; } + static Lib::Comparison compare (Constraint_Generator* c1, Constraint_Generator* c2) + { + using namespace Lib; + return c1->_weight < c2->_weight ? LESS : c1->_weight == c2->_weight ? EQUAL : GREATER; + } }; typedef Lib::BinaryHeap Constraint_Generator_Heap; - Stack>* _distinct_sort_constraints; - Stack>* _strict_distinct_sort_constraints; + Lib::Stack>* _distinct_sort_constraints; + Lib::Stack>* _strict_distinct_sort_constraints; /** * Constraints are at the same time used as generators. @@ -278,14 +280,14 @@ class FiniteModelBuilder : public MainLoop { bool _skippedSomeSizes; bool _keepOldGenerators; - Stack _old_generators; // keeping old generators degraded performance on average ... + Lib::Stack _old_generators; // keeping old generators degraded performance on average ... protected: - bool checkConstriant(DArray& newSortSizes, Constraint_Generator_Vals& constraint); + bool checkConstriant(Lib::DArray& newSortSizes, Constraint_Generator_Vals& constraint); public: HackyDSAE(bool keepOldGenerators) : _maxWeightSoFar(0), _keepOldGenerators(keepOldGenerators) {} - bool init(unsigned _startSize, DArray&, Stack>& dsc, Stack>& sdsc) override { + bool init(unsigned _startSize, Lib::DArray&, Lib::Stack>& dsc, Lib::Stack>& sdsc) override { _skippedSomeSizes = (_startSize > 1); _distinct_sort_constraints = &dsc; _strict_distinct_sort_constraints = &sdsc; @@ -294,7 +296,7 @@ class FiniteModelBuilder : public MainLoop { bool isFmbComplete(unsigned noDomains) override { return (noDomains <= 1) && !_skippedSomeSizes; } void learnNogood(Constraint_Generator_Vals& nogood, unsigned weight) override; - bool increaseModelSizes(DArray& newSortSizes, DArray& sortMaxes) override; + bool increaseModelSizes(Lib::DArray& newSortSizes, Lib::DArray& sortMaxes) override; }; #if VZ3 @@ -302,32 +304,32 @@ class FiniteModelBuilder : public MainLoop { z3::context _context; z3::solver _smtSolver; unsigned _lastWeight; - DArray _sizeConstants; + Lib::DArray _sizeConstants; bool _skippedSomeSizes; protected: - unsigned loadSizesFromSmt(DArray& szs); + unsigned loadSizesFromSmt(Lib::DArray& szs); void reportZ3OutOfMemory(); public: SmtBasedDSAE() : _smtSolver(_context) {} - bool init(unsigned, DArray&, Stack>&, Stack>&) override; + bool init(unsigned, Lib::DArray&, Lib::Stack>&, Lib::Stack>&) override; void learnNogood(Constraint_Generator_Vals& nogood, unsigned weight) override; - bool increaseModelSizes(DArray& newSortSizes, DArray& sortMaxes) override; + bool increaseModelSizes(Lib::DArray& newSortSizes, Lib::DArray& sortMaxes) override; bool isFmbComplete(unsigned) override { return !_skippedSomeSizes; } }; #endif // the sort constraints from injectivity/surjectivity // pairs of distinct sorts where pair.first >= pair.second - Stack> _distinct_sort_constraints; + Lib::Stack> _distinct_sort_constraints; // pairs of distinct sorts where pair.first > pair.second - Stack> _strict_distinct_sort_constraints; + Lib::Stack> _strict_distinct_sort_constraints; // Record the number of constants in the problem per distinct sort - DArray _distinctSortConstantCount; + Lib::DArray _distinctSortConstantCount; // min and max sizes for distinct sorts - DArray _distinctSortMins; - DArray _distinctSortMaxs; + Lib::DArray _distinctSortMins; + Lib::DArray _distinctSortMaxs; //unsigned _maxModelSizeAllSorts; public: // debugging diff --git a/FMB/FiniteModelMultiSorted.hpp b/FMB/FiniteModelMultiSorted.hpp index f158f374f..393e58519 100644 --- a/FMB/FiniteModelMultiSorted.hpp +++ b/FMB/FiniteModelMultiSorted.hpp @@ -27,7 +27,6 @@ namespace FMB { -using namespace Lib; using namespace Kernel; /** @@ -35,20 +34,20 @@ using namespace Kernel; * */ class FiniteModelMultiSorted { - DHMap _sizes; + Lib::DHMap _sizes; public: // sortSizes is a map from vampire sorts (defined in Kernel/Sorts) to the size of that sort - FiniteModelMultiSorted(DHMap sortSizes); + FiniteModelMultiSorted(Lib::DHMap sortSizes); // Assume def is an equality literal with a // function application on lhs and constant on rhs void addConstantDefinition(unsigned f, unsigned res); - void addFunctionDefinition(unsigned f, const DArray& args, unsigned res); + void addFunctionDefinition(unsigned f, const Lib::DArray& args, unsigned res); // Assume def is non-equality ground literal void addPropositionalDefinition(unsigned f, bool res); - void addPredicateDefinition(unsigned f, const DArray& args, bool res); + void addPredicateDefinition(unsigned f, const Lib::DArray& args, bool res); bool isPartial(); @@ -67,29 +66,29 @@ class FiniteModelMultiSorted { // The model is partial if there is a operation with arity n that does not have // coverage size^n in its related coverage map bool _isPartial; - DHMap _functionCoverage; - DHMap _predicateCoverage; + Lib::DHMap _functionCoverage; + Lib::DHMap _predicateCoverage; - DArray> sortRepr; + Lib::DArray> sortRepr; - DArray f_offsets; - DArray p_offsets; - DArray f_interpretation; - DArray p_interpretation; // 0 is undef, 1 false, 2 true + Lib::DArray f_offsets; + Lib::DArray p_offsets; + Lib::DArray f_interpretation; + Lib::DArray p_interpretation; // 0 is undef, 1 false, 2 true // the pairs of - DHMap,Term*> _domainConstants; - DHMap> _domainConstantsRev; + Lib::DHMap,Term*> _domainConstants; + Lib::DHMap> _domainConstantsRev; public: Term* getDomainConstant(unsigned c, unsigned srt) { Term* t; std::pair pair = std::make_pair(c,srt); if(_domainConstants.find(pair,t)) return t; - std::string name = "domCon_"+env.signature->typeConName(srt)+"_"+Lib::Int::toString(c); - unsigned f = env.signature->addFreshFunction(0,name.c_str()); + std::string name = "domCon_"+Lib::env.signature->typeConName(srt)+"_"+Lib::Int::toString(c); + unsigned f = Lib::env.signature->addFreshFunction(0,name.c_str()); TermList srtT = TermList(AtomicSort::createConstant(srt)); - env.signature->getFunction(f)->setType(OperatorType::getConstantsType(srtT)); + Lib::env.signature->getFunction(f)->setType(OperatorType::getConstantsType(srtT)); t = Term::createConstant(f); _domainConstants.insert(pair,t); _domainConstantsRev.insert(t,pair); diff --git a/FMB/FunctionRelationshipInference.cpp b/FMB/FunctionRelationshipInference.cpp index 3bd176be8..7f1b6eb0a 100644 --- a/FMB/FunctionRelationshipInference.cpp +++ b/FMB/FunctionRelationshipInference.cpp @@ -48,6 +48,7 @@ namespace FMB { using namespace std; +using namespace Lib; using namespace Shell; void FunctionRelationshipInference::findFunctionRelationships(ClauseIterator clauses, diff --git a/FMB/FunctionRelationshipInference.hpp b/FMB/FunctionRelationshipInference.hpp index 68ffd029e..f6600c722 100644 --- a/FMB/FunctionRelationshipInference.hpp +++ b/FMB/FunctionRelationshipInference.hpp @@ -24,7 +24,6 @@ namespace FMB { -using namespace Lib; using namespace Kernel; /** @@ -36,9 +35,9 @@ class FunctionRelationshipInference { public: void findFunctionRelationships(ClauseIterator clauses, - Stack*>& eq_classes, - DHSet>& nonstrict_cons, - DHSet>& strict_cons); + Lib::Stack*>& eq_classes, + Lib::DHSet>& nonstrict_cons, + Lib::DHSet>& strict_cons); private: @@ -52,8 +51,8 @@ void addClaimForFunction(TermList x, TermList y, TermList fx, TermList fy, void addClaim(Formula* conjecture, ClauseList*& newClauses); Formula* getName(TermList fromSort, TermList toSort, bool strict); -DHMap> _labelMap_nonstrict; -DHMap> _labelMap_strict; +Lib::DHMap> _labelMap_nonstrict; +Lib::DHMap> _labelMap_strict; }; diff --git a/FMB/ModelCheck.hpp b/FMB/ModelCheck.hpp index 85d91841a..776869521 100644 --- a/FMB/ModelCheck.hpp +++ b/FMB/ModelCheck.hpp @@ -32,7 +32,6 @@ namespace FMB{ -using namespace Lib; using namespace Kernel; class ModelCheck{ @@ -45,7 +44,7 @@ static void doCheck(UnitList* units) // Currently assume it is called 'finite_domain' // TODO search for something of the right shape unsigned modelSize = 0; - Set domainConstants; + Lib::Set domainConstants; { UnitList::Iterator uit(units); while(uit.hasNext()){ @@ -89,8 +88,8 @@ static void doCheck(UnitList* units) std::cout << "Distinct domain assumed, domain elements are:" << std::endl; // number the domain constants - DHMap domainConstantNumber; - Set::Iterator dit(domainConstants); + Lib::DHMap domainConstantNumber; + Lib::Set::Iterator dit(domainConstants); unsigned count=1; while(dit.hasNext()){ Term* con = dit.next(); @@ -161,7 +160,7 @@ static void doCheck(UnitList* units) private: -static void checkIsDomainLiteral(Literal* l, int& single_var, Set& domainConstants) +static void checkIsDomainLiteral(Literal* l, int& single_var, Lib::Set& domainConstants) { if(!l->isEquality()) USER_ERROR("finite_domain is not a domain axiom"); @@ -180,7 +179,7 @@ static void checkIsDomainLiteral(Literal* l, int& single_var, Set& domain // store and check the ground constant used Term* constant = right->term(); unsigned f = constant->functor(); - if(env.signature->functionArity(f)!=0) USER_ERROR("finite_domain is not a domain axiom"); + if(Lib::env.signature->functionArity(f)!=0) USER_ERROR("finite_domain is not a domain axiom"); if(domainConstants.contains(constant)) USER_ERROR("finite_domain is not a domain axiom"); domainConstants.insert(constant); @@ -189,8 +188,8 @@ static void checkIsDomainLiteral(Literal* l, int& single_var, Set& domain } static void addDefinition(FiniteModel& model,Literal* lit,bool negated, - Set& domainConstants, - DHMap& domainConstantNumber) + Lib::Set& domainConstants, + Lib::DHMap& domainConstantNumber) { if(lit->isEquality()){ if(!lit->polarity() || negated) USER_ERROR("Cannot have negated function definition"); @@ -207,10 +206,10 @@ static void addDefinition(FiniteModel& model,Literal* lit,bool negated, if(left->isVar()) USER_ERROR("Expect term on left of definition"); Term* fun = left->term(); unsigned f = fun->functor(); - unsigned arity = env.signature->functionArity(f); + unsigned arity = Lib::env.signature->functionArity(f); if(arity==0) model.addConstantDefinition(f,res); else{ - DArray args(arity); + Lib::DArray args(arity); for(unsigned i=0;inthArgument(i); if(arg->isVar() || !domainConstants.contains(arg->term())) @@ -224,10 +223,10 @@ static void addDefinition(FiniteModel& model,Literal* lit,bool negated, if(!lit->polarity()) negated=!negated; // Defining a predicate or proposition unsigned p = lit->functor(); - unsigned arity = env.signature->predicateArity(p); + unsigned arity = Lib::env.signature->predicateArity(p); if(arity==0) model.addPropositionalDefinition(p,!negated); else{ - DArray args(arity); + Lib::DArray args(arity); for(unsigned i=0;inthArgument(i); if(arg->isVar() || !domainConstants.contains(arg->term())) diff --git a/FMB/Monotonicity.cpp b/FMB/Monotonicity.cpp index 6d7672acc..3006dd49f 100644 --- a/FMB/Monotonicity.cpp +++ b/FMB/Monotonicity.cpp @@ -39,6 +39,7 @@ namespace FMB { using namespace std; +using namespace Lib; Monotonicity::Monotonicity(ClauseList* clauses, unsigned srt) : _srt(srt) { diff --git a/FMB/Monotonicity.hpp b/FMB/Monotonicity.hpp index 70eb3a9bf..bcd7a2d6e 100644 --- a/FMB/Monotonicity.hpp +++ b/FMB/Monotonicity.hpp @@ -37,7 +37,6 @@ namespace FMB { using namespace Kernel; using namespace SAT; - using namespace Lib; class Monotonicity{ public: @@ -46,7 +45,7 @@ class Monotonicity{ bool check(){ return _result;} - static void addSortPredicates(bool withMon, ClauseList*& clauses, DArray& del_f); + static void addSortPredicates(bool withMon, ClauseList*& clauses, Lib::DArray& del_f); static void addSortFunctions(bool withMon, ClauseList*& clauses); private: @@ -55,11 +54,11 @@ class Monotonicity{ void safe(Clause* c, Literal* l, TermList* t); void safe(Clause* c, Literal* l, TermList* t, SATLiteral add); - void safe(Clause* c, Literal* l, TermList* t, Stack& slits); + void safe(Clause* c, Literal* l, TermList* t, Lib::Stack& slits); // returns true if the true literal should be added to slits // returns false otherwise (if false should be added or something else has been added) - bool guards(Literal* l, unsigned var, Stack& slits); + bool guards(Literal* l, unsigned var, Lib::Stack& slits); unsigned _srt; @@ -67,10 +66,10 @@ class Monotonicity{ // the constructor computes the result bool _result; - DHMap _pF; - DHMap _pT; + Lib::DHMap _pF; + Lib::DHMap _pT; - ScopedPtr _solver; + Lib::ScopedPtr _solver; }; diff --git a/FMB/SortInference.cpp b/FMB/SortInference.cpp index 03321a804..3d4d9bc22 100644 --- a/FMB/SortInference.cpp +++ b/FMB/SortInference.cpp @@ -43,6 +43,7 @@ namespace FMB { using namespace std; +using namespace Lib; /** diff --git a/FMB/SortInference.hpp b/FMB/SortInference.hpp index 89e805f0d..b5a9fb0c8 100644 --- a/FMB/SortInference.hpp +++ b/FMB/SortInference.hpp @@ -29,73 +29,72 @@ namespace FMB { using namespace Kernel; using namespace Shell; -using namespace Lib; struct SortedSignature{ unsigned sorts; - DArray> sortedConstants; - DArray> sortedFunctions; + Lib::DArray> sortedConstants; + Lib::DArray> sortedFunctions; // for f(x,y) = z this will store sort(z),sort(x),sort(y) - DArray> functionSignatures; + Lib::DArray> functionSignatures; // for p(x,y) this will store sort(x),sort(y) - DArray> predicateSignatures; + Lib::DArray> predicateSignatures; // gives the maximum size of a sort - DArray sortBounds; + Lib::DArray sortBounds; // the number of distinct sorts that might have different sizes unsigned distinctSorts; // for each distinct sort gives a sort that can be used for variable equalities that are otherwise unsorted // some of these will not be used, we could detect these cases... but it is not interesting - DArray varEqSorts; + Lib::DArray varEqSorts; // the distinct parents of sorts // has length sorts with contents from distinctSorts // invariant: all monotonic sorts will have parent 0, the first non-monotonic sort - DArray parents; + Lib::DArray parents; // Map the distinct sorts back to their vampire parents // A distinct sort may merge multipe vampire sorts (due to monotonicity) - DHMap*> distinctToVampire; + Lib::DHMap*> distinctToVampire; // A vampire sort can only be mapped to more than one distinct sort under certain conditions i.e. when // (i) the option for fmbSortInference = expand // (ii) at most one sort has non-monotonic subsorts and that is called parent // (iii) additional constraints have been added making expanded <= parent - DHMap*> vampireToDistinct; + Lib::DHMap*> vampireToDistinct; // This maps to the distinct parent // invariant: domain of the two maps are the same and the second maps to something in the stack of the first - DHMap vampireToDistinctParent; + Lib::DHMap vampireToDistinctParent; // has size distinctSorts // is 1 if that distinct sort is monotonic - ZIArray monotonicSorts; + Lib::ZIArray monotonicSorts; }; class SortInference { public: SortInference(ClauseList* clauses, - DArray del_f, - DArray del_p, - Stack*> equiv_v_sorts, - Stack>& cons) : + Lib::DArray del_f, + Lib::DArray del_p, + Lib::Stack*> equiv_v_sorts, + Lib::Stack>& cons) : _clauses(clauses), _del_f(del_f), _del_p(del_p), - _equiv_v_sorts(equiv_v_sorts), _equiv_vs(env.signature->typeCons()), + _equiv_v_sorts(equiv_v_sorts), _equiv_vs(Lib::env.signature->typeCons()), _sort_constraints(cons) { _sig = new SortedSignature(); - _print = env.options->showFMBsortInfo(); + _print = Lib::env.options->showFMBsortInfo(); // ignore inference if there are no clauses _ignoreInference = !clauses; - _expandSubsorts = env.options->fmbAdjustSorts() == Options::FMBAdjustSorts::EXPAND; + _expandSubsorts = Lib::env.options->fmbAdjustSorts() == Options::FMBAdjustSorts::EXPAND; _usingMonotonicity = true; - _collapsingMonotonicSorts = (env.options->fmbAdjustSorts() != Options::FMBAdjustSorts::OFF && - env.options->fmbAdjustSorts() != Options::FMBAdjustSorts::EXPAND); + _collapsingMonotonicSorts = (Lib::env.options->fmbAdjustSorts() != Options::FMBAdjustSorts::OFF && + Lib::env.options->fmbAdjustSorts() != Options::FMBAdjustSorts::EXPAND); _assumeMonotonic = _collapsingMonotonicSorts && - env.options->fmbAdjustSorts() != Options::FMBAdjustSorts::GROUP; + Lib::env.options->fmbAdjustSorts() != Options::FMBAdjustSorts::GROUP; _distinctSorts=0; _collapsed=0; @@ -121,17 +120,17 @@ class SortInference { unsigned _distinctSorts; unsigned _collapsed; - DHSet monotonicVampireSorts; - ZIArray posEqualitiesOnSort; + Lib::DHSet monotonicVampireSorts; + Lib::ZIArray posEqualitiesOnSort; SortedSignature* _sig; ClauseList* _clauses; - DArray _del_f; - DArray _del_p; - Stack*> _equiv_v_sorts; - IntUnionFind _equiv_vs; + Lib::DArray _del_f; + Lib::DArray _del_p; + Lib::Stack*> _equiv_v_sorts; + Lib::IntUnionFind _equiv_vs; - Stack>& _sort_constraints; + Lib::Stack>& _sort_constraints; }; diff --git a/Forwards.hpp b/Forwards.hpp index 91468215a..351ac14f1 100644 --- a/Forwards.hpp +++ b/Forwards.hpp @@ -35,9 +35,9 @@ template class Vector; template class List; template class SharedSet; -typedef List IntList; -typedef Stack StringStack; -typedef List VoidFuncList; +typedef Lib::List IntList; +typedef Lib::Stack StringStack; +typedef Lib::List VoidFuncList; class DefaultHash; class DefaultHash2; @@ -53,46 +53,45 @@ class Timer; namespace Kernel { -using namespace Lib; class Signature; class Term; class TermList; -typedef VirtualIterator TermIterator; -typedef Stack TermStack; +typedef Lib::VirtualIterator TermIterator; +typedef Lib::Stack TermStack; struct SubstApplicator; struct AppliedTerm; -typedef List VList; // a list of variables (which are unsigned) -typedef List SList; // a list of sorts (which are now, with polymorphism, TermLists) -typedef const SharedSet VarSet; +typedef Lib::List VList; // a list of variables (which are unsigned) +typedef Lib::List SList; // a list of sorts (which are now, with polymorphism, TermLists) +typedef const Lib::SharedSet VarSet; class Literal; -typedef List LiteralList; -typedef Stack LiteralStack; -typedef VirtualIterator LiteralIterator; +typedef Lib::List LiteralList; +typedef Lib::Stack LiteralStack; +typedef Lib::VirtualIterator LiteralIterator; class Inference; class Unit; -typedef List UnitList; -typedef Stack UnitStack; -typedef VirtualIterator UnitIterator; +typedef Lib::List UnitList; +typedef Lib::Stack UnitStack; +typedef Lib::VirtualIterator UnitIterator; class FormulaUnit; class Formula; -typedef List FormulaList; -typedef VirtualIterator FormulaIterator; -typedef Stack FormulaStack; +typedef Lib::List FormulaList; +typedef Lib::VirtualIterator FormulaIterator; +typedef Lib::Stack FormulaStack; class Clause; -typedef VirtualIterator ClauseIterator; -typedef SingleParamEvent ClauseEvent; -typedef List ClauseList; -typedef Stack ClauseStack; +typedef Lib::VirtualIterator ClauseIterator; +typedef Lib::SingleParamEvent ClauseEvent; +typedef Lib::List ClauseList; +typedef Lib::Stack ClauseStack; class Problem; @@ -100,11 +99,11 @@ class Renaming; class Substitution; class RobSubstitution; -typedef VirtualIterator SubstIterator; +typedef Lib::VirtualIterator SubstIterator; typedef Lib::SmartPtr RobSubstitutionSP; class Matcher; -typedef VirtualIterator MatchIterator; +typedef Lib::VirtualIterator MatchIterator; class LiteralSelector; @@ -114,7 +113,7 @@ struct OrderingComparator; typedef std::unique_ptr OrderingComparatorUP; typedef unsigned SplitLevel; -typedef const SharedSet SplitSet; +typedef const Lib::SharedSet SplitSet; /** * Color of a term @@ -176,17 +175,16 @@ class BackwardSimplificationEngine; namespace SAT { -using namespace Lib; class SATClause; class SATLiteral; class SATInference; class SATSolver; -typedef VirtualIterator SATClauseIterator; -typedef List SATClauseList; -typedef Stack SATClauseStack; -typedef Stack SATLiteralStack; +typedef Lib::VirtualIterator SATClauseIterator; +typedef Lib::List SATClauseList; +typedef Lib::Stack SATClauseStack; +typedef Lib::Stack SATLiteralStack; } namespace Shell diff --git a/Indexing/ClauseCodeTree.hpp b/Indexing/ClauseCodeTree.hpp index c9c2de4aa..f2358503b 100644 --- a/Indexing/ClauseCodeTree.hpp +++ b/Indexing/ClauseCodeTree.hpp @@ -29,7 +29,6 @@ namespace Indexing { -using namespace Lib; using namespace Kernel; class ClauseCodeTree : public CodeTree @@ -49,19 +48,19 @@ class ClauseCodeTree : public CodeTree struct InitialLiteralOrderingComparator; - void optimizeLiteralOrder(DArray& lits); + void optimizeLiteralOrder(Lib::DArray& lits); void evalSharing(Literal* lit, CodeOp* startOp, size_t& sharedLen, size_t& unsharedLen, CodeOp*& nextOp); static void matchCode(CodeStack& code, CodeOp* startOp, size_t& matchedCnt, CodeOp*& nextOp); //////// removal ////////// - bool removeOneOfAlternatives(CodeOp* op, Clause* cl, Stack* firstsInBlocks); + bool removeOneOfAlternatives(CodeOp* op, Clause* cl, Lib::Stack* firstsInBlocks); struct RemovingLiteralMatcher : public RemovingMatcher { void init(CodeOp* entry_, LitInfo* linfos_, size_t linfoCnt_, - ClauseCodeTree* tree_, Stack* firstsInBlocks_); + ClauseCodeTree* tree_, Lib::Stack* firstsInBlocks_); USE_ALLOCATOR(RemovingLiteralMatcher); }; @@ -87,7 +86,7 @@ class ClauseCodeTree : public CodeTree private: bool _eagerlyMatched; - Stack eagerResults; + Lib::Stack eagerResults; void recordMatch(); }; @@ -134,9 +133,9 @@ class ClauseCodeTree : public CodeTree * [if sres] Ground literals negated * [if sres] Non-ground literals negated */ - DArray lInfos; + Lib::DArray lInfos; - Stack> lms; + Lib::Stack> lms; }; private: diff --git a/Indexing/ClauseVariantIndex.hpp b/Indexing/ClauseVariantIndex.hpp index 79778a75f..da40df7bd 100644 --- a/Indexing/ClauseVariantIndex.hpp +++ b/Indexing/ClauseVariantIndex.hpp @@ -27,7 +27,6 @@ namespace Indexing { -using namespace Lib; using namespace Kernel; class ClauseVariantIndex @@ -63,9 +62,9 @@ class SubstitutionTreeClauseVariantIndex : public ClauseVariantIndex private: Literal* getMainLiteral(Literal* const * lits, unsigned length); - DHMap _groundUnits; + Lib::DHMap _groundUnits; - ZIArray _strees; + Lib::ZIArray _strees; ClauseList* _emptyClauses; }; @@ -82,12 +81,12 @@ class HashingClauseVariantIndex : public ClauseVariantIndex private: struct VariableIgnoringComparator; - typedef DHMap VarCounts; // overflows allowed + typedef Lib::DHMap VarCounts; // overflows allowed unsigned termFunctorHash(Term* t, unsigned hash_begin) { unsigned func = t->functor(); // std::cout << "will hash funtor " << func << std::endl; - return DefaultHash::hash(func, hash_begin); + return Lib::DefaultHash::hash(func, hash_begin); } unsigned computeHashAndCountVariables(unsigned var, VarCounts& varCnts, unsigned hash_begin) { @@ -101,7 +100,7 @@ class HashingClauseVariantIndex : public ClauseVariantIndex } // std::cout << "will hash variable" << std::endl; - return DefaultHash::hash(varHash, hash_begin); + return Lib::DefaultHash::hash(varHash, hash_begin); } unsigned computeHashAndCountVariables(TermList* tl, VarCounts& varCnts, unsigned hash_begin); @@ -109,7 +108,7 @@ class HashingClauseVariantIndex : public ClauseVariantIndex unsigned computeHash(Literal* const * lits, unsigned length); - DHMap _entries; + Lib::DHMap _entries; }; }; diff --git a/Indexing/CodeTree.hpp b/Indexing/CodeTree.hpp index 160021f94..1fa605b5c 100644 --- a/Indexing/CodeTree.hpp +++ b/Indexing/CodeTree.hpp @@ -38,7 +38,6 @@ namespace Indexing { -using namespace Lib; using namespace Kernel; class CodeTree @@ -87,7 +86,7 @@ class CodeTree TermList bindings[1]; private: - void init(ILStruct* ils, unsigned liIndex, DArray& bindingArray); + void init(ILStruct* ils, unsigned liIndex, Lib::DArray& bindingArray); static MatchInfo* alloc(unsigned bindCnt); @@ -109,7 +108,7 @@ class CodeTree */ struct alignas(8) ILStruct { - ILStruct(const Literal* lit, unsigned varCnt, Stack& gvnStack); + ILStruct(const Literal* lit, unsigned varCnt, Lib::Stack& gvnStack); ~ILStruct(); void putIntoSequence(ILStruct* previous_); @@ -140,7 +139,7 @@ class CodeTree unsigned timestamp; //from here on, the values are valid only if the timestamp is current - void addMatch(unsigned liIndex, DArray& bindingArray); + void addMatch(unsigned liIndex, Lib::DArray& bindingArray); void deleteMatch(unsigned matchIndex); MatchInfo*& getMatch(unsigned matchIndex); @@ -151,7 +150,7 @@ class CodeTree bool finished; bool noNonOppositeMatches; private: - DArray matches; + Lib::DArray matches; }; enum Instruction @@ -244,9 +243,9 @@ class CodeTree BITFIELD64_GET_AND_SET(unsigned, instruction, Instruction, INSTRUCTION) BITFIELD64_GET_AND_SET(unsigned, arg, Arg, ARG) template T* _data() const - { return reinterpret_cast(BitUtils::getBits(this->_content)); } + { return reinterpret_cast(Lib::BitUtils::getBits(this->_content)); } template void _setData(T* data) - { BitUtils::setBits(this->_content, reinterpret_cast(data)); } + { Lib::BitUtils::setBits(this->_content, reinterpret_cast(data)); } // end bitfield private: @@ -325,8 +324,8 @@ class CodeTree using FnSearchStruct = SearchStructImpl; using GroundTermSearchStruct = SearchStructImpl; - typedef Vector CodeBlock; - typedef Stack CodeStack; + typedef Lib::Vector CodeBlock; + typedef Lib::Stack CodeStack; struct BaseMatcher { @@ -372,7 +371,7 @@ class CodeTree //////////// insertion ////////////// - typedef DHMap VarMap; + typedef Lib::DHMap VarMap; /** Context for code compilation */ struct CompileContext @@ -398,7 +397,7 @@ class CodeTree //////////// removal ////////////// - void optimizeMemoryAfterRemoval(Stack* firstsInBlocks, CodeOp* removedOp); + void optimizeMemoryAfterRemoval(Lib::Stack* firstsInBlocks, CodeOp* removedOp); struct RemovingMatcher : public BaseMatcher @@ -413,7 +412,7 @@ class CodeTree protected: void init(CodeOp* entry_, LitInfo* linfos_, size_t linfoCnt_, - CodeTree* tree_, Stack* firstsInBlocks_); + CodeTree* tree_, Lib::Stack* firstsInBlocks_); bool prepareLiteral(); @@ -435,10 +434,10 @@ class CodeTree }; /** Variable bindings */ - DArray bindings; + Lib::DArray bindings; - Stack btStack; - Stack* firstsInBlocks; + Lib::Stack btStack; + Lib::Stack* firstsInBlocks; bool fresh; size_t curLInfo; @@ -468,8 +467,8 @@ class CodeTree CodeOp* op; }; - typedef Stack BTStack; - typedef DArray BindingArray; + typedef Lib::Stack BTStack; + typedef Lib::DArray BindingArray; /** * Context for finding matches of literals diff --git a/Indexing/CodeTreeInterfaces.hpp b/Indexing/CodeTreeInterfaces.hpp index 25556e2cd..6be66dfde 100644 --- a/Indexing/CodeTreeInterfaces.hpp +++ b/Indexing/CodeTreeInterfaces.hpp @@ -30,7 +30,6 @@ namespace Indexing { using namespace Kernel; -using namespace Lib; /** @@ -52,11 +51,11 @@ class CodeTreeTIS : public TermIndexingStructure } } - VirtualIterator> getGeneralizations(TypedTermList t, bool retrieveSubstitutions = true) final override; + Lib::VirtualIterator> getGeneralizations(TypedTermList t, bool retrieveSubstitutions = true) final override; // TODO use TypedTermList here too bool generalizationExists(TermList t) final override; // TODO: get rid of NOT_IMPLEMENTED - VirtualIterator> getUwa(TypedTermList t, Options::UnificationWithAbstraction, bool fixedPointIteration) override { NOT_IMPLEMENTED; } + Lib::VirtualIterator> getUwa(TypedTermList t, Options::UnificationWithAbstraction, bool fixedPointIteration) override { NOT_IMPLEMENTED; } virtual void output(std::ostream& out) const final override { out << _ct; } diff --git a/Indexing/GroundingIndex.hpp b/Indexing/GroundingIndex.hpp index 9e5c9dfb3..a725a1b76 100644 --- a/Indexing/GroundingIndex.hpp +++ b/Indexing/GroundingIndex.hpp @@ -40,8 +40,8 @@ class GroundingIndex : public Index { virtual void handleClause(Clause* c, bool adding); private: - ScopedPtr _solver; - ScopedPtr _grounder; + Lib::ScopedPtr _solver; + Lib::ScopedPtr _grounder; }; } diff --git a/Indexing/Index.hpp b/Indexing/Index.hpp index a325cd1b5..6e477f9dd 100644 --- a/Indexing/Index.hpp +++ b/Indexing/Index.hpp @@ -37,7 +37,6 @@ namespace Indexing { using namespace Kernel; -using namespace Lib; using namespace Saturation; struct LiteralClause @@ -200,8 +199,8 @@ class Index //TODO: postponing index modifications during iteration (methods isBeingIterated() etc...) private: - SubscriptionData _addedSD; - SubscriptionData _removedSD; + Lib::SubscriptionData _addedSD; + Lib::SubscriptionData _removedSD; }; }; diff --git a/Indexing/IndexManager.hpp b/Indexing/IndexManager.hpp index 4b1ab8a39..4d967b33d 100644 --- a/Indexing/IndexManager.hpp +++ b/Indexing/IndexManager.hpp @@ -27,7 +27,6 @@ namespace Indexing { -using namespace Lib; using namespace Saturation; enum IndexType { @@ -93,7 +92,7 @@ class IndexManager int refCnt; }; SaturationAlgorithm* _alg; - DHMap _store; + Lib::DHMap _store; Index* create(IndexType t); Shell::Options::UnificationWithAbstraction _uwa; diff --git a/Indexing/InductionFormulaIndex.hpp b/Indexing/InductionFormulaIndex.hpp index f6760c168..6a7a45bed 100644 --- a/Indexing/InductionFormulaIndex.hpp +++ b/Indexing/InductionFormulaIndex.hpp @@ -31,9 +31,8 @@ namespace Inferences { namespace Indexing { -using namespace Lib; using namespace Kernel; -using Key = std::pair,std::pair>; +using Key = std::pair,std::pair>; class InductionFormulaIndex { @@ -56,18 +55,18 @@ class InductionFormulaIndex } _st.push(std::make_pair(cls, subst)); } - const Stack>& get() const { + const Lib::Stack>& get() const { return _st; } private: - Stack> _st; + Lib::Stack> _st; }; static Key represent(const Inferences::InductionContext& context); bool findOrInsert(const Inferences::InductionContext& context, Entry*& e, Literal* bound1 = nullptr, Literal* bound2 = nullptr); private: - DHMap _map; + Lib::DHMap _map; }; } diff --git a/Indexing/LiteralIndex.hpp b/Indexing/LiteralIndex.hpp index 7ad78af32..0522c9bb1 100644 --- a/Indexing/LiteralIndex.hpp +++ b/Indexing/LiteralIndex.hpp @@ -30,19 +30,19 @@ class LiteralIndex : public Index { public: - VirtualIterator getAll() + Lib::VirtualIterator getAll() { return _is->getAll(); } - VirtualIterator> getUnifications(Literal* lit, bool complementary, bool retrieveSubstitutions = true) + Lib::VirtualIterator> getUnifications(Literal* lit, bool complementary, bool retrieveSubstitutions = true) { return _is->getUnifications(lit, complementary, retrieveSubstitutions); } - VirtualIterator> getUwa(Literal* lit, bool complementary, Options::UnificationWithAbstraction uwa, bool fixedPointIteration) + Lib::VirtualIterator> getUwa(Literal* lit, bool complementary, Options::UnificationWithAbstraction uwa, bool fixedPointIteration) { return _is->getUwa(lit, complementary, uwa, fixedPointIteration); } - VirtualIterator> getGeneralizations(Literal* lit, bool complementary, bool retrieveSubstitutions = true) + Lib::VirtualIterator> getGeneralizations(Literal* lit, bool complementary, bool retrieveSubstitutions = true) { return _is->getGeneralizations(lit, complementary, retrieveSubstitutions); } - VirtualIterator> getInstances(Literal* lit, bool complementary, bool retrieveSubstitutions = true) + Lib::VirtualIterator> getInstances(Literal* lit, bool complementary, bool retrieveSubstitutions = true) { return _is->getInstances(lit, complementary, retrieveSubstitutions); } size_t getUnificationCount(Literal* lit, bool complementary) @@ -167,7 +167,7 @@ class RewriteRuleIndex void handleEquivalence(Clause* c, Literal* cgr, Clause* d, Literal* dgr, bool adding); LiteralIndexingStructure* _partialIndex; - DHMap _counterparts; + Lib::DHMap _counterparts; Ordering& _ordering; }; diff --git a/Indexing/LiteralIndexingStructure.hpp b/Indexing/LiteralIndexingStructure.hpp index 1405a12a1..106539378 100644 --- a/Indexing/LiteralIndexingStructure.hpp +++ b/Indexing/LiteralIndexingStructure.hpp @@ -34,19 +34,19 @@ class LiteralIndexingStructure { void insert(LeafData ld) { handle(std::move(ld), /* insert = */ true ); } void remove(LeafData ld) { handle(std::move(ld), /* insert = */ false); } - virtual VirtualIterator getAll() { NOT_IMPLEMENTED; } - virtual VirtualIterator> getUnifications(Literal* lit, bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } - virtual VirtualIterator> getUwa(Literal* lit, bool complementary, Options::UnificationWithAbstraction uwa, bool fixedPointIteration) = 0; - virtual VirtualIterator> getGeneralizations(Literal* lit, bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } - virtual VirtualIterator> getInstances(Literal* lit, bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } - virtual VirtualIterator> getVariants(Literal* lit, bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual Lib::VirtualIterator getAll() { NOT_IMPLEMENTED; } + virtual Lib::VirtualIterator> getUnifications(Literal* lit, bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual Lib::VirtualIterator> getUwa(Literal* lit, bool complementary, Options::UnificationWithAbstraction uwa, bool fixedPointIteration) = 0; + virtual Lib::VirtualIterator> getGeneralizations(Literal* lit, bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual Lib::VirtualIterator> getInstances(Literal* lit, bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual Lib::VirtualIterator> getVariants(Literal* lit, bool complementary, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } virtual size_t getUnificationCount(Literal* lit, bool complementary) { return countIteratorElements(getUnifications(lit, complementary, false)); } - virtual void output(std::ostream& out, Option multilineIndent) const = 0; + virtual void output(std::ostream& out, Lib::Option multilineIndent) const = 0; friend std::ostream& operator<<(std::ostream& out, LiteralIndexingStructure const& self) { self.output(out, {} ); return out; } friend std::ostream& operator<<(std::ostream& out, OutputMultilineconst& self) { self.self.output(out, some(self.indent)); return out; } diff --git a/Indexing/LiteralMiniIndex.hpp b/Indexing/LiteralMiniIndex.hpp index 1e3d2944e..1c400d22a 100644 --- a/Indexing/LiteralMiniIndex.hpp +++ b/Indexing/LiteralMiniIndex.hpp @@ -23,7 +23,6 @@ namespace Indexing { -using namespace Lib; using namespace Kernel; @@ -54,7 +53,7 @@ class LiteralMiniIndex static bool literalHeaderComparator(const Entry& e1, const Entry& e2); unsigned _cnt = 0; - DArray _entries; + Lib::DArray _entries; struct IteratorBase { diff --git a/Indexing/LiteralSubstitutionTree.hpp b/Indexing/LiteralSubstitutionTree.hpp index 66e673ef7..131ca7914 100644 --- a/Indexing/LiteralSubstitutionTree.hpp +++ b/Indexing/LiteralSubstitutionTree.hpp @@ -43,13 +43,13 @@ class LiteralSubstitutionTree public: LiteralSubstitutionTree() - : _trees(env.signature->predicates() * 2) + : _trees(Lib::env.signature->predicates() * 2) { } void handle(LeafData ld, bool insert) final override { getTree(ld.key(), /* complementary */ false).handle(std::move(ld), insert); } - VirtualIterator getAll() final override + Lib::VirtualIterator getAll() final override { return pvi( iterTraits(getRangeIterator((unsigned long)0, _trees.size())) @@ -60,16 +60,16 @@ class LiteralSubstitutionTree ); } - VirtualIterator> getUnifications(Literal* lit, bool complementary, bool retrieveSubstitutions) final override + Lib::VirtualIterator> getUnifications(Literal* lit, bool complementary, bool retrieveSubstitutions) final override { return pvi(getResultIterator>(lit, complementary, retrieveSubstitutions)); } - VirtualIterator> getGeneralizations(Literal* lit, bool complementary, bool retrieveSubstitutions) final override + Lib::VirtualIterator> getGeneralizations(Literal* lit, bool complementary, bool retrieveSubstitutions) final override { return pvi(getResultIterator(lit, complementary, retrieveSubstitutions)); } - VirtualIterator> getInstances(Literal* lit, bool complementary, bool retrieveSubstitutions) final override + Lib::VirtualIterator> getInstances(Literal* lit, bool complementary, bool retrieveSubstitutions) final override { return pvi(getResultIterator(lit, complementary, retrieveSubstitutions)); } - VirtualIterator> getVariants(Literal* query, bool complementary, bool retrieveSubstitutions) final override + Lib::VirtualIterator> getVariants(Literal* query, bool complementary, bool retrieveSubstitutions) final override { return pvi(iterTraits(getTree(query, complementary).getVariants(query, retrieveSubstitutions))); } @@ -94,7 +94,7 @@ class LiteralSubstitutionTree { return tree->template iterator(lit, retrieveSubstitutions, reversed, args...); }; return ifElseIter( - tree->isEmpty(), [&]() { return VirtualIterator::getEmpty(); }, + tree->isEmpty(), [&]() { return Lib::VirtualIterator::getEmpty(); }, [&]() { return ifElseIter(!lit->commutative(), [&]() { return iter(/* reverse */ false); }, [&]() { return concatIters(iter(/* reverse */ false), iter(/* reverse */ true)); }); } @@ -115,7 +115,7 @@ class LiteralSubstitutionTree public: - VirtualIterator> getUwa(Literal* lit, bool complementary, Options::UnificationWithAbstraction uwa, bool fixedPointIteration) final override + Lib::VirtualIterator> getUwa(Literal* lit, bool complementary, Options::UnificationWithAbstraction uwa, bool fixedPointIteration) final override { return pvi(getResultIterator>(lit, complementary, /* retrieveSubstitutions */ true, AbstractionOracle(uwa), fixedPointIteration)); } friend std::ostream& operator<<(std::ostream& out, LiteralSubstitutionTree const& self) @@ -124,7 +124,7 @@ class LiteralSubstitutionTree out << "{ "; for (auto& t : self._trees) { if (!t->isEmpty()) { - auto f = env.signature->getPredicate(idxToFunctor(i)); + auto f = Lib::env.signature->getPredicate(idxToFunctor(i)); if (idxIsNegative(i)) out << "~"; out << *f << "(" << *t << "), "; } @@ -138,7 +138,7 @@ class LiteralSubstitutionTree out << "{ " << std::endl; for (auto& t : self.self._trees) { if (!t->isEmpty()) { - auto f = env.signature->getPredicate(idxToFunctor(i)); + auto f = Lib::env.signature->getPredicate(idxToFunctor(i)); OutputMultiline::outputIndent(out, self.indent); out << (idxIsNegative(i) ? "~" : " ") << *f << "(" << multiline(*t, self.indent + 1) << ")" << std::endl; } @@ -147,7 +147,7 @@ class LiteralSubstitutionTree return out << "} "; } - virtual void output(std::ostream& out, Option multilineIndent) const override { + virtual void output(std::ostream& out, Lib::Option multilineIndent) const override { if (multilineIndent) { out << multiline(*this, *multilineIndent); } else { @@ -167,7 +167,7 @@ class LiteralSubstitutionTree return *_trees[idx]; } - Stack> _trees; + Lib::Stack> _trees; }; }; diff --git a/Indexing/SubstitutionTree.cpp b/Indexing/SubstitutionTree.cpp index e52af44e4..c56dd7823 100644 --- a/Indexing/SubstitutionTree.cpp +++ b/Indexing/SubstitutionTree.cpp @@ -45,6 +45,9 @@ #include "SubstitutionTree.hpp" namespace Indexing { + +using namespace Lib; + struct UnresolvedSplitRecord { UnresolvedSplitRecord() {} diff --git a/Indexing/SubstitutionTree.hpp b/Indexing/SubstitutionTree.hpp index e274f84cd..2e6bda17d 100644 --- a/Indexing/SubstitutionTree.hpp +++ b/Indexing/SubstitutionTree.hpp @@ -60,7 +60,6 @@ static constexpr int QUERY_BANK=0; static constexpr int RESULT_BANK=1; static constexpr int NORM_RESULT_BANK=3; -using namespace Lib; using namespace Kernel; #define UARR_INTERMEDIATE_NODE_MAX_SIZE 4 @@ -208,21 +207,22 @@ class SubstitutionTree final friend std::ostream& operator<<(std::ostream& out, SubstitutionTree const& self); template friend std::ostream& operator<<(std::ostream& out, OutputMultiline> const& self); - typedef VirtualIterator LDIterator; + typedef Lib::VirtualIterator LDIterator; - template using QueryResultIter = VirtualIterator>; + template using QueryResultIter = Lib::VirtualIterator>; template auto iterator(TermOrLit query, bool retrieveSubstitutions, bool reversed, Args... args) - { return isEmpty() ? VirtualIterator::getEmpty() - : pvi(iterPointer(Recycled(this, _root, query, retrieveSubstitutions, reversed, std::move(args)...))); + { return isEmpty() ? Lib::VirtualIterator::getEmpty() + : pvi(iterPointer(Lib::Recycled(this, _root, query, retrieveSubstitutions, reversed, std::move(args)...))); } class LDComparator { public: template - static Comparison compare(const LD& ld1, const LD& ld2) + static Lib::Comparison compare(const LD& ld1, const LD& ld2) { + using namespace Lib; return ld1 < ld2 ? Comparison::LESS : ld1 > ld2 ? Comparison::GREATER : Comparison::EQUAL; @@ -300,7 +300,7 @@ class SubstitutionTree final }; - typedef VirtualIterator NodeIterator; + typedef Lib::VirtualIterator NodeIterator; class IntermediateNode : public Node @@ -424,11 +424,11 @@ class SubstitutionTree final bool isEmpty() const { return !_size; } int size() const { return _size; } NodeIterator allChildren() - { return pvi( arrayIter(_nodes,_size).map([](Node *& n) { return &n; }) ); } + { return pvi( Lib::arrayIter(_nodes,_size).map([](Node *& n) { return &n; }) ); } NodeIterator variableChildren() { - return pvi( arrayIter(_nodes, _size) + return pvi( Lib::arrayIter(_nodes, _size) .filter([](auto& n) { return n->term().isVar(); }) .map([](Node *& n) { return &n; })); } @@ -503,18 +503,19 @@ class SubstitutionTree final class NodePtrComparator { public: - inline static Comparison compare(TermList::Top& l, Node* r) + inline static Lib::Comparison compare(TermList::Top& l, Node* r) { + using namespace Lib; if(l.var()) { - return r->term().isVar() ? Int::compare(*l.var(), r->term().var()) + return r->term().isVar() ? Lib::Int::compare(*l.var(), r->term().var()) : LESS; } else { return r->term().isVar() ? GREATER - : Int::compare(l.functor()->functor, r->term().term()->functor()); + : Lib::Int::compare(l.functor()->functor, r->term().term()->functor()); } } }; - typedef SkipList NodeSkipList; + typedef Lib::SkipList NodeSkipList; NodeSkipList _nodes; }; @@ -529,8 +530,8 @@ class SubstitutionTree final Binding(int v,TermList t) : var(v), term(t) {} }; // class SubstitutionTree::Binding - typedef DHMap BindingMap; - typedef Stack VarStack; + typedef Lib::DHMap BindingMap; + typedef Lib::Stack VarStack; Leaf* findLeaf(BindingMap& svBindings) { return _root ? findLeaf(_root, svBindings) : nullptr; } @@ -564,7 +565,7 @@ class SubstitutionTree final void handle(LeafData ld, bool doInsert) { auto norm = Renaming::normalize(ld.key()); - Recycled bindings; + Lib::Recycled bindings; createBindings(norm, /* reversed */ false, [&](int var, auto term) { _nextVar = std::max(_nextVar, var + 1); @@ -589,8 +590,8 @@ class SubstitutionTree final : public ResultSubstitution { public: - Recycled _query; - Recycled _result; + Lib::Recycled _query; + Lib::Recycled _result; RenamingSubstitution(): _query(), _result() {} virtual ~RenamingSubstitution() override {} virtual TermList applyToQuery(TermList t) final override { return _query->apply(t); } @@ -619,7 +620,7 @@ class SubstitutionTree final } template - VirtualIterator> getVariants(Query query, bool retrieveSubstitutions) + Lib::VirtualIterator> getVariants(Query query, bool retrieveSubstitutions) { auto renaming = retrieveSubstitutions ? std::make_unique() : std::unique_ptr(nullptr); ResultSubstitutionSP resultSubst = retrieveSubstitutions ? ResultSubstitutionSP(&*renaming) : ResultSubstitutionSP(); @@ -632,14 +633,14 @@ class SubstitutionTree final normQuery = Renaming::normalize(query); } - Recycled svBindings; + Lib::Recycled svBindings; createBindings(normQuery, /* reversed */ false, [&](auto v, auto t) { { svBindings->insert(v, t); } }); Leaf* leaf = findLeaf(*svBindings); if(leaf==0) { - return VirtualIterator>::getEmpty(); + return Lib::VirtualIterator>::getEmpty(); } else { return pvi(iterTraits(leaf->allChildren()) .map([retrieveSubstitutions, renaming = std::move(renaming), resultSubst](LeafData* ld) @@ -668,7 +669,7 @@ class SubstitutionTree final private: void skipToNextLeaf(); Node* _curr; - Stack _nodeIterators; + Lib::Stack _nodeIterators; }; @@ -755,7 +756,7 @@ class SubstitutionTree final class Substitution; VarStack _boundVars; - DArray _specVars; + Lib::DArray _specVars; /** * Inheritors must assign the maximal possible number of an ordinary * variable that can be bound during the retrievall process. @@ -766,7 +767,7 @@ class SubstitutionTree final * Inheritors must ensure that the size of this map will * be at least @b _maxVar+1 */ - ArrayMap _bindings; + Lib::ArrayMap _bindings; }; /** @@ -883,9 +884,9 @@ class SubstitutionTree final Node* _root; - Stack _alternatives; - Stack _specVarNumbers; - Stack _nodeTypes; + Lib::Stack _alternatives; + Lib::Stack _specVarNumbers; + Lib::Stack _nodeTypes; InstanceCntr _iterCntr; public: bool keepRecycled() const @@ -1015,8 +1016,8 @@ class SubstitutionTree final TermSpec deref(TermList var); - typedef DHMap BindingMap; - typedef Stack TermStack; + typedef Lib::DHMap BindingMap; + typedef Lib::Stack TermStack; /** Stacks of bindings made on each backtrack level. Backtrack * levels are separated by empty terms. */ @@ -1029,7 +1030,7 @@ class SubstitutionTree final * * The map is reset whenever we enter a new leaf */ - DHMap _derefBindings; + Lib::DHMap _derefBindings; struct DerefTask { @@ -1128,9 +1129,9 @@ class SubstitutionTree final Renaming _resultDenormalizer; Node* _root; - Stack _alternatives; - Stack _specVarNumbers; - Stack _nodeTypes; + Lib::Stack _alternatives; + Lib::Stack _specVarNumbers; + Lib::Stack _nodeTypes; InstanceCntr _iterCntr; public: @@ -1292,7 +1293,7 @@ class SubstitutionTree final Node* n=*_nodeIterators.top().next(); DEBUG_QUERY(1, "trying S", _svStack.top(), " -> ", n->term()) - _bdStack.push(BacktrackData()); + _bdStack.push(Lib::BacktrackData()); if (runRecording([&]() { return _algo.associate(_svStack.top(), n->term());})) { prepareChildren(n, /* backtrackable */ true); @@ -1336,11 +1337,11 @@ class SubstitutionTree final RetrievalAlgorithm _algo; VarStack _svStack; bool _retrieveSubstitution; - Option _leafData; - Stack _nodeIterators; - Stack _bdStack; + Lib::Option _leafData; + Lib::Stack _nodeIterators; + Lib::Stack _bdStack; bool _normalizationRecording; - BacktrackData _normalizationBacktrackData; + Lib::BacktrackData _normalizationBacktrackData; InstanceCntr _iterCntr; public: @@ -1411,7 +1412,7 @@ class SubstitutionTree final Unifier unifier() { return ResultSubstitution::fromSubstitution(&_subs, QUERY_BANK, RESULT_BANK); } /** same as in @Backtrackable */ - void bdRecord(BacktrackData& bd) { _subs.bdRecord(bd); } + void bdRecord(Lib::BacktrackData& bd) { _subs.bdRecord(bd); } /** same as in @Backtrackable */ void bdDone() { _subs.bdDone(); } @@ -1448,7 +1449,7 @@ class SubstitutionTree final auto** match = n->childByTop(top, /* canCreate */ false); if(match) { return pvi(concatIters( - getSingletonIterator(match), + Lib::getSingletonIterator(match), n->variableChildren())); } else { return n->variableChildren(); @@ -1485,7 +1486,7 @@ class SubstitutionTree final void bindQuerySpecialVar(unsigned var, TermList term) { _unif.subs().bindSpecialVar(var, term, QUERY_BANK); } - void bdRecord(BacktrackData& bd) + void bdRecord(Lib::BacktrackData& bd) { _unif.subs().bdRecord(bd); } void bdDone() @@ -1510,7 +1511,7 @@ class SubstitutionTree final auto syms = unif.unifiableSymbols(*top.functor()); if (syms) { return pvi(concatIters( - arrayIter(std::move(*syms)) + Lib::arrayIter(std::move(*syms)) .map ([=](auto f) { return n->childByTop(top, /* canCreate */ false); }) .filter([ ](auto n) { return n != nullptr; }), n->variableChildren() diff --git a/Indexing/TermCodeTree.hpp b/Indexing/TermCodeTree.hpp index 62e7ccf32..3b936248a 100644 --- a/Indexing/TermCodeTree.hpp +++ b/Indexing/TermCodeTree.hpp @@ -35,7 +35,6 @@ namespace Indexing { -using namespace Lib; using namespace Kernel; template @@ -55,7 +54,7 @@ class TermCodeTree : public CodeTree : public RemovingMatcher { public: - void init(FlatTerm* ft_, TermCodeTree* tree_, Stack* firstsInBlocks_); + void init(FlatTerm* ft_, TermCodeTree* tree_, Lib::Stack* firstsInBlocks_); }; diff --git a/Indexing/TermIndex.hpp b/Indexing/TermIndex.hpp index 6d65e0cc5..3f2280592 100644 --- a/Indexing/TermIndex.hpp +++ b/Indexing/TermIndex.hpp @@ -31,16 +31,16 @@ class TermIndex public: virtual ~TermIndex() {} - VirtualIterator> getUwa(TypedTermList t, Options::UnificationWithAbstraction uwa, bool fixedPointIteration) + Lib::VirtualIterator> getUwa(TypedTermList t, Options::UnificationWithAbstraction uwa, bool fixedPointIteration) { return _is->getUwa(t, uwa, fixedPointIteration); } - VirtualIterator> getUnifications(TypedTermList t, bool retrieveSubstitutions = true) + Lib::VirtualIterator> getUnifications(TypedTermList t, bool retrieveSubstitutions = true) { return _is->getUnifications(t, retrieveSubstitutions); } - VirtualIterator> getGeneralizations(TypedTermList t, bool retrieveSubstitutions = true) + Lib::VirtualIterator> getGeneralizations(TypedTermList t, bool retrieveSubstitutions = true) { return _is->getGeneralizations(t, retrieveSubstitutions); } - VirtualIterator> getInstances(TypedTermList t, bool retrieveSubstitutions = true) + Lib::VirtualIterator> getInstances(TypedTermList t, bool retrieveSubstitutions = true) { return _is->getInstances(t, retrieveSubstitutions); } friend std::ostream& operator<<(std::ostream& out, TermIndex const& self) diff --git a/Indexing/TermIndexingStructure.hpp b/Indexing/TermIndexingStructure.hpp index e43d3a460..0cf00053b 100644 --- a/Indexing/TermIndexingStructure.hpp +++ b/Indexing/TermIndexingStructure.hpp @@ -29,11 +29,11 @@ class TermIndexingStructure { void insert(Data data) { handle(std::move(data), /* insert */ true ); } void remove(Data data) { handle(std::move(data), /* insert */ false); } - virtual VirtualIterator> getUnifications(TypedTermList t, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } - virtual VirtualIterator> getUwa(TypedTermList t, Options::UnificationWithAbstraction uwa, bool fixedPointIteration) = 0; - virtual VirtualIterator> getUnificationsUsingSorts(TypedTermList tt, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } - virtual VirtualIterator> getGeneralizations(TypedTermList t, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } - virtual VirtualIterator> getInstances(TypedTermList t, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual Lib::VirtualIterator> getUnifications(TypedTermList t, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual Lib::VirtualIterator> getUwa(TypedTermList t, Options::UnificationWithAbstraction uwa, bool fixedPointIteration) = 0; + virtual Lib::VirtualIterator> getUnificationsUsingSorts(TypedTermList tt, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual Lib::VirtualIterator> getGeneralizations(TypedTermList t, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } + virtual Lib::VirtualIterator> getInstances(TypedTermList t, bool retrieveSubstitutions = true) { NOT_IMPLEMENTED; } virtual bool generalizationExists(TermList t) { NOT_IMPLEMENTED; } diff --git a/Indexing/TermSharing.cpp b/Indexing/TermSharing.cpp index bd1fe7f1c..c84495147 100644 --- a/Indexing/TermSharing.cpp +++ b/Indexing/TermSharing.cpp @@ -30,6 +30,7 @@ #include "TermSharing.hpp" using namespace std; +using namespace Lib; using namespace Kernel; using namespace Indexing; diff --git a/Indexing/TermSharing.hpp b/Indexing/TermSharing.hpp index d6d3856ad..d4ea1ab43 100644 --- a/Indexing/TermSharing.hpp +++ b/Indexing/TermSharing.hpp @@ -22,7 +22,6 @@ #include "Lib/Allocator.hpp" -using namespace Lib; using namespace Kernel; namespace Indexing { @@ -59,9 +58,9 @@ class TermSharing static bool equals(const Literal* l1, const Literal* l2) { return Literal::literalEquals(l1, l2->functor(), l2->polarity() ^ opposite, [&](auto i){ return *l2->nthArgument(i); }, - l2->arity(), someIf(l2->isTwoVarEquality(), [&](){ return l2->twoVarEqSort(); }), l2->commutative()); } + l2->arity(), Lib::someIf(l2->isTwoVarEquality(), [&](){ return l2->twoVarEqSort(); }), l2->commutative()); } - DHSet* getArraySorts(){ + Lib::DHSet* getArraySorts(){ return &_arraySorts; } @@ -100,15 +99,15 @@ class TermSharing static bool argNormGt(TermList t1, TermList t2); /** The set storing all terms */ - Set _terms; + Lib::Set _terms; /** The set storing all literals */ - Set _literals; + Lib::Set _literals; /** The set storing all sorts */ - Set _sorts; + Lib::Set _sorts; /* Set containing all array sorts. * Can be deleted once array axioms are made truly poltmorphic */ - DHSet _arraySorts; + Lib::DHSet _arraySorts; bool _poly; bool _wellSortednessCheckingDisabled; diff --git a/Indexing/TermSubstitutionTree.hpp b/Indexing/TermSubstitutionTree.hpp index abc766bac..c8f05d193 100644 --- a/Indexing/TermSubstitutionTree.hpp +++ b/Indexing/TermSubstitutionTree.hpp @@ -81,17 +81,17 @@ class TermSubstitutionTree { return out << multiline(self.self._inner, self.indent); } public: - VirtualIterator> getInstances(TypedTermList t, bool retrieveSubstitutions) final override + Lib::VirtualIterator> getInstances(TypedTermList t, bool retrieveSubstitutions) final override { return pvi(getResultIterator(t, retrieveSubstitutions)); } - VirtualIterator> getGeneralizations(TypedTermList t, bool retrieveSubstitutions) final override + Lib::VirtualIterator> getGeneralizations(TypedTermList t, bool retrieveSubstitutions) final override { return pvi(getResultIterator(t, retrieveSubstitutions)); } - VirtualIterator> getUwa(TypedTermList t, Options::UnificationWithAbstraction uwa, bool fixedPointIteration) final override + Lib::VirtualIterator> getUwa(TypedTermList t, Options::UnificationWithAbstraction uwa, bool fixedPointIteration) final override { return pvi(getResultIterator>(t, /* retrieveSubstitutions */ true, AbstractionOracle(uwa), fixedPointIteration)); } - VirtualIterator> getUnifications(TypedTermList t, bool retrieveSubstitutions) override + Lib::VirtualIterator> getUnifications(TypedTermList t, bool retrieveSubstitutions) override { return pvi(getResultIterator>(t, retrieveSubstitutions)); } }; diff --git a/Inferences/ArithmeticSubtermGeneralization.cpp b/Inferences/ArithmeticSubtermGeneralization.cpp index 188a6434a..d60be2fa6 100644 --- a/Inferences/ArithmeticSubtermGeneralization.cpp +++ b/Inferences/ArithmeticSubtermGeneralization.cpp @@ -23,6 +23,7 @@ namespace Inferences { using namespace std; +using namespace Lib; /** iterator over all subterms of a clause in polynomial normal form */ static const auto iterTerms = [](Clause* cl) diff --git a/Inferences/ArithmeticSubtermGeneralization.hpp b/Inferences/ArithmeticSubtermGeneralization.hpp index 8f97df7e5..4df4b3247 100644 --- a/Inferences/ArithmeticSubtermGeneralization.hpp +++ b/Inferences/ArithmeticSubtermGeneralization.hpp @@ -58,7 +58,7 @@ class AdditionGeneralization SimplifyingGeneratingInference1::Result simplify(Clause* cl, bool doOrderingCheck); }; -Stack allArithmeticSubtermGeneralizations(); +Lib::Stack allArithmeticSubtermGeneralizations(); } // namespace Inferences diff --git a/Inferences/BoolSimp.cpp b/Inferences/BoolSimp.cpp index 24d346ca5..32c7d9b50 100644 --- a/Inferences/BoolSimp.cpp +++ b/Inferences/BoolSimp.cpp @@ -27,6 +27,8 @@ namespace Inferences { +using namespace Lib; + Clause* BoolSimp::simplify(Clause* premise) { TermList subTerm; TermList simpedSubTerm; diff --git a/Inferences/Cancellation.cpp b/Inferences/Cancellation.cpp index 90a08e7f1..0ec487425 100644 --- a/Inferences/Cancellation.cpp +++ b/Inferences/Cancellation.cpp @@ -17,6 +17,7 @@ namespace Inferences { +using namespace Lib; Cancellation::~Cancellation() {} diff --git a/Inferences/Cases.cpp b/Inferences/Cases.cpp index cf157b644..6e25a9eb6 100644 --- a/Inferences/Cases.cpp +++ b/Inferences/Cases.cpp @@ -35,6 +35,7 @@ namespace Inferences { using namespace std; +using namespace Lib; Clause* Cases::performParamodulation(Clause* premise, Literal* lit, TermList t) { ASS(t.isTerm()); diff --git a/Inferences/CasesSimp.cpp b/Inferences/CasesSimp.cpp index c3adca936..a81b52bd8 100644 --- a/Inferences/CasesSimp.cpp +++ b/Inferences/CasesSimp.cpp @@ -35,7 +35,7 @@ namespace Inferences { using namespace std; - +using namespace Lib; ClauseIterator CasesSimp::performSimplification(Clause* premise, Literal* lit, TermList t) { ASS(t.isTerm()); diff --git a/Inferences/DefinitionIntroduction.cpp b/Inferences/DefinitionIntroduction.cpp index a48a3779c..eca276e92 100644 --- a/Inferences/DefinitionIntroduction.cpp +++ b/Inferences/DefinitionIntroduction.cpp @@ -20,6 +20,8 @@ namespace Inferences { +using namespace Lib; + struct IncompleteFunction { unsigned functor, arity, remaining; }; diff --git a/Inferences/DefinitionIntroduction.hpp b/Inferences/DefinitionIntroduction.hpp index bc63fe326..b95bb12ae 100644 --- a/Inferences/DefinitionIntroduction.hpp +++ b/Inferences/DefinitionIntroduction.hpp @@ -48,9 +48,9 @@ class DefinitionIntroduction: public GeneratingInferenceEngine, public Index { Term *term; unsigned weight; }; - DHSet _defined; - Stack> _entries; - Stack _definitions; + Lib::DHSet _defined; + Lib::Stack> _entries; + Lib::Stack _definitions; }; } diff --git a/Inferences/DemodulationHelper.cpp b/Inferences/DemodulationHelper.cpp index 21ea6fd9e..720e3e3e1 100644 --- a/Inferences/DemodulationHelper.cpp +++ b/Inferences/DemodulationHelper.cpp @@ -23,6 +23,7 @@ namespace Inferences { +using namespace Lib; using namespace Kernel; DemodulationHelper::DemodulationHelper(const Options& opts, const Ordering* ord) diff --git a/Inferences/DistinctEqualitySimplifier.cpp b/Inferences/DistinctEqualitySimplifier.cpp index ca4d6773d..5af95f46e 100644 --- a/Inferences/DistinctEqualitySimplifier.cpp +++ b/Inferences/DistinctEqualitySimplifier.cpp @@ -23,6 +23,8 @@ namespace Inferences { +using namespace Lib; + Clause* DistinctEqualitySimplifier::simplify(Clause* cl) { if(!canSimplify(cl)) { diff --git a/Inferences/EquationalTautologyRemoval.cpp b/Inferences/EquationalTautologyRemoval.cpp index 19ffee859..f42d1e33c 100644 --- a/Inferences/EquationalTautologyRemoval.cpp +++ b/Inferences/EquationalTautologyRemoval.cpp @@ -23,6 +23,7 @@ namespace Inferences { using namespace std; +using namespace Lib; Clause* EquationalTautologyRemoval::simplify(Clause* cl) { diff --git a/Inferences/FOOLParamodulation.cpp b/Inferences/FOOLParamodulation.cpp index 12e9297da..a6d496f03 100644 --- a/Inferences/FOOLParamodulation.cpp +++ b/Inferences/FOOLParamodulation.cpp @@ -31,6 +31,8 @@ namespace Inferences { +using namespace Lib; + ClauseIterator FOOLParamodulation::generateClauses(Clause* premise) { /** * We are going to implement the following inference rule, taken from the paper: diff --git a/Inferences/ForwardLiteralRewriting.cpp b/Inferences/ForwardLiteralRewriting.cpp index e1f89feac..468275adb 100644 --- a/Inferences/ForwardLiteralRewriting.cpp +++ b/Inferences/ForwardLiteralRewriting.cpp @@ -27,6 +27,8 @@ namespace Inferences { +using namespace Lib; + void ForwardLiteralRewriting::attach(SaturationAlgorithm* salg) { ForwardSimplificationEngine::attach(salg); diff --git a/Inferences/GaussianVariableElimination.cpp b/Inferences/GaussianVariableElimination.cpp index 7ae5f2a95..d36980a1c 100644 --- a/Inferences/GaussianVariableElimination.cpp +++ b/Inferences/GaussianVariableElimination.cpp @@ -21,6 +21,8 @@ namespace Inferences { +using namespace Lib; + using Balancer = Kernel::Rebalancing::Balancer; SimplifyingGeneratingInference1::Result GaussianVariableElimination::simplify(Clause* in, bool doCheckOrdering) diff --git a/Inferences/GlobalSubsumption.hpp b/Inferences/GlobalSubsumption.hpp index 6797ea4a7..bf76ae90c 100644 --- a/Inferences/GlobalSubsumption.hpp +++ b/Inferences/GlobalSubsumption.hpp @@ -51,7 +51,7 @@ class GlobalSubsumption void detach() override; bool perform(Clause* cl, Clause*& replacement, ClauseIterator& premises) override; - Clause* perform(Clause* cl, Stack& prems); + Clause* perform(Clause* cl, Lib::Stack& prems); private: struct Unit2ClFn; @@ -90,12 +90,12 @@ class GlobalSubsumption * * (Should this be rather a part of _index?) */ - DHMap _splits2vars; + Lib::DHMap _splits2vars; /** * An inverse of the above map, for convenience. */ - DHMap _vars2splits; + Lib::DHMap _vars2splits; protected: unsigned splitLevelToVar(SplitLevel lev) { diff --git a/Inferences/Induction.hpp b/Inferences/Induction.hpp index 9f46ca094..396562bf2 100644 --- a/Inferences/Induction.hpp +++ b/Inferences/Induction.hpp @@ -48,7 +48,6 @@ namespace Inferences using namespace Kernel; using namespace Saturation; using namespace Shell; -using namespace Lib; /** * This class is similar to @b NonVariableNonTypeIterator and is @@ -58,7 +57,7 @@ using namespace Lib; * instance. */ class ActiveOccurrenceIterator - : public IteratorCore + : public Lib::IteratorCore { public: ActiveOccurrenceIterator(Literal* lit, FunctionDefinitionHandler& fnDefHandler) @@ -72,7 +71,7 @@ class ActiveOccurrenceIterator bool hasNext() override { return !_stack.isEmpty(); } Term* next() override; private: - Stack _stack; + Lib::Stack _stack; FunctionDefinitionHandler& _fnDefHandler; }; @@ -120,7 +119,7 @@ class SkolemSquashingTermReplacement : public TermReplacement { SkolemSquashingTermReplacement(const std::map& m, unsigned& var) : TermReplacement(m), _v(var) {} TermList transformSubterm(TermList trm) override; - DHMap _tv; // maps terms to their variable replacement + Lib::DHMap _tv; // maps terms to their variable replacement private: unsigned& _v; // fresh variable counter supported by caller }; @@ -194,7 +193,7 @@ struct InductionContext { * induction terms replaced with placeholders. */ class ContextReplacement - : public TermReplacement, public IteratorCore { + : public TermReplacement, public Lib::IteratorCore { public: ContextReplacement(const InductionContext& context); @@ -273,7 +272,7 @@ class Induction ClauseIterator generateClauses(Clause* premise) override; #if VDEBUG - void setTestIndices(const Stack& indices) override { + void setTestIndices(const Lib::Stack& indices) override { _comparisonIndex = static_cast*>(indices[0]); _inductionTermIndex = static_cast(indices[1]); _structInductionTermIndex = static_cast(indices[2]); @@ -327,7 +326,7 @@ class InductionClauseIterator void performInfIntInduction(const InductionContext& context, bool increasing, const TermLiteralClause& bound); struct DefaultBound { TypedTermList term; }; - using Bound = Coproduct; + using Bound = Lib::Coproduct; void performIntInduction(const InductionContext& context, InductionFormulaIndex::Entry* e, bool increasing, Bound bound1, const TermLiteralClause* optionalBound2); void performIntInduction(const InductionContext& context, InductionFormulaIndex::Entry* e, bool increasing, TermLiteralClause const& bound1, const TermLiteralClause* optionalBound2) @@ -361,7 +360,7 @@ class InductionClauseIterator bool isValidBound(const InductionContext& context, const TermLiteralClause& bound) { return isValidBound(context, Bound(bound)); } - Stack _clauses; + Lib::Stack _clauses; InductionHelper _helper; const Options& _opt; TermIndex* _structInductionTermIndex; diff --git a/Inferences/InductionHelper.hpp b/Inferences/InductionHelper.hpp index 1e4bc4b8f..4f89038ef 100644 --- a/Inferences/InductionHelper.hpp +++ b/Inferences/InductionHelper.hpp @@ -35,10 +35,10 @@ class InductionHelper { InductionHelper(LiteralIndex* comparisonIndex, TermIndex* inductionTermIndex) : _comparisonIndex(comparisonIndex), _inductionTermIndex(inductionTermIndex) {} - VirtualIterator getLess(Term* t); - VirtualIterator getGreater(Term* t); + Lib::VirtualIterator getLess(Term* t); + Lib::VirtualIterator getGreater(Term* t); - VirtualIterator> getTQRsForInductionTerm(Term* inductionTerm); + Lib::VirtualIterator> getTQRsForInductionTerm(Term* inductionTerm); static bool isIntegerComparison(Clause* c); static bool isIntInductionOn(); @@ -65,7 +65,7 @@ class InductionHelper { static Term* getOtherTermFromComparison(Literal* l, Term* t); private: - VirtualIterator getComparisonMatch(bool polarity, bool termIsLeft, Term* t); + Lib::VirtualIterator getComparisonMatch(bool polarity, bool termIsLeft, Term* t); // The following pointers can be null if splitting or integer induction is off. LiteralIndex* _comparisonIndex; // not owned diff --git a/Inferences/InferenceEngine.hpp b/Inferences/InferenceEngine.hpp index b758d2d82..bd8ed2ffc 100644 --- a/Inferences/InferenceEngine.hpp +++ b/Inferences/InferenceEngine.hpp @@ -36,7 +36,6 @@ namespace Inferences { -using namespace Lib; using namespace Kernel; using namespace Saturation; using namespace Shell; @@ -82,7 +81,7 @@ class InferenceEngine * machinery for unit testing a single rule if that rule uses a term index. In order to circumvent this * issue we add this method in debug mode. * */ - virtual void setTestIndices(Stack const&) {} + virtual void setTestIndices(Lib::Stack const&) {} #endif // VDEBUG protected: SaturationAlgorithm* _salg; @@ -287,7 +286,7 @@ struct BwSimplificationRecord Clause* toRemove; Clause* replacement; }; -typedef VirtualIterator BwSimplificationRecordIterator; +typedef Lib::VirtualIterator BwSimplificationRecordIterator; class BackwardSimplificationEngine : public InferenceEngine @@ -351,7 +350,7 @@ class CompositeISE void attach(SaturationAlgorithm* salg); void detach(); private: - typedef List ISList; + typedef Lib::List ISList; ISList* _inners; ISList* _innersMany; }; @@ -367,7 +366,7 @@ class CompositeISE // void attach(SaturationAlgorithm* salg); // void detach(); //private: -// typedef List FSList; +// typedef Lib::List FSList; // FSList* _inners; //}; @@ -382,7 +381,7 @@ class CompositeGIE void attach(SaturationAlgorithm* salg) override; void detach() override; private: - typedef List GIList; + typedef Lib::List GIList; GIList* _inners; }; @@ -399,8 +398,8 @@ class CompositeSGI void attach(SaturationAlgorithm* salg) override; void detach() override; private: - Stack _simplifiers; - Stack _generators; + Lib::Stack _simplifiers; + Lib::Stack _generators; }; //removes clauses which define choice operators diff --git a/Inferences/Injectivity.cpp b/Inferences/Injectivity.cpp index befd38359..f9f70d8d1 100644 --- a/Inferences/Injectivity.cpp +++ b/Inferences/Injectivity.cpp @@ -29,6 +29,8 @@ namespace Inferences { +using namespace Lib; + ClauseIterator Injectivity::generateClauses(Clause* premise) { if(premise->length() != 2){ return ClauseIterator::getEmpty(); diff --git a/Inferences/Instantiation.hpp b/Inferences/Instantiation.hpp index a7f15d10d..ed26d9fa7 100644 --- a/Inferences/Instantiation.hpp +++ b/Inferences/Instantiation.hpp @@ -42,15 +42,15 @@ class Instantiation void registerClause(Clause* cl); private: - VirtualIterator getCandidateTerms(Clause* cl, unsigned var,TermList sort); + Lib::VirtualIterator getCandidateTerms(Clause* cl, unsigned var,TermList sort); class AllSubstitutionsIterator; struct ResultFn; - void tryMakeLiteralFalse(Literal*, Stack& subs); + void tryMakeLiteralFalse(Literal*, Lib::Stack& subs); Term* tryGetDifferentValue(Term* t); - DHMap*> sorted_candidates_check; - DHMap*> sorted_candidates; + Lib::DHMap*> sorted_candidates_check; + Lib::DHMap*> sorted_candidates; }; diff --git a/Inferences/PolynomialEvaluation.hpp b/Inferences/PolynomialEvaluation.hpp index 8a4017852..200378efe 100644 --- a/Inferences/PolynomialEvaluation.hpp +++ b/Inferences/PolynomialEvaluation.hpp @@ -37,12 +37,12 @@ class PolynomialEvaluation Result simplifyLiteral(Literal*) override; - Option evaluate(TermList in, SortId sortNumber) const; - Option evaluate(Term* in) const; - Option evaluate(PolyNf in) const; - Option evaluate(TypedTermList in) const; + Lib::Option evaluate(TermList in, SortId sortNumber) const; + Lib::Option evaluate(Term* in) const; + Lib::Option evaluate(PolyNf in) const; + Lib::Option evaluate(TypedTermList in) const; - Option tryEvalPredicate(Literal* orig, PolyNf* evaluatedArgs) const; + Lib::Option tryEvalPredicate(Literal* orig, PolyNf* evaluatedArgs) const; PolyNf evaluateStep(Term* orig, PolyNf* evaluatedArgs) const; }; diff --git a/Inferences/PushUnaryMinus.cpp b/Inferences/PushUnaryMinus.cpp index 267f1415f..2015c744c 100644 --- a/Inferences/PushUnaryMinus.cpp +++ b/Inferences/PushUnaryMinus.cpp @@ -15,6 +15,7 @@ namespace Inferences { using namespace std; +using namespace Lib; enum class UMinus { Int, diff --git a/Inferences/SubsumptionDemodulationHelper.hpp b/Inferences/SubsumptionDemodulationHelper.hpp index 73b6db287..0fd649992 100644 --- a/Inferences/SubsumptionDemodulationHelper.hpp +++ b/Inferences/SubsumptionDemodulationHelper.hpp @@ -39,7 +39,6 @@ namespace Inferences { using namespace Indexing; using namespace Kernel; -using namespace Lib; diff --git a/Inferences/TheoryInstAndSimp.hpp b/Inferences/TheoryInstAndSimp.hpp index 93b2dd036..ae184eb37 100644 --- a/Inferences/TheoryInstAndSimp.hpp +++ b/Inferences/TheoryInstAndSimp.hpp @@ -49,7 +49,7 @@ class TheoryInstAndSimp public: using SortId = SAT::Z3Interfacing::SortId; ~TheoryInstAndSimp(); - TheoryInstAndSimp() : TheoryInstAndSimp(*env.options) {} + TheoryInstAndSimp() : TheoryInstAndSimp(*Lib::env.options) {} TheoryInstAndSimp(Options& opts); TheoryInstAndSimp(Options::TheoryInstSimp mode, bool thiTautologyDeletion, bool showZ3, bool generalisation, std::string const& exportSmtlib); @@ -60,26 +60,26 @@ class TheoryInstAndSimp private: struct SkolemizedLiterals { - Stack lits; - Stack vars; + Lib::Stack lits; + Lib::Stack vars; Substitution subst; }; template SkolemizedLiterals skolemize(IterLits lits); - VirtualIterator getSolutions(Stack const& theoryLiterals, Stack const& guards, unsigned freshVar); + Lib::VirtualIterator getSolutions(Lib::Stack const& theoryLiterals, Lib::Stack const& guards, unsigned freshVar); - Option instantiateWithModel(SkolemizedLiterals skolemized); - Option instantiateGeneralised(SkolemizedLiterals skolemized, unsigned freshVar); + Lib::Option instantiateWithModel(SkolemizedLiterals skolemized); + Lib::Option instantiateGeneralised(SkolemizedLiterals skolemized, unsigned freshVar); - Stack selectTheoryLiterals(Clause* cl); + Lib::Stack selectTheoryLiterals(Clause* cl); - void originalSelectTheoryLiterals(Clause* cl, Stack& theoryLits,bool forZ3); + void originalSelectTheoryLiterals(Clause* cl, Lib::Stack& theoryLits,bool forZ3); - Stack applyFilters(Stack theoryLits); - void filterUninterpretedPartialFunctionDeep(Stack& theoryLits, Stack& filteredLits); + Lib::Stack applyFilters(Lib::Stack theoryLits); + void filterUninterpretedPartialFunctionDeep(Lib::Stack& theoryLits, Lib::Stack& filteredLits); /** returns the set of literals trivial in cl */ - Stack selectTrivialLiterals(Clause* cl ); + Lib::Stack selectTrivialLiterals(Clause* cl ); bool isPure(Literal* lit); /** @@ -113,7 +113,7 @@ class TheoryInstAndSimp { class SortedConstantCache { unsigned _used; - Stack _constants; + Lib::Stack _constants; public: SortedConstantCache() : _used(0), _constants() {} void reset(); @@ -121,7 +121,7 @@ class TheoryInstAndSimp }; const char* _prefix; - Map _inner; + Lib::Map _inner; public: ConstantCache(const char* prefix) : _prefix(prefix), _inner() {} @@ -138,7 +138,7 @@ class TheoryInstAndSimp volatile char padding00[1024]; Z3Interfacing* _solver; volatile char padding01[1024]; - Map _supportedSorts; + Lib::Map _supportedSorts; bool _generalisation; ConstantCache _instantiationConstants; ConstantCache _generalizationConstants; diff --git a/Inferences/URResolution.hpp b/Inferences/URResolution.hpp index c2d649718..4b08ecfd8 100644 --- a/Inferences/URResolution.hpp +++ b/Inferences/URResolution.hpp @@ -41,7 +41,7 @@ class URResolution private: struct Item; - typedef List ItemList; + typedef Lib::List ItemList; void processAndGetClauses(Item* itm, unsigned startIdx, ClauseList*& acc); diff --git a/Kernel/ApplicativeHelper.hpp b/Kernel/ApplicativeHelper.hpp index c7bfcd6bf..1dc10dc54 100644 --- a/Kernel/ApplicativeHelper.hpp +++ b/Kernel/ApplicativeHelper.hpp @@ -63,7 +63,7 @@ class ApplicativeHelper { static void getHeadAndAllArgs(TermList term, TermList& head, TermStack& args); static void getHeadAndArgs(TermList term, TermList& head, TermStack& args); static void getHeadAndArgs(Term* term, TermList& head, TermStack& args); - static void getHeadAndArgs(const Term* term, TermList& head, Deque& args); + static void getHeadAndArgs(const Term* term, TermList& head, Lib::Deque& args); static void getHeadSortAndArgs(TermList term, TermList& head, TermList& headSort, TermStack& args); static bool isComb(const TermList t); static Signature::Combinator getComb(const TermList t); diff --git a/Kernel/BestLiteralSelector.hpp b/Kernel/BestLiteralSelector.hpp index ddf62ff33..fcb65c61b 100644 --- a/Kernel/BestLiteralSelector.hpp +++ b/Kernel/BestLiteralSelector.hpp @@ -37,7 +37,6 @@ namespace Kernel { -using namespace Lib; /** * A literal selector class template that selects the best literal @@ -63,6 +62,7 @@ class BestLiteralSelector protected: void doSelection(Clause* c, unsigned eligible) override { + using namespace Lib; unsigned besti=0; Literal* best=(*c)[0]; for(unsigned i=1;icombinatorySup(); + static bool combSup = Lib::env.options->combinatorySup(); - static DArray litArr(64); - static Set maxTermHeads; + static Lib::DArray litArr(64); + static Lib::Set maxTermHeads; maxTermHeads.reset(); litArr.initFromArray(eligible,*c); litArr.sortInversed(_comp); @@ -190,8 +190,8 @@ class CompleteBestLiteralSelector c->setSelected(eligible); } else if(!singleSelected) { //select multiple maximal literals - static Stack replaced(16); - Set maxSet; + static Lib::Stack replaced(16); + Lib::Set maxSet; unsigned selCnt=0; for(LiteralList* mit=maximals; mit; mit=mit->tail()) { @@ -231,9 +231,9 @@ class CompleteBestLiteralSelector ensureSomeColoredSelected(c, eligible); } - void fillMaximals(LiteralList*& maximals, DArray& litArr) + void fillMaximals(LiteralList*& maximals, Lib::DArray& litArr) { - DArray::ReversedIterator rlit(litArr); + Lib::DArray::ReversedIterator rlit(litArr); while(rlit.hasNext()) { Literal* lit=rlit.next(); LiteralList::push(lit,maximals); diff --git a/Kernel/BottomUpEvaluation.hpp b/Kernel/BottomUpEvaluation.hpp index bd61213ea..aa9164e1b 100644 --- a/Kernel/BottomUpEvaluation.hpp +++ b/Kernel/BottomUpEvaluation.hpp @@ -39,8 +39,8 @@ namespace Memo { template struct None { - Option get(Arg const&) - { return Option(); } + Lib::Option get(Arg const&) + { return Lib::Option(); } template Result getOrInit(Arg const& orig, Init init) { return init(); } @@ -50,7 +50,7 @@ namespace Memo { template class Hashed { - Map _memo; + Lib::Map _memo; public: Hashed() : _memo(decltype(_memo)()) {} @@ -58,7 +58,7 @@ namespace Memo { template Result getOrInit(Arg const& orig, Init init) { return _memo.getOrInit(Arg(orig), init); } - Option get(const Arg& orig) + Lib::Option get(const Arg& orig) { return _memo.tryGet(orig).toOwned(); } }; @@ -144,7 +144,7 @@ auto replaceTupleElem(std::tuple tup, B b) -> decltype(auto) template struct ReturnNone { template - constexpr Option operator()(As...) const { return Option(); } + constexpr Lib::Option operator()(As...) const { return Lib::Option(); } }; template @@ -303,7 +303,7 @@ class BottomUpEvaluation { * // In this case we do it for shared terms if the function returns a value (non-empty Option) * // the evalution does not recurse but just use the result. If the returned option is empty * // the term is recursively evaluated as usual. - * .evNonRec([](auto& t) { return t.shared() ? Option(t.weight) : Option()); }) + * .evNonRec([](auto& t) { return t.shared() ? Lib::Option(t.weight) : Lib::Option()); }) * * // (optional) * // a memo can be used cache evaluated sub result. We need to explicitly specify to pass it as @@ -324,8 +324,8 @@ class BottomUpEvaluation { Result apply(Arg const& toEval) { /* recursion state. Contains a stack of items that are being recursed on. */ - Recycled>> recState; - Recycled> recResults; + Lib::Recycled>> recState; + Lib::Recycled> recResults; recState->push(BottomUpChildIter(toEval, _context)); @@ -333,12 +333,12 @@ class BottomUpEvaluation { if (recState->top().hasNext(_context)) { Arg t = recState->top().next(_context); - Option nonRec = _evNonRec(t); + Lib::Option nonRec = _evNonRec(t); if (nonRec) { recResults->push(move_if_value(*nonRec)); } else { - Option cached = _memo.get(t); + Lib::Option cached = _memo.get(t); if (cached.isSome()) { recResults->push(std::move(cached).unwrap()); } else { @@ -446,7 +446,7 @@ template Kernel::Literal* evaluateLiteralBottomUp(Kernel::Literal* const& lit, EvalFn evaluateStep, Memo& memo) { using namespace Kernel; - Recycled> args; + Lib::Recycled> args; for (unsigned i = 0; i < lit->arity(); i++) { args->push( BottomUpEvaluation() @@ -518,10 +518,10 @@ struct BottomUpChildIter struct FuncTermBottomUpChildIter { - Perfect _self; + Lib::Perfect _self; unsigned _idx; - FuncTermBottomUpChildIter(Perfect self) : _self(self), _idx(0) {} + FuncTermBottomUpChildIter(Lib::Perfect self) : _self(self), _idx(0) {} bool hasNext() const { return _idx < _self->numTermArguments(); } @@ -555,11 +555,11 @@ struct BottomUpChildIter { return out << self._self; } }; - using Inner = Coproduct; + using Inner = Lib::Coproduct; Inner _self; BottomUpChildIter(Kernel::PolyNf self, EmptyContext = EmptyContext()) : _self(self.match( - [&](Perfect self) { return Inner(FuncTermBottomUpChildIter( self )); }, + [&](Lib::Perfect self) { return Inner(FuncTermBottomUpChildIter( self )); }, [&](Kernel::Variable self) { return Inner(VariableBottomUpChildIter( self )); }, [&](Kernel::AnyPoly self) { return Inner(PolynomialBottomUpChildIter(std::move(self))); } )) diff --git a/Kernel/Clause.hpp b/Kernel/Clause.hpp index 07de871aa..c94290e58 100644 --- a/Kernel/Clause.hpp +++ b/Kernel/Clause.hpp @@ -33,7 +33,6 @@ namespace Kernel { -using namespace Lib; /** * Class to represent clauses. @@ -54,7 +53,7 @@ class Clause void operator delete(void* ptr) { ASSERTION_VIOLATION; } template - void collectVars2(DHSet& acc); + void collectVars2(Lib::DHSet& acc); public: DECL_ELEMENT_TYPE(Literal*); @@ -90,13 +89,13 @@ class Clause { return fromLiterals({}, inf); } - static Clause* fromStack(const Stack& lits, Inference inf) + static Clause* fromStack(const Lib::Stack& lits, Inference inf) { return new(lits.size()) Clause(lits.begin(), lits.size(), std::move(inf)); } template static Clause* fromIterator(Iter litit, const Inference& inf) { - static Stack st; + static Lib::Stack st; st.reset(); st.loadFromIterator(litit); return fromStack(st, inf); @@ -234,17 +233,17 @@ class Clause return savedTimestamp == _reductionTimestamp; } - auto getSelectedLiteralIterator() { return arrayIter(*this,numSelected()); } - auto iterLits() { return arrayIter(*this,size()); } - auto iterLits() const { return arrayIter(*this,size()); } + auto getSelectedLiteralIterator() { return Lib::arrayIter(*this,numSelected()); } + auto iterLits() { return Lib::arrayIter(*this,size()); } + auto iterLits() const { return Lib::arrayIter(*this,size()); } // TODO remove this - auto getLiteralIterator() { return arrayIter(*this,size()); } + auto getLiteralIterator() { return Lib::arrayIter(*this,size()); } bool isGround(); bool isPropositional(); bool isHorn(); - VirtualIterator getVariableIterator(); + Lib::VirtualIterator getVariableIterator(); bool contains(Literal* lit); #if VDEBUG @@ -271,7 +270,7 @@ class Clause void incNumActiveSplits() { _numActiveSplits++; } void decNumActiveSplits() { _numActiveSplits--; } - VirtualIterator toSimpleClauseStrings(); + Lib::VirtualIterator toSimpleClauseStrings(); void setAux() { @@ -345,8 +344,8 @@ class Clause unsigned splitWeight() const; unsigned getNumeralWeight() const; - void collectVars(DHSet& acc); - void collectUnstableVars(DHSet& acc); + void collectVars(Lib::DHSet& acc); + void collectUnstableVars(Lib::DHSet& acc); unsigned varCnt(); @@ -391,7 +390,7 @@ class Clause /** for splitting: timestamp marking when has the clause been reduced or restored by splitting */ unsigned _reductionTimestamp; /** a map that translates Literal* to its index in the clause */ - InverseLookup* _literalPositions; + Lib::InverseLookup* _literalPositions; int _numActiveSplits; diff --git a/Kernel/ColorHelper.cpp b/Kernel/ColorHelper.cpp index 4dbda5c3c..35d0fadfc 100644 --- a/Kernel/ColorHelper.cpp +++ b/Kernel/ColorHelper.cpp @@ -33,6 +33,7 @@ namespace Kernel { using namespace std; +using namespace Lib; /** * Return true if symbol number @c functor is transparent. If @c predicate diff --git a/Kernel/ColorHelper.hpp b/Kernel/ColorHelper.hpp index b16313692..5bf5dcb28 100644 --- a/Kernel/ColorHelper.hpp +++ b/Kernel/ColorHelper.hpp @@ -24,7 +24,6 @@ namespace Kernel { -using namespace Lib; using namespace Saturation; class ColorHelper { @@ -35,7 +34,7 @@ class ColorHelper { */ static Color combine(Color c1, Color c2) { - ASS(env.colorUsed || (c1|c2)!=COLOR_INVALID); + ASS(Lib::env.colorUsed || (c1|c2)!=COLOR_INVALID); return static_cast(c1|c2); } @@ -58,13 +57,13 @@ class ColorHelper { static void tryUnblock(Clause* c, SaturationAlgorithm* salg); private: - typedef DHMap TermMap; + typedef Lib::DHMap TermMap; static void ensureSkolemReplacement(Term* t, TermMap& map); static void collectSkolemReplacements(Clause* c, TermMap& map); static Term* applyReplacement(Term* t, TermMap& map); - static void collectColoredConstants(Clause* c, Stack& acc); + static void collectColoredConstants(Clause* c, Lib::Stack& acc); }; } diff --git a/Kernel/EqHelper.cpp b/Kernel/EqHelper.cpp index e7fd7ff1f..e9bda088b 100644 --- a/Kernel/EqHelper.cpp +++ b/Kernel/EqHelper.cpp @@ -27,6 +27,7 @@ namespace Kernel { +using namespace Lib; using namespace Shell; /* diff --git a/Kernel/EqHelper.hpp b/Kernel/EqHelper.hpp index 246e33e28..972a584d4 100644 --- a/Kernel/EqHelper.hpp +++ b/Kernel/EqHelper.hpp @@ -28,7 +28,6 @@ namespace Kernel { -using namespace Lib; using namespace Shell; class EqHelper @@ -36,15 +35,15 @@ class EqHelper public: static TermList getOtherEqualitySide(Literal* eq, TermList lhs); static bool hasGreaterEqualitySide(Literal* eq, const Ordering& ord, TermList& lhs, TermList& rhs); - static VirtualIterator getSubtermIterator(Literal* lit, const Ordering& ord); - static VirtualIterator getFoSubtermIterator(Literal* lit, const Ordering& ord); + static Lib::VirtualIterator getSubtermIterator(Literal* lit, const Ordering& ord); + static Lib::VirtualIterator getFoSubtermIterator(Literal* lit, const Ordering& ord); static TermIterator getBooleanSubtermIterator(Literal* lit, const Ordering& ord); static TermIterator getNarrowableSubtermIterator(Literal* lit, const Ordering& ord); - static VirtualIterator getRewritableVarsIterator(DHSet* unstableVars, Literal* lit, const Ordering& ord); - static VirtualIterator getLHSIterator(Literal* lit, const Ordering& ord); - static VirtualIterator getSuperpositionLHSIterator(Literal* lit, const Ordering& ord, const Options& opt); - static VirtualIterator getSubVarSupLHSIterator(Literal* lit, const Ordering& ord); - static std::pair,bool> getDemodulationLHSIterator(Literal* lit, bool onlyPreordered, const Ordering& ord); + static Lib::VirtualIterator getRewritableVarsIterator(Lib::DHSet* unstableVars, Literal* lit, const Ordering& ord); + static Lib::VirtualIterator getLHSIterator(Literal* lit, const Ordering& ord); + static Lib::VirtualIterator getSuperpositionLHSIterator(Literal* lit, const Ordering& ord, const Options& opt); + static Lib::VirtualIterator getSubVarSupLHSIterator(Literal* lit, const Ordering& ord); + static std::pair,bool> getDemodulationLHSIterator(Literal* lit, bool onlyPreordered, const Ordering& ord); static TermIterator getEqualityArgumentIterator(Literal* lit); //WARNING, this function cannot be used when @param t is a sort. @@ -55,7 +54,7 @@ class EqHelper { LHSIteratorFn(const Ordering& ord) : _ord(ord) {} - VirtualIterator > operator()(Literal* lit) + Lib::VirtualIterator > operator()(Literal* lit) { return pvi( pushPairIntoRightIterator(lit, getLHSIterator(lit, _ord)) ); } @@ -67,7 +66,7 @@ class EqHelper { SuperpositionLHSIteratorFn(const Ordering& ord, const Options& opt) : _ord(ord), _opt(opt) {} - VirtualIterator > operator()(Literal* lit) + Lib::VirtualIterator > operator()(Literal* lit) { return pvi( pushPairIntoRightIterator(lit, getSuperpositionLHSIterator(lit, _ord, _opt)) ); } @@ -80,7 +79,7 @@ class EqHelper { SubVarSupLHSIteratorFn(const Ordering& ord) : _ord(ord) {} - VirtualIterator > operator()(Literal* lit) + Lib::VirtualIterator > operator()(Literal* lit) { return pvi( pushPairIntoRightIterator(lit, getSubVarSupLHSIterator(lit, _ord)) ); } @@ -91,7 +90,7 @@ class EqHelper struct EqualityArgumentIteratorFn { - VirtualIterator > operator()(Literal* lit) + Lib::VirtualIterator > operator()(Literal* lit) { return pvi( pushPairIntoRightIterator(lit, getEqualityArgumentIterator(lit)) ); } @@ -104,7 +103,7 @@ class EqHelper private: template - static VirtualIterator getRewritableSubtermIterator(Literal* lit, const Ordering& ord); + static Lib::VirtualIterator getRewritableSubtermIterator(Literal* lit, const Ordering& ord); struct IsNonVariable; diff --git a/Kernel/Formula.cpp b/Kernel/Formula.cpp index e3265f487..8ea5ae93e 100644 --- a/Kernel/Formula.cpp +++ b/Kernel/Formula.cpp @@ -21,6 +21,7 @@ namespace Kernel { using namespace std; +using namespace Lib; std::string Formula::DEFAULT_LABEL = "none"; diff --git a/Kernel/Formula.hpp b/Kernel/Formula.hpp index 9a250c090..36862de85 100644 --- a/Kernel/Formula.hpp +++ b/Kernel/Formula.hpp @@ -32,7 +32,6 @@ namespace Kernel { -using namespace Lib; class Formula { @@ -355,10 +354,10 @@ class BoolTermFormula } } else { unsigned functor = term->functor(); - if (env.signature->isFoolConstantSymbol(true, functor)) { + if (Lib::env.signature->isFoolConstantSymbol(true, functor)) { return new Formula(true); } else { - ASS(env.signature->isFoolConstantSymbol(false, functor)); + ASS(Lib::env.signature->isFoolConstantSymbol(false, functor)); return new Formula(false); } } diff --git a/Kernel/FormulaTransformer.cpp b/Kernel/FormulaTransformer.cpp index 646619cf6..409b22eed 100644 --- a/Kernel/FormulaTransformer.cpp +++ b/Kernel/FormulaTransformer.cpp @@ -28,6 +28,8 @@ namespace Kernel { +using namespace Lib; + Formula* FormulaTransformer::transform(Formula* f) { Formula* res = apply(f); return res; diff --git a/Kernel/FormulaTransformer.hpp b/Kernel/FormulaTransformer.hpp index 04cb72996..198d70d59 100644 --- a/Kernel/FormulaTransformer.hpp +++ b/Kernel/FormulaTransformer.hpp @@ -119,7 +119,7 @@ class PolarityAwareFormulaTransformer : protected FormulaTransformer { TermList getVarSort(unsigned var) const; private: - Recycled> _varSorts; + Lib::Recycled> _varSorts; int _polarity; }; diff --git a/Kernel/FormulaUnit.hpp b/Kernel/FormulaUnit.hpp index 72a8e479d..8854a3e84 100644 --- a/Kernel/FormulaUnit.hpp +++ b/Kernel/FormulaUnit.hpp @@ -21,7 +21,6 @@ #include "Unit.hpp" -using namespace Lib; namespace Kernel { diff --git a/Kernel/FormulaVarIterator.hpp b/Kernel/FormulaVarIterator.hpp index 4a8c7e8df..069df6e0a 100644 --- a/Kernel/FormulaVarIterator.hpp +++ b/Kernel/FormulaVarIterator.hpp @@ -27,7 +27,6 @@ #include "Kernel/Term.hpp" #include "Kernel/Formula.hpp" -using namespace Lib; namespace Kernel { @@ -74,19 +73,19 @@ class FormulaVarIterator unsigned _nextVar; /** Counter used to store bound variables, together with the number of times they are bound */ - MultiCounter _bound; + Lib::MultiCounter _bound; /** To store previously found free variables */ - MultiCounter _free; + Lib::MultiCounter _free; /** Stack of formulas to be processed */ - Stack _formulas; + Lib::Stack _formulas; /** Stack of terms to process */ - Stack _terms; + Lib::Stack _terms; /** Stack of term lists to process */ - Stack _termLists; + Lib::Stack _termLists; /** Stack of instructions telling what to do next */ - Stack _instructions; + Lib::Stack _instructions; /** Stack of lists of variables to process */ - Stack _vars; + Lib::Stack _vars; }; // class FormulaVarIterator template // a template to work with Term*, TermList*, and Formula* diff --git a/Kernel/Grounder.cpp b/Kernel/Grounder.cpp index 4baaa4751..c6890ea43 100644 --- a/Kernel/Grounder.cpp +++ b/Kernel/Grounder.cpp @@ -34,6 +34,7 @@ #include "Grounder.hpp" using namespace std; +using namespace Lib; using namespace Kernel; /** diff --git a/Kernel/Grounder.hpp b/Kernel/Grounder.hpp index 666107043..75e3234b1 100644 --- a/Kernel/Grounder.hpp +++ b/Kernel/Grounder.hpp @@ -25,7 +25,6 @@ namespace Kernel { -using namespace Lib; using namespace SAT; class Grounder { @@ -53,7 +52,7 @@ class Grounder { SATLiteral groundNormalized(Literal*); /** Map from positive literals to SAT variable numbers */ - DHMap _asgn; + Lib::DHMap _asgn; /** Pointer to a SATSolver instance for which the grounded clauses * are being prepared. Used to request new variables from the Solver. diff --git a/Kernel/Inference.cpp b/Kernel/Inference.cpp index 26d462dbf..9609ceb4c 100644 --- a/Kernel/Inference.cpp +++ b/Kernel/Inference.cpp @@ -24,6 +24,7 @@ #include "Inference.hpp" using namespace std; +using namespace Lib; using namespace Kernel; diff --git a/Kernel/Inference.hpp b/Kernel/Inference.hpp index 77df9b4f8..063128974 100644 --- a/Kernel/Inference.hpp +++ b/Kernel/Inference.hpp @@ -25,7 +25,6 @@ #include #include -using namespace Lib; namespace Kernel { diff --git a/Kernel/InferenceStore.hpp b/Kernel/InferenceStore.hpp index c183881fa..24158525f 100644 --- a/Kernel/InferenceStore.hpp +++ b/Kernel/InferenceStore.hpp @@ -32,14 +32,13 @@ namespace Kernel { -using namespace Lib; class InferenceStore { public: static InferenceStore* instance(); - typedef List IntList; + typedef Lib::List IntList; struct FullInference { @@ -84,16 +83,16 @@ class InferenceStore ProofPrinter* createProofPrinter(std::ostream& out); - DHMultiset _nextClIds; + Lib::DHMultiset _nextClIds; - DHMap _splittingNameLiterals; + Lib::DHMap _splittingNameLiterals; /** first records the type of the symbol (PRED,FUNC or TYPE_CON), second is symbol number */ typedef std::pair SymbolId; - typedef Stack SymbolStack; - DHMap _introducedSymbols; - DHMap _introducedSplitNames; + typedef Lib::Stack SymbolStack; + Lib::DHMap _introducedSymbols; + Lib::DHMap _introducedSplitNames; }; diff --git a/Kernel/InterpretedLiteralEvaluator.hpp b/Kernel/InterpretedLiteralEvaluator.hpp index 9525cdf2f..4d695b9de 100644 --- a/Kernel/InterpretedLiteralEvaluator.hpp +++ b/Kernel/InterpretedLiteralEvaluator.hpp @@ -48,13 +48,13 @@ class InterpretedLiteralEvaluator class RatEvaluator; class RealEvaluator; - typedef Stack EvalStack; + typedef Lib::Stack EvalStack; virtual TermList transformSubterm(TermList trm); Evaluator* getFuncEvaluator(unsigned func); Evaluator* getPredEvaluator(unsigned pred); EvalStack _evals; - DArray _funEvaluators; - DArray _predEvaluators; + Lib::DArray _funEvaluators; + Lib::DArray _predEvaluators; bool balancable(Literal* lit); bool balance(Literal* lit,Literal*& res); @@ -80,7 +80,7 @@ class InterpretedLiteralEvaluator private: template - Evaluator* getEvaluator(unsigned func, DArray& evaluators, Fn canEval); + Evaluator* getEvaluator(unsigned func, Lib::DArray& evaluators, Fn canEval); const bool _normalize; }; diff --git a/Kernel/KBO.hpp b/Kernel/KBO.hpp index 4cfd03f3a..adec15606 100644 --- a/Kernel/KBO.hpp +++ b/Kernel/KBO.hpp @@ -34,7 +34,6 @@ namespace Kernel { -using namespace Lib; #if __KBO__CUSTOM_PREDICATE_WEIGHTS__ struct PredSigTraits; @@ -100,7 +99,7 @@ struct KboSpecialWeights template struct KboWeightMap { friend class KBO; - DArray _weights; + Lib::DArray _weights; /** KboWeight of function symbols not occurring in the signature, i.e. that are introduced during proof search */ KboWeight _introducedSymbolWeight; @@ -137,10 +136,10 @@ class KBO #endif // precedence ordering params - DArray funcPrec, - DArray typeConPrec, - DArray predPrec, - DArray predLevels, + Lib::DArray funcPrec, + Lib::DArray typeConPrec, + Lib::DArray predPrec, + Lib::DArray predLevels, // other bool reverseLCM); @@ -180,7 +179,7 @@ class KBO #endif template const KboWeightMap& getWeightMap() const; - template KboWeightMap weightsFromOpts(const Options& opts, const DArray& rawPrecedence) const; + template KboWeightMap weightsFromOpts(const Options& opts, const Lib::DArray& rawPrecedence) const; template KboWeightMap weightsFromFile(const Options& opts) const; template diff --git a/Kernel/KBOComparator.hpp b/Kernel/KBOComparator.hpp index c97a3e40a..f38a74adb 100644 --- a/Kernel/KBOComparator.hpp +++ b/Kernel/KBOComparator.hpp @@ -23,7 +23,6 @@ namespace Kernel { -using namespace Lib; /** * Runtime specialized KBO ordering check, based on the linear KBO check @@ -42,7 +41,7 @@ class KBOComparator private: // TODO this could be done with KBO::State - static void countSymbols(const KBO& kbo, DHMap& vars, int& w, TermList t, int coeff); + static void countSymbols(const KBO& kbo, Lib::DHMap& vars, int& w, TermList t, int coeff); enum InstructionTag { DATA = 0u, @@ -114,7 +113,7 @@ class KBOComparator uint64_t _content; }; const KBO& _kbo; - Stack _instructions; + Lib::Stack _instructions; }; } diff --git a/Kernel/LPO.hpp b/Kernel/LPO.hpp index 433f36501..61df01c34 100644 --- a/Kernel/LPO.hpp +++ b/Kernel/LPO.hpp @@ -26,7 +26,6 @@ namespace Kernel { -using namespace Lib; /** * Class for instances of the lexicographic path orderings @@ -38,8 +37,8 @@ class LPO LPO(Problem& prb, const Options& opt) : PrecedenceOrdering(prb, opt) {} - LPO(const DArray& funcPrec, const DArray& typeConPrec, - const DArray& predPrec, const DArray& predLevels, bool reverseLCM) : + LPO(const Lib::DArray& funcPrec, const Lib::DArray& typeConPrec, + const Lib::DArray& predPrec, const Lib::DArray& predLevels, bool reverseLCM) : PrecedenceOrdering(funcPrec, typeConPrec, predPrec, predLevels, reverseLCM) {} ~LPO() override = default; diff --git a/Kernel/LPOComparator.hpp b/Kernel/LPOComparator.hpp index 8deb0c30b..889a20b85 100644 --- a/Kernel/LPOComparator.hpp +++ b/Kernel/LPOComparator.hpp @@ -17,7 +17,6 @@ namespace Kernel { -using namespace Lib; using namespace std; /** @@ -102,14 +101,14 @@ class LPOComparator }; private: - static pair,Instruction::BranchTag> majoChain(const LPO& lpo, TermList tl1, Term* t, unsigned i); - static pair,Instruction::BranchTag> alphaChain(const LPO& lpo, Term* s, unsigned i, TermList tl2); - static pair,Instruction::BranchTag>* createHelper(TermList tl1, TermList tl2, const LPO& lpo); + static pair,Instruction::BranchTag> majoChain(const LPO& lpo, TermList tl1, Term* t, unsigned i); + static pair,Instruction::BranchTag> alphaChain(const LPO& lpo, Term* s, unsigned i, TermList tl2); + static pair,Instruction::BranchTag>* createHelper(TermList tl1, TermList tl2, const LPO& lpo); const LPO& _lpo; /** This is non-empty if @b _res is @b BranchTag::T_JUMP */ - Stack _instructions; + Lib::Stack _instructions; /** It contains the result of the comparison if the terms * are comparable, otherwise it contains @b BranchTag::T_JUMP diff --git a/Kernel/LiteralComparators.hpp b/Kernel/LiteralComparators.hpp index 221e60349..b0046cc4f 100644 --- a/Kernel/LiteralComparators.hpp +++ b/Kernel/LiteralComparators.hpp @@ -27,7 +27,6 @@ namespace Kernel { namespace LiteralComparators { -using namespace Lib; //typedef CompositeComaprator Composite; @@ -50,9 +49,10 @@ template class Composite : public LiteralComparator { public: - Comparison compare(Literal* l1, Literal* l2) + Lib::Comparison compare(Literal* l1, Literal* l2) { - Comparison res1=_c1.compare(l1,l2); + using namespace Lib; + Lib::Comparison res1=_c1.compare(l1,l2); return (res1==EQUAL)?_c2.compare(l1,l2):res1; } @@ -71,7 +71,7 @@ template class Inverse : public LiteralComparator { public: - Comparison compare(Literal* l1, Literal* l2) + Lib::Comparison compare(Literal* l1, Literal* l2) { return _c.compare(l2,l1); } @@ -87,8 +87,9 @@ class Inverse : public LiteralComparator struct ColoredFirst : public LiteralComparator { - Comparison compare(Literal* l1, Literal* l2) + Lib::Comparison compare(Literal* l1, Literal* l2) { + using namespace Lib; if(l1->color()!=COLOR_TRANSPARENT && l2->color()==COLOR_TRANSPARENT) { return GREATER; } else if(l1->color()==COLOR_TRANSPARENT && l2->color()!=COLOR_TRANSPARENT) { @@ -101,8 +102,9 @@ struct ColoredFirst : public LiteralComparator struct NoPositiveEquality : public LiteralComparator { - Comparison compare(Literal* l1, Literal* l2) + Lib::Comparison compare(Literal* l1, Literal* l2) { + using namespace Lib; bool l1PE=l1->isEquality()&&l1->isPositive(); bool l2PE=l2->isEquality()&&l2->isPositive(); if( l1PE && !l2PE ) { @@ -117,8 +119,9 @@ struct NoPositiveEquality : public LiteralComparator struct Negative : public LiteralComparator { - Comparison compare(Literal* l1, Literal* l2) + Lib::Comparison compare(Literal* l1, Literal* l2) { + using namespace Lib; ASS(_selector); bool l1N=_selector->isNegativeForSelection(l1); @@ -135,8 +138,9 @@ struct Negative : public LiteralComparator struct NegativeEquality : public LiteralComparator { - Comparison compare(Literal* l1, Literal* l2) + Lib::Comparison compare(Literal* l1, Literal* l2) { + using namespace Lib; bool l1NE=l1->isEquality()&&l1->isNegative(); bool l2NE=l2->isEquality()&&l2->isNegative(); if( l1NE && !l2NE ) { @@ -151,33 +155,33 @@ struct NegativeEquality : public LiteralComparator struct MaximalSize : public LiteralComparator { - Comparison compare(Literal* l1, Literal* l2) + Lib::Comparison compare(Literal* l1, Literal* l2) { - return Int::compare(l1->weight(), l2->weight()); + return Lib::Int::compare(l1->weight(), l2->weight()); } }; struct LeastVariables : public LiteralComparator { - Comparison compare(Literal* l1, Literal* l2) + Lib::Comparison compare(Literal* l1, Literal* l2) { - return Int::compare(l2->numVarOccs(), l1->numVarOccs()); + return Lib::Int::compare(l2->numVarOccs(), l1->numVarOccs()); } }; struct LeastDistinctVariables : public LiteralComparator { - Comparison compare(Literal* l1, Literal* l2) + Lib::Comparison compare(Literal* l1, Literal* l2) { - return Int::compare(l2->getDistinctVars(), l1->getDistinctVars()); + return Lib::Int::compare(l2->getDistinctVars(), l1->getDistinctVars()); } }; struct LeastTopLevelVariables : public LiteralComparator { - Comparison compare(Literal* l1, Literal* l2) + Lib::Comparison compare(Literal* l1, Literal* l2) { - return Int::compare(getTLVarCnt(l2), getTLVarCnt(l1)); + return Lib::Int::compare(getTLVarCnt(l2), getTLVarCnt(l1)); } private: unsigned getTLVarCnt(Literal* l) @@ -194,13 +198,14 @@ struct LeastTopLevelVariables : public LiteralComparator struct LexComparator : public LiteralComparator { - Comparison compare(Literal* l1, Literal* l2) + Lib::Comparison compare(Literal* l1, Literal* l2) { + using namespace Lib; ASS(l1->shared()); ASS(l2->shared()); if(l1->header()!=l2->header()) { - return Int::compare(l1->header(),l2->header()); + return Lib::Int::compare(l1->header(),l2->header()); } SubtermIterator sit1(l1); @@ -214,7 +219,7 @@ struct LexComparator : public LiteralComparator unsigned f1=st1.term()->functor(); unsigned f2=st2.term()->functor(); if(f1!=f2) { - return Int::compare(f1,f2); + return Lib::Int::compare(f1,f2); } } else { return GREATER; @@ -224,7 +229,7 @@ struct LexComparator : public LiteralComparator return LESS; } else { if(st1.var()!=st2.var()) { - return Int::compare(st1.var(),st2.var()); + return Lib::Int::compare(st1.var(),st2.var()); } } } @@ -243,19 +248,20 @@ struct LexComparator : public LiteralComparator template struct NormalizedLinearComparatorByWeight : public LiteralComparator { - Comparison compare(Term* t1, Term* t2) + Lib::Comparison compare(Term* t1, Term* t2) { + using namespace Lib; ASS_EQ(t1->isLiteral(), t2->isLiteral()); if(t1->weight()!=t2->weight()) { - return Int::compare(t1->weight(),t2->weight()); + return Lib::Int::compare(t1->weight(),t2->weight()); } if(t1->functor()!=t2->functor()) { - return Int::compare(t1->functor(),t2->functor()); + return Lib::Int::compare(t1->functor(),t2->functor()); } if(t1->isLiteral() && !ignorePolarity && static_cast(t1)->polarity()!=static_cast(t2)->polarity()) { - return Int::compare(static_cast(t1)->polarity(), + return Lib::Int::compare(static_cast(t1)->polarity(), static_cast(t2)->polarity()); } @@ -272,8 +278,8 @@ struct NormalizedLinearComparatorByWeight : public LiteralComparator } } - static DHMap firstNums; - static DHMap secondNums; + static Lib::DHMap firstNums; + static Lib::DHMap secondNums; firstNums.reset(); secondNums.reset(); @@ -283,7 +289,7 @@ struct NormalizedLinearComparatorByWeight : public LiteralComparator if(dis.first.isTerm()) { if(dis.second.isTerm()) { ASS_NEQ(dis.first.term()->functor(), dis.second.term()->functor()); - return Int::compare(dis.first.term()->functor(), dis.second.term()->functor()); + return Lib::Int::compare(dis.first.term()->functor(), dis.second.term()->functor()); } return GREATER; } @@ -293,15 +299,16 @@ struct NormalizedLinearComparatorByWeight : public LiteralComparator int firstNorm=firstNums.findOrInsert(dis.first.var(), firstNums.size()); int secondNorm=secondNums.findOrInsert(dis.second.var(), secondNums.size()); if(firstNorm!=secondNorm) { - return Int::compare(secondNorm, firstNorm); + return Lib::Int::compare(secondNorm, firstNorm); } } //they're variants of each other return EQUAL; } - Comparison compare(TermList t1, TermList t2) + Lib::Comparison compare(TermList t1, TermList t2) { + using namespace Lib; if(t1.isVar()) { if(t2.isVar()) { return EQUAL; diff --git a/Kernel/LiteralSelector.cpp b/Kernel/LiteralSelector.cpp index 38c96d11e..4ee7d56db 100644 --- a/Kernel/LiteralSelector.cpp +++ b/Kernel/LiteralSelector.cpp @@ -39,6 +39,7 @@ namespace Kernel { using namespace std; +using namespace Lib; /** * Return true if literal @b l is positive for the purpose of diff --git a/Kernel/LiteralSelector.hpp b/Kernel/LiteralSelector.hpp index 2871caa58..4b2c4d892 100644 --- a/Kernel/LiteralSelector.hpp +++ b/Kernel/LiteralSelector.hpp @@ -26,7 +26,6 @@ namespace Kernel { -using namespace Lib; using namespace Shell; /** diff --git a/Kernel/LookaheadLiteralSelector.hpp b/Kernel/LookaheadLiteralSelector.hpp index a8dc10f2a..2c7652a73 100644 --- a/Kernel/LookaheadLiteralSelector.hpp +++ b/Kernel/LookaheadLiteralSelector.hpp @@ -46,7 +46,7 @@ class LookaheadLiteralSelector private: Literal* pickTheBest(Literal** lits, unsigned cnt); void removeVariants(LiteralStack& lits); - VirtualIterator> getGeneraingInferenceIterator(Literal* lit); + Lib::VirtualIterator> getGeneraingInferenceIterator(Literal* lit); struct GenIteratorIterator; diff --git a/Kernel/MLMatcher.hpp b/Kernel/MLMatcher.hpp index aa272bbb1..4dde9757f 100644 --- a/Kernel/MLMatcher.hpp +++ b/Kernel/MLMatcher.hpp @@ -21,7 +21,6 @@ namespace Kernel { -using namespace Lib; struct MLMatchStats diff --git a/Kernel/MLMatcherSD.hpp b/Kernel/MLMatcherSD.hpp index 44857f871..29e60cada 100644 --- a/Kernel/MLMatcherSD.hpp +++ b/Kernel/MLMatcherSD.hpp @@ -16,7 +16,6 @@ namespace Kernel { -using namespace Lib; /** diff --git a/Kernel/MLVariant.hpp b/Kernel/MLVariant.hpp index bf2c4b0ba..a2fe6efb8 100644 --- a/Kernel/MLVariant.hpp +++ b/Kernel/MLVariant.hpp @@ -21,7 +21,6 @@ namespace Kernel { -using namespace Lib; class MLVariant { public: diff --git a/Kernel/MainLoop.cpp b/Kernel/MainLoop.cpp index 6ac0e5434..c7541149f 100644 --- a/Kernel/MainLoop.cpp +++ b/Kernel/MainLoop.cpp @@ -33,6 +33,7 @@ #include "MainLoop.hpp" using namespace Kernel; +using namespace Lib; using namespace Saturation; using namespace FMB; diff --git a/Kernel/MainLoop.hpp b/Kernel/MainLoop.hpp index 2f2683a2f..c57ec33df 100644 --- a/Kernel/MainLoop.hpp +++ b/Kernel/MainLoop.hpp @@ -30,7 +30,6 @@ namespace Shell { namespace Kernel { -using namespace Lib; using namespace Inferences; using namespace Shell; @@ -65,7 +64,7 @@ class MainLoop { * A struct that is thrown as an exception when a refutation is found * during the main loop. */ - struct RefutationFoundException : public ThrowableBase + struct RefutationFoundException : public Lib::ThrowableBase { RefutationFoundException(Clause* ref) : refutation(ref) { @@ -79,7 +78,7 @@ class MainLoop { * A struct that is thrown as an exception when a refutation is found * during the main loop. */ - struct MainLoopFinishedException : public ThrowableBase + struct MainLoopFinishedException : public Lib::ThrowableBase { MainLoopFinishedException(const MainLoopResult& res) : result(res) { diff --git a/Kernel/Matcher.cpp b/Kernel/Matcher.cpp index 93ecabb86..223fec82c 100644 --- a/Kernel/Matcher.cpp +++ b/Kernel/Matcher.cpp @@ -23,6 +23,7 @@ namespace Kernel { using namespace std; +using namespace Lib; namespace __MU_Aux { diff --git a/Kernel/Matcher.hpp b/Kernel/Matcher.hpp index 0c418ce56..a45e55e78 100644 --- a/Kernel/Matcher.hpp +++ b/Kernel/Matcher.hpp @@ -30,7 +30,6 @@ namespace Kernel { -using namespace Lib; class MatchingUtils { @@ -144,7 +143,7 @@ class MatchingUtils }; private: - typedef DHMap BindingMap; + typedef Lib::DHMap BindingMap; struct MapBinder { bool bind(unsigned var, TermList term) @@ -205,8 +204,8 @@ class OCMatchIterator { ASSERTION_VIOLATION; } - typedef DHMap BindingMap; - typedef Stack BoundStack; + typedef Lib::DHMap BindingMap; + typedef Lib::Stack BoundStack; BindingMap _bindings; BoundStack _bound; @@ -219,7 +218,7 @@ class OCMatchIterator }; class Matcher -: public Backtrackable +: public Lib::Backtrackable { public: Matcher() : _binder(*this) {} @@ -235,7 +234,7 @@ class Matcher bool matchReversedArgs(Literal* base, Literal* instance); - typedef DHMap BindingMap; + typedef Lib::DHMap BindingMap; struct MapBinder { MapBinder(Matcher& parent) : _parent(parent) {} @@ -258,7 +257,7 @@ class Matcher Matcher& _parent; class BindingBacktrackObject - : public BacktrackObject + : public Lib::BacktrackObject { public: BindingBacktrackObject(MapBinder* bnd, unsigned var) @@ -325,7 +324,7 @@ bool MatchingUtils::matchArgs(Term* base, Term* instance, Binder& binder) TermList* bt=base->args(); TermList* it=instance->args(); - static Stack subterms(32); + static Lib::Stack subterms(32); subterms.reset(); for (;;) { diff --git a/Kernel/NumTraits.hpp b/Kernel/NumTraits.hpp index 4554ab830..e6a507ba5 100644 --- a/Kernel/NumTraits.hpp +++ b/Kernel/NumTraits.hpp @@ -90,7 +90,7 @@ struct NumTraits; static constexpr Theory::Interpretation name ## I = Theory::SORT_SHORT ## _INTERPRETATION; \ \ static unsigned name ## F() { \ - static const unsigned functor = env.signature->getInterpretingSymbol(name ## I); \ + static const unsigned functor = Lib::env.signature->getInterpretingSymbol(name ## I); \ return functor; \ } \ @@ -169,15 +169,15 @@ struct NumTraits; static Term* constantT(int i) { return constantT(constant(i)); } \ static Term* constantT(ConstantType i) { return theory->representConstant(i); } \ static TermList constantTl(int i) { return TermList(constantT(i)); } \ - static Option tryNumeral(TermList t) { \ + static Lib::Option tryNumeral(TermList t) { \ ConstantType out; \ if (theory->tryInterpretConstant(t,out)) { \ - return Option(out); \ + return Lib::Option(out); \ } else { \ - return Option(); \ + return Lib::Option(); \ } \ } \ - static Option tryNumeral(Term* t) { return tryNumeral(TermList(t)); } \ + static Lib::Option tryNumeral(Term* t) { return tryNumeral(TermList(t)); } \ \ static const char* name() {return #CamelCase;} \ }; \ diff --git a/Kernel/OperatorType.hpp b/Kernel/OperatorType.hpp index 64306d500..2ca43a6c1 100644 --- a/Kernel/OperatorType.hpp +++ b/Kernel/OperatorType.hpp @@ -41,7 +41,7 @@ namespace Kernel { * * https://link.springer.com/chapter/10.1007/978-3-030-51054-1_21 * - * The class stores data in a Vector*, of length + * The class stores data in a Lib::Vector*, of length * num_of_arg_sorts + 1. The number of bound variables is stored in * a field _typeArgsArity. It is assumed that the bound variables range from * 0 to _typeArgsArity - 1. In order for this assumption to be valid all sorts must @@ -63,15 +63,15 @@ class OperatorType { OperatorKey& key = *ot->key(); unsigned typeArgsArity = ot->numTypeArguments(); - return HashUtils::combine( - DefaultHash::hash(key), - DefaultHash::hash(typeArgsArity) + return Lib::HashUtils::combine( + Lib::DefaultHash::hash(key), + Lib::DefaultHash::hash(typeArgsArity) ); } }; private: - typedef Vector OperatorKey; // Vector of argument sorts together with "0" appended for predicates and resultSort appended for functions + typedef Lib::Vector OperatorKey; // Vector of argument sorts together with "0" appended for predicates and resultSort appended for functions OperatorKey* _key; unsigned _typeArgsArity; /** number of quantified variables of this type */ @@ -85,7 +85,7 @@ class OperatorType static OperatorKey* setupKey(std::initializer_list sorts); static OperatorKey* setupKeyUniformRange(unsigned arity, TermList argsSort); - typedef Set OperatorTypes; + typedef Lib::Set OperatorTypes; static OperatorTypes& operatorTypes(); // just a wrapper around a static OperatorTypes object, to ensure a correct initialization order static OperatorType* getTypeFromKey(OperatorKey* key, unsigned taArity); diff --git a/Kernel/Ordering.hpp b/Kernel/Ordering.hpp index 9440e2a0a..55742e1ee 100644 --- a/Kernel/Ordering.hpp +++ b/Kernel/Ordering.hpp @@ -96,8 +96,8 @@ class Ordering void removeNonMaximal(LiteralList*& lits) const; - static Result fromComparison(Comparison c); - static Comparison intoComparison(Result c); + static Result fromComparison(Lib::Comparison c); + static Lib::Comparison intoComparison(Result c); static Result reverse(Result r) { @@ -159,16 +159,16 @@ class PrecedenceOrdering // l1 and l2 are not equalities and have the same predicate virtual Result comparePredicates(Literal* l1,Literal* l2) const = 0; - PrecedenceOrdering(const DArray& funcPrec, const DArray& typeConPrec, - const DArray& predPrec, const DArray& predLevels, bool reverseLCM); - PrecedenceOrdering(Problem& prb, const Options& opt, const DArray& predPrec); + PrecedenceOrdering(const Lib::DArray& funcPrec, const Lib::DArray& typeConPrec, + const Lib::DArray& predPrec, const Lib::DArray& predLevels, bool reverseLCM); + PrecedenceOrdering(Problem& prb, const Options& opt, const Lib::DArray& predPrec); PrecedenceOrdering(Problem& prb, const Options& opt); - static DArray typeConPrecFromOpts(Problem& prb, const Options& opt); - static DArray funcPrecFromOpts(Problem& prb, const Options& opt); - static DArray predPrecFromOpts(Problem& prb, const Options& opt); - static DArray predLevelsFromOptsAndPrec(Problem& prb, const Options& opt, const DArray& predicatePrecedences); + static Lib::DArray typeConPrecFromOpts(Problem& prb, const Options& opt); + static Lib::DArray funcPrecFromOpts(Problem& prb, const Options& opt); + static Lib::DArray predPrecFromOpts(Problem& prb, const Options& opt); + static Lib::DArray predLevelsFromOptsAndPrec(Problem& prb, const Options& opt, const Lib::DArray& predicatePrecedences); Result compareFunctionPrecedences(unsigned fun1, unsigned fun2) const; Result compareTypeConPrecedences(unsigned tyc1, unsigned tyc2) const; @@ -181,13 +181,13 @@ class PrecedenceOrdering /** number of functions in the signature at the time the order was created */ unsigned _functions; /** Array of predicate levels */ - DArray _predicateLevels; + Lib::DArray _predicateLevels; /** Array of predicate precedences */ - DArray _predicatePrecedences; + Lib::DArray _predicatePrecedences; /** Array of function precedences */ - DArray _functionPrecedences; + Lib::DArray _functionPrecedences; /** Array of type con precedences */ - DArray _typeConPrecedences; + Lib::DArray _typeConPrecedences; bool _reverseLCM; }; diff --git a/Kernel/Polynomial.cpp b/Kernel/Polynomial.cpp index 48d2fb3b5..46df372cf 100644 --- a/Kernel/Polynomial.cpp +++ b/Kernel/Polynomial.cpp @@ -16,6 +16,8 @@ namespace Kernel { +using namespace Lib; + PolyNf PolyNf::normalize(TypedTermList t) { return normalizeTerm(t); } diff --git a/Kernel/Polynomial.hpp b/Kernel/Polynomial.hpp index 144c6cd31..8d8d29ddf 100644 --- a/Kernel/Polynomial.hpp +++ b/Kernel/Polynomial.hpp @@ -93,10 +93,10 @@ class FuncId unsigned id() const; Theory::Interpretation interpretation() const; bool isInterpreted() const; - Option tryInterpret() const; + Lib::Option tryInterpret() const; template - Option tryNumeral() const; + Lib::Option tryNumeral() const; }; } // namespace Kernel @@ -137,13 +137,13 @@ struct Monom using Numeral = typename Number::ConstantType; Numeral numeral; - Perfect> factors; + Lib::Perfect> factors; - Monom(Numeral numeral, Perfect> factors); + Monom(Numeral numeral, Lib::Perfect> factors); static Monom zero(); - Option tryVar() const; + Lib::Option tryVar() const; /** performs an integrity check on the datastructure, only has an effect in debug mode */ void integrity() const; @@ -156,11 +156,11 @@ struct Monom class FuncTerm { FuncId _fun; - Stack _args; + Lib::Stack _args; public: USE_ALLOCATOR(FuncTerm) - FuncTerm(FuncId f, Stack&& args); + FuncTerm(FuncId f, Lib::Stack&& args); FuncTerm(FuncId f, PolyNf* args); unsigned numTermArguments() const; @@ -168,7 +168,7 @@ class FuncTerm PolyNf const& arg(unsigned i) const; template - Option tryNumeral() const; + Lib::Option tryNumeral() const; friend std::ostream& operator<<(std::ostream& out, const FuncTerm& self); friend bool operator==(FuncTerm const& lhs, FuncTerm const& rhs); @@ -176,27 +176,27 @@ class FuncTerm friend struct std::hash; }; -using AnyPolySuper = Coproduct< - Perfect> - , Perfect> - , Perfect> +using AnyPolySuper = Lib::Coproduct< + Lib::Perfect> + , Lib::Perfect> + , Lib::Perfect> >; class AnyPoly : public AnyPolySuper { public: /** creates a new dynamically typed polynom from a statically typed one */ - template AnyPoly(Perfect> x); + template AnyPoly(Lib::Perfect> x); /** tries to turn this polynom into a polynom of the given NumTraits. */ - template Option> const&> downcast() const&; + template Lib::Option> const&> downcast() const&; /** returns wether this is a Polynom of the given NumTraits. */ template bool isType() const; /** if this polynom has the right sort, and consist of a single summand that is a numeral, then this numeral * is returned. otherwise an empty Option is returned. */ - template Option tryNumeral() const&; + template Lib::Option tryNumeral() const&; /** \see template Polynom::replaceTerms */ AnyPoly replaceTerms(PolyNf* newTs) const; @@ -217,7 +217,7 @@ class AnyPoly : public AnyPolySuper friend struct std::hash; }; -using PolyNfSuper = Lib::Coproduct, Variable, AnyPoly>; +using PolyNfSuper = Lib::Coproduct, Variable, AnyPoly>; /** * Represents the polynomial normal form of a term, that is used for performing several simplifications and evaluations. @@ -228,7 +228,7 @@ class PolyNf : public PolyNfSuper { public: - PolyNf(Perfect t); + PolyNf(Lib::Perfect t); PolyNf(Variable t); PolyNf(AnyPoly t); @@ -239,7 +239,7 @@ class PolyNf : public PolyNfSuper * otherwise an empty Option is returned */ template - Option>> downcast() const; + Lib::Option>> downcast() const; /** turns the normal form term PolyNf into an ordenary vampire term TermList. */ TermList denormalize() const; @@ -252,21 +252,21 @@ class PolyNf : public PolyNfSuper * wrapped in a polynom. */ template - Perfect> wrapPoly() const; + Lib::Perfect> wrapPoly() const; /** if this PolyNf is a numeral, the numeral is returned */ template - Option tryNumeral() const; + Lib::Option tryNumeral() const; /** if this PolyNf is a Variable, the variable is returned */ - Option tryVar() const; + Lib::Option tryVar() const; /** an iterator over all PolyNf s that are subterms of this one */ class SubtermIter; /** returns an iterator over all PolyNf s that are subterms of this one */ - IterTraits iterSubterms() const; + Lib::IterTraits iterSubterms() const; friend struct std::hash; friend bool operator==(PolyNf const& lhs, PolyNf const& rhs); @@ -293,7 +293,7 @@ struct MonomFactor MonomFactor(PolyNf term, int power); /** if this monomfactor is a Variable and has power one it is turned into a variable */ - Option tryVar() const; + Lib::Option tryVar() const; }; @@ -308,7 +308,7 @@ class MonomFactors using Monom = Kernel::Monom; using Polynom = Kernel::Polynom; using Numeral = typename Number::ConstantType; - Stack _factors; + Lib::Stack _factors; friend struct std::hash; public: @@ -318,7 +318,7 @@ class MonomFactors * constructs a new MonomFactors. * \pre factors must be sorted */ - MonomFactors(Stack&& factors); + MonomFactors(Lib::Stack&& factors); /** constructs an empty product, which corresponds to the numeral one. */ MonomFactors(); @@ -347,7 +347,7 @@ class MonomFactors /** turns this monom into a polynom. * \pre isPolynom must be true */ - Perfect asPolynom() const; + Lib::Perfect asPolynom() const; /** returns the (empty) product one */ static MonomFactors one(); @@ -357,7 +357,7 @@ class MonomFactors /** if this MonomFactors consist of a single variable if will be returnd */ - Option tryVar() const; + Lib::Option tryVar() const; /** performs an integrity check on the datastructure, only has an effect in debug mode */ void integrity() const; @@ -368,7 +368,7 @@ class MonomFactors /** returns an iterator over all factors */ auto iter() const& - { return arrayIter(_factors); } + { return Lib::arrayIter(_factors); } explicit MonomFactors(const MonomFactors&) = default; explicit MonomFactors(MonomFactors&) = default; @@ -382,7 +382,7 @@ class MonomFactors /** helper function for PolyNf::denormalize() */ TermList denormalize(TermList* results) const; - Stack& raw(); + Lib::Stack& raw(); }; template @@ -394,7 +394,7 @@ class Polynom using MonomFactors = Kernel::MonomFactors; using Monom = Kernel::Monom; - Stack _summands; + Lib::Stack _summands; public: USE_ALLOCATOR(Polynom) @@ -403,7 +403,7 @@ class Polynom * constructs a new Polynom with a list of summands * \pre summands must be sorted */ - explicit Polynom(Stack&& summands); + explicit Polynom(Lib::Stack&& summands); /** creates a Polynom that consists of only one summand */ explicit Polynom(Monom m); @@ -421,7 +421,7 @@ class Polynom static Polynom zero(); /** if this Polynom consists only of one summand that is a numeral the numeral is returned */ - Option toNumber() const&; + Lib::Option toNumber() const&; /** turns this Polynom into a numeral if it consists only of one summand that is a numeral, or throws an assertion violation * \pre isNumeral is true* @@ -463,9 +463,9 @@ class Polynom /** returns iterator over all summands of this Polyom */ auto iterSummands() const& - { return arrayIter(_summands); } + { return Lib::arrayIter(_summands); } - Stack& raw(); + Lib::Stack& raw(); template friend bool operator==(const Polynom& lhs, const Polynom& rhs); template friend std::ostream& operator<<(std::ostream& out, const Polynom& self); @@ -487,7 +487,7 @@ class IterArgsPnf }; /** convienent constructor for IterArgsPnf */ -IterTraits iterArgsPnf(Literal* lit); +Lib::IterTraits iterArgsPnf(Literal* lit); } // namespace Kernel @@ -497,7 +497,7 @@ IterTraits iterArgsPnf(Literal* lit); namespace Kernel { class PolyNf::SubtermIter { - Stack> _stack; + Lib::Stack> _stack; public: DECL_ELEMENT_TYPE(PolyNf); @@ -525,21 +525,21 @@ class PolyNf::SubtermIter { namespace Kernel { template -Monom::Monom(Monom::Numeral numeral, Perfect> factors) +Monom::Monom(Monom::Numeral numeral, Lib::Perfect> factors) : numeral(numeral), factors(factors) {} template Monom Monom::zero() { - static Monom p = Monom(Numeral(0), perfect(MonomFactors())); + static Monom p = Monom(Numeral(0), Lib::perfect(MonomFactors())); return p; } template -Option Monom::tryVar() const +Lib::Option Monom::tryVar() const { - using Opt = Option; + using Opt = Lib::Option; if (numeral == Numeral(1)) { return factors->tryVar(); } else { @@ -590,14 +590,14 @@ std::ostream& operator<<(std::ostream& out, const Monom& self) namespace Kernel { template -Option FuncId::tryNumeral() const +Lib::Option FuncId::tryNumeral() const { using Numeral = typename Number::ConstantType; Numeral out; if (theory->tryInterpretConstant(_num, out)) { - return Option(out); + return Lib::Option(out); } else { - return Option(); + return Lib::Option(); } } @@ -612,7 +612,7 @@ Option FuncId::tryNumeral() const namespace Kernel { template -Option FuncTerm::tryNumeral() const +Lib::Option FuncTerm::tryNumeral() const { return _fun.template tryNumeral(); } } // namespace Kernel @@ -621,7 +621,7 @@ Option FuncTerm::tryNumeral() const template<> struct std::hash { size_t operator()(Kernel::FuncTerm const& f) const - { return Lib::HashUtils::combine(std::hash{}(f._fun), std::hash>{}(f._args)); } + { return Lib::HashUtils::combine(std::hash{}(f._fun), std::hash>{}(f._args)); } }; ///////////////////////////////////////////////////////// @@ -631,29 +631,29 @@ template<> struct std::hash namespace Kernel { template -AnyPoly::AnyPoly(Perfect> x) : Coproduct(std::move(x)) { } +AnyPoly::AnyPoly(Lib::Perfect> x) : Coproduct(std::move(x)) { } template -Option> const&> AnyPoly::downcast() const& -{ return as>>(); } +Lib::Option> const&> AnyPoly::downcast() const& +{ return as>>(); } template bool AnyPoly::isType() const -{ return is>>(); } +{ return is>>(); } /* helper function for AnyPoly::tryNumeral */ template struct __ToNumeralHelper { - Option operator()(Perfect>) const - { return Option(); } + Lib::Option operator()(Lib::Perfect>) const + { return Lib::Option(); } }; /* helper function for AnyPoly::tryNumeral */ template struct __ToNumeralHelper { - Option operator()(Perfect> p) const + Lib::Option operator()(Lib::Perfect> p) const { return p->toNumber(); } }; @@ -661,13 +661,13 @@ template struct PolymorphicToNumeral { template - Option operator()(Perfect> const& p) const + Lib::Option operator()(Lib::Perfect> const& p) const { return __ToNumeralHelper{}(p); } }; template -Option AnyPoly::tryNumeral() const& +Lib::Option AnyPoly::tryNumeral() const& { return apply(PolymorphicToNumeral{}); } } // namespace Kernel @@ -688,9 +688,9 @@ namespace Kernel { template -Option>> PolyNf::downcast() const +Lib::Option>> PolyNf::downcast() const { - using Result = Perfect>; + using Result = Lib::Perfect>; return as() .andThen([](AnyPoly const& p) { return p.as(); }) .map([](Result const& p) -> Result { return p; }); @@ -698,23 +698,23 @@ Option>> PolyNf::downcast() const template -Perfect> PolyNf::wrapPoly() const +Lib::Perfect> PolyNf::wrapPoly() const { if (this->is()) { return this->unwrap() - .unwrap>>(); + .unwrap>>(); } else { - return perfect(Polynom(*this)); + return Lib::perfect(Polynom(*this)); } } template -Option PolyNf::tryNumeral() const +Lib::Option PolyNf::tryNumeral() const { using Numeral = typename Number::ConstantType; return match( - [](Perfect t) { return (*t).tryNumeral(); }, - [](Variable t) { return Option(); }, + [](Lib::Perfect t) { return (*t).tryNumeral(); }, + [](Variable t) { return Lib::Option(); }, [](AnyPoly t) { return t.template tryNumeral(); } ); } @@ -760,8 +760,8 @@ std::ostream& operator<<(std::ostream& out, const MonomFactor& self) { } template -Option MonomFactor::tryVar() const -{ return power == 1 ? term.tryVar() : none(); } +Lib::Option MonomFactor::tryVar() const +{ return power == 1 ? term.tryVar() : Lib::none(); } } // namespace Kernel @@ -770,7 +770,8 @@ struct std::hash> { size_t operator()(Kernel::MonomFactor const& x) const noexcept { - return HashUtils::combine( + using namespace Lib; + return Lib::HashUtils::combine( StlHash::hash(x.term), StlHash::hash(x.power) ); @@ -785,7 +786,7 @@ struct std::hash> namespace Kernel { template -MonomFactors::MonomFactors(Stack&& factors) +MonomFactors::MonomFactors(Lib::Stack&& factors) : _factors(std::move(factors)) { } template @@ -820,7 +821,7 @@ PolyNf const& MonomFactors::termAt(unsigned i) const { return _factors[i].term; } template -Stack> & MonomFactors::raw() +Lib::Stack> & MonomFactors::raw() { return _factors; } template @@ -830,12 +831,12 @@ bool MonomFactors::isPolynom() const && _factors[0].term.template is(); } template -Perfect> MonomFactors::asPolynom() const +Lib::Perfect> MonomFactors::asPolynom() const { ASS(isPolynom()); return _factors[0].term .template unwrap() - .template unwrap>(); + .template unwrap>(); } template @@ -897,9 +898,9 @@ TermList MonomFactors::denormalize(TermList* results) const } template -Option MonomFactors::tryVar() const +Lib::Option MonomFactors::tryVar() const { - using Opt = Option; + using Opt = Lib::Option; if (nFactors() == 1 ) { return _factors[0].tryVar(); @@ -944,6 +945,7 @@ struct std::hash> { size_t operator()(Kernel::MonomFactors const& x) const noexcept { + using namespace Lib; return StackHash::hash(x._factors); } }; @@ -957,22 +959,22 @@ namespace Kernel { template -Polynom::Polynom(Stack&& summands) +Polynom::Polynom(Lib::Stack&& summands) : _summands( summands.isEmpty() - ? Stack{Monom::zero()} + ? Lib::Stack{Monom::zero()} : std::move(summands)) { } template Polynom::Polynom(Monom m) : Polynom( - Stack{m}) + Lib::Stack{m}) { } template Polynom::Polynom(Numeral numeral, PolyNf term) - : Polynom(Monom(numeral, perfect(MonomFactors(term)))) + : Polynom(Monom(numeral, Lib::perfect(MonomFactors(term)))) { } template @@ -982,7 +984,7 @@ Polynom::Polynom(PolyNf t) template Polynom::Polynom(Numeral constant) - : Polynom(Monom(constant, perfect(MonomFactors::one()))) + : Polynom(Monom(constant, Lib::perfect(MonomFactors::one()))) { } @@ -1012,22 +1014,22 @@ std::ostream& operator<<(std::ostream& out, const Polynom& self) { template Polynom Polynom::zero() { - auto out = Polynom(Stack{Monom::zero()}); + auto out = Polynom(Lib::Stack{Monom::zero()}); out.integrity(); return std::move(out); } template -Option Polynom::toNumber() const& +Lib::Option Polynom::toNumber() const& { if ( _summands.size() == 0) { - return Option(Numeral(0)); + return Lib::Option(Numeral(0)); } else if (_summands.size() == 1 && _summands[0].factors->nFactors() == 0) { - return Option(_summands[0].numeral); + return Lib::Option(_summands[0].numeral); } else { - return Option(); + return Lib::Option(); } } @@ -1077,20 +1079,20 @@ TermList Polynom::denormalize(TermList* results) const } template -Stack>& Polynom::raw() +Lib::Stack>& Polynom::raw() { return _summands; } template Polynom Polynom::replaceTerms(PolyNf* simplifiedTerms) const { int offs = 0; - Stack out; + Lib::Stack out; out.reserve(nSummands()); for (auto& monom : _summands) { out.push(Monom( monom.numeral, - perfect(monom.factors->replaceTerms(&simplifiedTerms[offs])))); + Lib::perfect(monom.factors->replaceTerms(&simplifiedTerms[offs])))); offs += monom.factors->nFactors(); } return Polynom(std::move(out)); @@ -1121,7 +1123,7 @@ void Polynom::integrity() const { auto iter = this->_summands.begin(); auto last = iter++; while (iter != _summands.end()) { - // ASS_REP(std::less>{}(last->factors, iter->factors), *this); + // ASS_REP(std::less>{}(last->factors, iter->factors), *this); ASS_REP(last->factors <= iter->factors, *this); iter->integrity(); last = iter++; @@ -1133,7 +1135,7 @@ void Polynom::integrity() const { template TermList Polynom::denormalize() const -{ return PolyNf(AnyPoly(perfect(Polynom(*this)))).denormalize(); } +{ return PolyNf(AnyPoly(Lib::perfect(Polynom(*this)))).denormalize(); } } // namespace Kernel @@ -1142,12 +1144,12 @@ struct std::hash> { size_t operator()(Kernel::Polynom const& x) const noexcept { - using namespace Lib; using namespace Kernel; + using namespace Lib; - unsigned out = HashUtils::combine(0,0); + unsigned out = Lib::HashUtils::combine(0,0); for (auto c : x._summands) { - out = HashUtils::combine( + out = Lib::HashUtils::combine( StlHash::hash(c.factors), StlHash::hash(c.numeral), out diff --git a/Kernel/PolynomialNormalizer.cpp b/Kernel/PolynomialNormalizer.cpp index 35c3efa86..c15eca0d6 100644 --- a/Kernel/PolynomialNormalizer.cpp +++ b/Kernel/PolynomialNormalizer.cpp @@ -16,6 +16,7 @@ namespace Kernel { using namespace std; +using namespace Lib; /** a struct that normalizes an object of type MonomFactors to a Monom */ struct RenderMonom { diff --git a/Kernel/PolynomialNormalizer.hpp b/Kernel/PolynomialNormalizer.hpp index 71802d54d..878b0f032 100644 --- a/Kernel/PolynomialNormalizer.hpp +++ b/Kernel/PolynomialNormalizer.hpp @@ -37,7 +37,7 @@ namespace Kernel { using LitSimplResult = Inferences::SimplifyingGeneratingLiteralSimplification::Result; -using NormalizationResult = Coproduct , Polynom< RatTraits> , Polynom diff --git a/Kernel/PolynomialNormalizer/PredicateEvaluator.hpp b/Kernel/PolynomialNormalizer/PredicateEvaluator.hpp index 6e5ddc6cc..75c824e16 100644 --- a/Kernel/PolynomialNormalizer/PredicateEvaluator.hpp +++ b/Kernel/PolynomialNormalizer/PredicateEvaluator.hpp @@ -20,7 +20,7 @@ using LitSimplResult = Inferences::SimplifyingGeneratingLiteralSimplification::R #define IMPL_EVALUATE_PRED(interpretation, ...) \ template<> \ struct PredicateEvaluator { \ - static Option evaluate(Literal* orig, PolyNf* evaluatedArgs) \ + static Lib::Option evaluate(Literal* orig, PolyNf* evaluatedArgs) \ { \ __VA_ARGS__ \ } \ @@ -32,15 +32,15 @@ using LitSimplResult = Inferences::SimplifyingGeneratingLiteralSimplification::R /////////////////////////////////////////////////////////////////////////////////////////////////////////////// template -Option tryEvalConstant2(Literal* orig, PolyNf* evaluatedArgs, EvalGround fun) +Lib::Option tryEvalConstant2(Literal* orig, PolyNf* evaluatedArgs, EvalGround fun) { using Number = NumTraits; auto& lhs = *evaluatedArgs[0].downcast().unwrap(); auto& rhs = *evaluatedArgs[1].downcast().unwrap(); if (lhs.isNumber() && rhs.isNumber()) { - return Option(LitSimplResult::constant(fun(lhs.unwrapNumber(), rhs.unwrapNumber()))); + return Lib::Option(LitSimplResult::constant(fun(lhs.unwrapNumber(), rhs.unwrapNumber()))); } else { - return Option(); + return Lib::Option(); } } @@ -48,13 +48,13 @@ Option tryEvalConstant2(Literal* orig, PolyNf* evaluatedArgs, Ev /// Equality ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -template inline Option interpretEquality(bool polarity, Perfect> lhs, Perfect> rhs) { +template inline Lib::Option interpretEquality(bool polarity, Lib::Perfect> lhs, Lib::Perfect> rhs) { if (lhs->isNumber() && rhs->isNumber()) { - return Option(LitSimplResult::constant(polarity == (lhs->unwrapNumber() == rhs->unwrapNumber()))); + return Lib::Option(LitSimplResult::constant(polarity == (lhs->unwrapNumber() == rhs->unwrapNumber()))); } else if (lhs == rhs) { - return Option(LitSimplResult::constant(polarity)); + return Lib::Option(LitSimplResult::constant(polarity)); } else { - return Option(); + return Lib::Option(); } } @@ -70,7 +70,7 @@ IMPL_EVALUATE_PRED(Interpretation::EQUAL, auto sort = SortHelper::getEqualityArgumentSort(orig); if (lhs == rhs) { - return Option(LitSimplResult::constant(polarity)); + return Lib::Option(LitSimplResult::constant(polarity)); } if (sort == IntTraits::sort()) return interpretEquality(polarity, lhs.template wrapPoly(), rhs.template wrapPoly()); @@ -79,14 +79,14 @@ IMPL_EVALUATE_PRED(Interpretation::EQUAL, if (sort == RealTraits::sort()) return interpretEquality(polarity, lhs.template wrapPoly(), rhs.template wrapPoly()); else - return Option(); + return Lib::Option(); ) /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Inequalities /////////////////////////////////////////////////////////////////////////////////////////////////////////////// -template Option evaluateInequality(Literal* orig, PolyNf* evaluatedArgs, bool strict, EvalIneq evalIneq) { +template Lib::Option evaluateInequality(Literal* orig, PolyNf* evaluatedArgs, bool strict, EvalIneq evalIneq) { ASS(orig->numTermArguments() == 2); @@ -95,11 +95,11 @@ template Option evaluateIneq auto polarity = orig->polarity(); if (lhs->isNumber() && rhs->isNumber()) { - return Option(LitSimplResult::constant(polarity == evalIneq(lhs->unwrapNumber(), rhs->unwrapNumber()))); + return Lib::Option(LitSimplResult::constant(polarity == evalIneq(lhs->unwrapNumber(), rhs->unwrapNumber()))); } else if (lhs == rhs) { - return Option(LitSimplResult::constant(polarity != strict)); + return Lib::Option(LitSimplResult::constant(polarity != strict)); } else { - return Option(); + return Lib::Option(); } } diff --git a/Kernel/Problem.cpp b/Kernel/Problem.cpp index 2cdb10626..e52ec1038 100644 --- a/Kernel/Problem.cpp +++ b/Kernel/Problem.cpp @@ -31,6 +31,7 @@ #undef LOGGING #define LOGGING 0 +using namespace Lib; using namespace Kernel; /** diff --git a/Kernel/Problem.hpp b/Kernel/Problem.hpp index a8239aa2e..8b12c7aaa 100644 --- a/Kernel/Problem.hpp +++ b/Kernel/Problem.hpp @@ -25,7 +25,6 @@ namespace Kernel { -using namespace Lib; using namespace Shell; /** @@ -67,7 +66,7 @@ class Problem { bool hadIncompleteTransformation() const { return _hadIncompleteTransformation; } void reportIncompleteTransformation() { _hadIncompleteTransformation = true; } - typedef DHMap TrivialPredicateMap; + typedef Lib::DHMap TrivialPredicateMap; void addTrivialPredicate(unsigned pred, bool assignment); /** * Return map of trivial predicates into their assignments. @@ -81,9 +80,9 @@ class Problem { void addEliminatedPredicate(unsigned pred, Unit* definition); void addPartiallyEliminatedPredicate(unsigned pred, Unit* definition); - DHMap getEliminatedFunctions(){ return _deletedFunctions; } - DHMap getEliminatedPredicates(){ return _deletedPredicates; } - DHMap getPartiallyEliminatedPredicates(){ return _partiallyDeletedPredicates;} + Lib::DHMap getEliminatedFunctions(){ return _deletedFunctions; } + Lib::DHMap getEliminatedPredicates(){ return _deletedPredicates; } + Lib::DHMap getPartiallyEliminatedPredicates(){ return _partiallyDeletedPredicates;} FunctionDefinitionHandler& getFunctionDefinitionHandler(){ return *_fnDefHandler; } @@ -189,14 +188,14 @@ class Problem { void readDetailsFromProperty() const; UnitList* _units; - DHMap _deletedFunctions; - DHMap _deletedPredicates; - DHMap _partiallyDeletedPredicates; - ScopedPtr _fnDefHandler; + Lib::DHMap _deletedFunctions; + Lib::DHMap _deletedPredicates; + Lib::DHMap _partiallyDeletedPredicates; + Lib::ScopedPtr _fnDefHandler; bool _hadIncompleteTransformation; - DHMap _trivialPredicates; + Lib::DHMap _trivialPredicates; mutable bool _mayHaveEquality; mutable bool _mayHaveFormulas; @@ -204,20 +203,20 @@ class Problem { mutable bool _mayHaveInequalityResolvableWithDeletion; mutable bool _mayHaveXEqualsY; - mutable MaybeBool _hasFormulas; - mutable MaybeBool _hasEquality; - mutable MaybeBool _hasInterpretedOperations; - mutable MaybeBool _hasNumerals; - mutable MaybeBool _hasFOOL; - mutable MaybeBool _hasCombs; - mutable MaybeBool _hasApp; - mutable MaybeBool _hasAppliedVar; - mutable MaybeBool _hasLogicalProxy; - mutable MaybeBool _hasPolymorphicSym; - mutable MaybeBool _quantifiesOverPolymorphicVar; - mutable MaybeBool _hasBoolVar; - mutable MaybeBool _higherOrder; - mutable MaybeBool _hasNonDefaultSorts; + mutable Lib::MaybeBool _hasFormulas; + mutable Lib::MaybeBool _hasEquality; + mutable Lib::MaybeBool _hasInterpretedOperations; + mutable Lib::MaybeBool _hasNumerals; + mutable Lib::MaybeBool _hasFOOL; + mutable Lib::MaybeBool _hasCombs; + mutable Lib::MaybeBool _hasApp; + mutable Lib::MaybeBool _hasAppliedVar; + mutable Lib::MaybeBool _hasLogicalProxy; + mutable Lib::MaybeBool _hasPolymorphicSym; + mutable Lib::MaybeBool _quantifiesOverPolymorphicVar; + mutable Lib::MaybeBool _hasBoolVar; + mutable Lib::MaybeBool _higherOrder; + mutable Lib::MaybeBool _hasNonDefaultSorts; SMTLIBLogic _smtlibLogic; diff --git a/Kernel/RCClauseStack.hpp b/Kernel/RCClauseStack.hpp index 719052511..0385f1a76 100644 --- a/Kernel/RCClauseStack.hpp +++ b/Kernel/RCClauseStack.hpp @@ -23,7 +23,6 @@ namespace Kernel { -using namespace Lib; /** * A clause stack that enforces reference counting on inserted clauses diff --git a/Kernel/Rebalancing.hpp b/Kernel/Rebalancing.hpp index a323e6360..ca8514013 100644 --- a/Kernel/Rebalancing.hpp +++ b/Kernel/Rebalancing.hpp @@ -78,7 +78,7 @@ namespace Kernel { template class BalanceIter { /* "call-stack". top of the stack is the term that is currently being traversed. */ - Stack _path; + Lib::Stack _path; /* index of the side of the equality that is to be investigated next. i.e.: */ unsigned _litIndex; @@ -129,7 +129,7 @@ template Balancer::Balancer(const Literal& l) : _lit(l) { } template BalanceIter::BalanceIter(const Balancer& balancer, bool end) - : _path(Stack()) + : _path(Lib::Stack()) , _litIndex(end ? 2 : 0) , _balancer(balancer) { diff --git a/Kernel/Renaming.hpp b/Kernel/Renaming.hpp index 95e606821..1181bffba 100644 --- a/Kernel/Renaming.hpp +++ b/Kernel/Renaming.hpp @@ -25,7 +25,6 @@ namespace Kernel { -using namespace Lib; class Renaming { public: @@ -100,13 +99,13 @@ class Renaming { Renaming* _parent; }; - typedef DHMap VariableMap; + typedef Lib::DHMap VariableMap; VariableMap _data; unsigned _nextVar; bool _identity; public: typedef VariableMap::Item Item; - VirtualIterator items() const { return _data.items(); } + Lib::VirtualIterator items() const { return _data.items(); } }; diff --git a/Kernel/RobSubstitution.hpp b/Kernel/RobSubstitution.hpp index 4a8cfad34..7f5595ac6 100644 --- a/Kernel/RobSubstitution.hpp +++ b/Kernel/RobSubstitution.hpp @@ -55,8 +55,8 @@ struct VarSpec auto asTuple() const { return std::tie(var, index); } IMPL_COMPARISONS_FROM_TUPLE(VarSpec) - unsigned defaultHash () const { return HashUtils::combine(var , index); } - unsigned defaultHash2() const { return HashUtils::combine(index, var ); } + unsigned defaultHash () const { return Lib::HashUtils::combine(var , index); } + unsigned defaultHash2() const { return Lib::HashUtils::combine(index, var ); } }; struct TermSpec { @@ -107,9 +107,9 @@ struct TermSpec { TermSpec typeArg(unsigned i) const { return TermSpec(this->term.term()->typeArg(i), this->index); } TermSpec anyArg (unsigned i) const { return TermSpec(*this->term.term()->nthArgument(i), this->index); } - auto typeArgs() const { return range(0, nTypeArgs()).map([this](auto i) { return typeArg(i); }); } - auto termArgs() const { return range(0, nTermArgs()).map([this](auto i) { return termArg(i); }); } - auto allArgs() const { return range(0, nAllArgs()).map([this](auto i) { return anyArg(i); }); } + auto typeArgs() const { return Lib::range(0, nTypeArgs()).map([this](auto i) { return typeArg(i); }); } + auto termArgs() const { return Lib::range(0, nTermArgs()).map([this](auto i) { return termArg(i); }); } + auto allArgs() const { return Lib::range(0, nAllArgs()).map([this](auto i) { return anyArg(i); }); } bool deepEqCheck(const TermSpec& t2) const { TermSpec const& t1 = *this; @@ -139,7 +139,7 @@ struct TermSpec { bool sortIsBoolOrVar() const { if (!isTerm()) return false; - auto fun = env.signature->getFunction(functor()); + auto fun = Lib::env.signature->getFunction(functor()); auto op = fun->fnType(); TermList res = op->result(); return res.isVar() || res == AtomicSort::boolSort(); @@ -160,7 +160,7 @@ struct TermSpec { template static int compare(TermSpec const& lhs, TermSpec const& rhs, Deref deref) { - Recycled>> todo; + Lib::Recycled>> todo; todo->push(std::make_pair(lhs,rhs)); while (todo->isNonEmpty()) { auto lhs_ = std::move(todo->top().first); @@ -212,27 +212,27 @@ struct AutoDerefTermSpec template class OnlyMemorizeNonVar { - Map _memo; + Lib::Map _memo; public: OnlyMemorizeNonVar(OnlyMemorizeNonVar &&) = default; OnlyMemorizeNonVar& operator=(OnlyMemorizeNonVar &&) = default; OnlyMemorizeNonVar() : _memo() {} - auto memoKey(AutoDerefTermSpec const& arg) -> Option + auto memoKey(AutoDerefTermSpec const& arg) -> Lib::Option { if (arg.term.term.isTerm()) { - return some(arg.term); + return Lib::some(arg.term); } else { return {}; } } - Option get(AutoDerefTermSpec const& arg) + Lib::Option get(AutoDerefTermSpec const& arg) { auto key = memoKey(arg); return key.isSome() ? _memo.tryGet(*key).toOwned() - : Option(); + : Lib::Option(); } template Result getOrInit(AutoDerefTermSpec const& orig, Init init) @@ -260,7 +260,7 @@ class UnificationConstraint : _t1(std::move(t1)), _t2(std::move(t2)), _sort(std::move(sort)) {} - Option toLiteral(RobSubstitution& s); + Lib::Option toLiteral(RobSubstitution& s); TermSpec const& lhs() const { return _t1; } TermSpec const& rhs() const { return _t2; } @@ -269,23 +269,22 @@ class UnificationConstraint { return out << self._t1 << " ?= " << self._t2; } }; -using namespace Lib; class AbstractingUnifier; class UnificationConstraint; class RobSubstitution -:public Backtrackable +:public Lib::Backtrackable { friend class AbstractingUnifier; friend class UnificationConstraint; - DHMap _bindings; - mutable DHMap _outputVarBindings; + Lib::DHMap _bindings; + mutable Lib::DHMap _outputVarBindings; mutable bool _startedBindingOutputVars; mutable unsigned _nextUnboundAvailable; mutable unsigned _nextGlueAvailable; - DHMap _gluedTerms; + Lib::DHMap _gluedTerms; mutable OnlyMemorizeNonVar _applyMemo; public: @@ -336,6 +335,7 @@ class RobSubstitution template TermSpec createTerm(unsigned functor, Args... args) { + using namespace Lib; TermSpec out; if (iterItems(args...).count() == 0) { return TermSpec(TermList(Term::create(functor, 0, nullptr)), /* index */ 0); @@ -381,7 +381,7 @@ class RobSubstitution TermList apply(TermList t, int index) const; Literal* apply(Literal* lit, int index) const; TypedTermList apply(TypedTermList t, int index) const { return TypedTermList(apply(TermList(t), index), apply(t.sort(), index)); } - Stack apply(Stack cl, int index) const; + Lib::Stack apply(Lib::Stack cl, int index) const; size_t getApplicationResultWeight(TermList t, int index) const; size_t getApplicationResultWeight(Literal* lit, int index) const; @@ -410,7 +410,7 @@ class RobSubstitution RobSubstitution& operator=(const RobSubstitution& obj) = delete; template - void bind(DHMap& map, const VarSpec& v, T b); + void bind(Lib::DHMap& map, const VarSpec& v, T b); void bind(const VarSpec& v, TermSpec b); void bindVar(const VarSpec& var, const VarSpec& to); bool match(TermSpec base, TermSpec instance); diff --git a/Kernel/SKIKBO.hpp b/Kernel/SKIKBO.hpp index 11e673f50..ecbb8c10c 100644 --- a/Kernel/SKIKBO.hpp +++ b/Kernel/SKIKBO.hpp @@ -31,7 +31,6 @@ namespace Kernel { -using namespace Lib; /** * Class for instances of the Knuth-Bendix orderings @@ -47,19 +46,19 @@ class SKIKBO KboWeightMap symbolWeights, // precedence ordering params - DArray funcPrec, - DArray typeConPrec, + Lib::DArray funcPrec, + Lib::DArray typeConPrec, // pred prec and pred levels are useless // as in higher-order we treat all symbol as function symbols (or type cons) - DArray predPrec, - DArray predLevels, + Lib::DArray predPrec, + Lib::DArray predLevels, // other bool reverseLCM); virtual ~SKIKBO(); - typedef SmartPtr ArgsIt_ptr; + typedef Lib::SmartPtr ArgsIt_ptr; using PrecedenceOrdering::compare; Result compare(TermList tl1, TermList tl2) const override; @@ -71,7 +70,7 @@ class SKIKBO static TermList reduce(TermStack& args, TermList& head); protected: - typedef DHMap*>*> VarOccMap; + typedef Lib::DHMap*>*> VarOccMap; //Result comparePredicates(Literal* l1, Literal* l2) const override; @@ -95,7 +94,7 @@ class SKIKBO //VarCondRes compareVariables(VarOccMap&, VarOccMap&, VarCondRes) const; VarCondRes compareVariables(TermList tl1, TermList tl2) const; unsigned getMaxRedLength(TermList t) const; - bool varConditionHolds(DHMultiset& tlTerms1, DHMultiset& tlTerms2) const; + bool varConditionHolds(Lib::DHMultiset& tlTerms1, Lib::DHMultiset& tlTerms2) const; bool safe(Term* t1, Term* t2) const; /** Weight of variables */ diff --git a/Kernel/Signature.cpp b/Kernel/Signature.cpp index 07ba8271d..15645dc06 100644 --- a/Kernel/Signature.cpp +++ b/Kernel/Signature.cpp @@ -21,6 +21,7 @@ #include "Signature.hpp" using namespace std; +using namespace Lib; using namespace Kernel; using namespace Shell; diff --git a/Kernel/Signature.hpp b/Kernel/Signature.hpp index e038291a2..e082f6584 100644 --- a/Kernel/Signature.hpp +++ b/Kernel/Signature.hpp @@ -41,8 +41,7 @@ namespace Kernel { -using namespace Lib; -typedef Map SymbolMap; +typedef Lib::Map SymbolMap; /** * Class implementing signatures @@ -107,7 +106,7 @@ class Signature /** Either a FunctionType of a PredicateType object */ mutable OperatorType* _type; /** List of distinct groups the constant is a member of, all members of a distinct group should be distinct from each other */ - List* _distinctGroups; + Lib::List* _distinctGroups; /** number of times it is used in the problem */ unsigned _usageCount; /** number of units it is used in in the problem */ @@ -315,7 +314,7 @@ class Signature inline RealConstantType realValue() const { ASS(realConstant()); return static_cast(this)->_realValue; } - const List* distinctGroups() const { return _distinctGroups; } + const Lib::List* distinctGroups() const { return _distinctGroups; } /** This takes the symbol number of this symbol as the symbol doesn't know it Note that this should only be called on a constant **/ void addToDistinctGroup(unsigned group,unsigned this_number); @@ -389,7 +388,7 @@ class Signature public: RealSymbol(const RealConstantType& val) - : Symbol((env.options->proof() == Shell::Options::Proof::PROOFCHECK) ? "$to_real("+val.toString()+")" : val.toNiceString(), 0, true), _realValue(val) + : Symbol((Lib::env.options->proof() == Shell::Options::Proof::PROOFCHECK) ? "$to_real("+val.toString()+")" : val.toNiceString(), 0, true), _realValue(val) { setType(OperatorType::getConstantsType(AtomicSort::realSort())); } @@ -552,7 +551,7 @@ class Signature return _choiceSymbols.contains(fun); } - DHSet* getChoiceOperators(){ + Lib::DHSet* getChoiceOperators(){ return &_choiceSymbols; } @@ -646,14 +645,14 @@ class Signature unsigned getFunctionNumber(const std::string& name, unsigned arity) const; unsigned getPredicateNumber(const std::string& name, unsigned arity) const; - typedef SmartPtr> DistinctGroupMembers; + typedef Lib::SmartPtr> DistinctGroupMembers; Unit* getDistinctGroupPremise(unsigned group); unsigned createDistinctGroup(Unit* premise = 0); void addToDistinctGroup(unsigned constantSymbol, unsigned groupId); bool hasDistinctGroups(){ return _distinctGroupsAddedTo; } void noDistinctGroupsLeft(){ _distinctGroupsAddedTo=false; } - Stack &distinctGroupMembers(){ return _distinctGroupMembers; } + Lib::Stack &distinctGroupMembers(){ return _distinctGroupMembers; } bool hasTermAlgebras() { return !_termAlgebras.isEmpty(); } bool hasDefPreds() const { return !_fnDefPreds.isEmpty() || !_boolDefPreds.isEmpty(); } @@ -904,19 +903,19 @@ class Signature return _termAlgebras.get(sort.term()->functor()); } void addTermAlgebra(Shell::TermAlgebra *ta) { _termAlgebras.insert(ta->sort().term()->functor(), ta); } - VirtualIterator termAlgebrasIterator() const { return _termAlgebras.range(); } + Lib::VirtualIterator termAlgebrasIterator() const { return _termAlgebras.range(); } Shell::TermAlgebraConstructor* getTermAlgebraConstructor(unsigned functor); void recordDividesNvalue(TermList n){ _dividesNvalues.push(n); } - Stack& getDividesNvalues(){ return _dividesNvalues; } + Lib::Stack& getDividesNvalues(){ return _dividesNvalues; } static bool symbolNeedsQuoting(std::string name, bool interpreted, unsigned arity); private: - Stack _dividesNvalues; - DHMap _formulaCounts; + Lib::Stack _dividesNvalues; + Lib::DHMap _formulaCounts; bool _foolConstantsDefined; unsigned _foolTrue; @@ -925,13 +924,13 @@ class Signature static bool isProtectedName(std::string name); static bool charNeedsQuoting(char c, bool first); /** Stack of function symbols */ - Stack _funs; + Lib::Stack _funs; /** Stack of predicate symbols */ - Stack _preds; + Lib::Stack _preds; /** Stack of type constructor symbols */ - Stack _typeCons; + Lib::Stack _typeCons; - DHSet _choiceSymbols; + Lib::DHSet _choiceSymbols; /** * Map from std::string "name_arity" to their numbers * @@ -955,10 +954,10 @@ class Signature SymbolMap _varNames; // Store the premise of a distinct group for proof printing, if 0 then group is input - Stack _distinctGroupPremises; + Lib::Stack _distinctGroupPremises; // We only store members up until a hard-coded limit i.e. the limit at which we will expand the group - Stack _distinctGroupMembers; + Lib::Stack _distinctGroupMembers; // Flag to indicate if any distinct groups have members bool _distinctGroupsAddedTo; @@ -969,7 +968,7 @@ class Signature * the MonomorphisedInterpretation value already determines whether we deal with a function * or a predicate. */ - DHMap _iSymbols; + Lib::DHMap _iSymbols; /** the number of string constants */ unsigned _strings; @@ -983,8 +982,8 @@ class Signature unsigned _arrayCon; unsigned _arrowCon; unsigned _appFun; - DHSet _fnDefPreds; - DHMap _boolDefPreds; + Lib::DHSet _fnDefPreds; + Lib::DHMap _boolDefPreds; /** * Map from type constructor functor to the associated term algebra, if applicable for the sort. @@ -992,7 +991,7 @@ class Signature * For a term algebra instance, this map gives the general term algebra based on the top-level * functor of its sort, the ctors and dtors still have to be instantiated to the right instances. */ - DHMap _termAlgebras; + Lib::DHMap _termAlgebras; //TODO Why are these here? They are not used anywhere. AYB //void defineOptionTermAlgebra(unsigned optionSort); diff --git a/Kernel/SortHelper.cpp b/Kernel/SortHelper.cpp index de9419070..4fbe369a8 100644 --- a/Kernel/SortHelper.cpp +++ b/Kernel/SortHelper.cpp @@ -28,6 +28,7 @@ #include "SortHelper.hpp" using namespace std; +using namespace Lib; using namespace Kernel; diff --git a/Kernel/SortHelper.hpp b/Kernel/SortHelper.hpp index 3fcb6d6b0..460bf795c 100644 --- a/Kernel/SortHelper.hpp +++ b/Kernel/SortHelper.hpp @@ -48,11 +48,11 @@ class SortHelper { TermList contextSort; // only used by TERMLIST and SPECIALTERM }; - static void collectVariableSortsIter(CollectTask task, DHMap& map, bool ignoreBound = false); + static void collectVariableSortsIter(CollectTask task, Lib::DHMap& map, bool ignoreBound = false); public: static TermList getResultSort(const Term* t); static TermList getResultSortMono(const Term* t); - static TermList getResultSort(TermList t, DHMap& varSorts); + static TermList getResultSort(TermList t, Lib::DHMap& varSorts); static TermList getArgSort(Term const* t, unsigned argIndex); static TermList getTermArgSort(Term const* t, unsigned argIndex); @@ -69,9 +69,9 @@ class SortHelper { [[deprecated("This function is usually only used if we loose the information about the sort of a variable somewhere while over subterms. Recovering the information using this method iterating the literal/term again, is very inefficient and should be avoided. Make sure to use TermIterators that return TypedTermList instead, or raise a discussion on slack/github if you have a use case where this function is *really* needed.")]] static TermList getTermSort(TermList trm, Literal* lit); - static void collectVariableSorts(Unit* u, DHMap& map); - static void collectVariableSorts(Term* t, DHMap& map); - static void collectVariableSorts(Formula* f, DHMap& map, bool ignoreBound = false); + static void collectVariableSorts(Unit* u, Lib::DHMap& map); + static void collectVariableSorts(Term* t, Lib::DHMap& map); + static void collectVariableSorts(Formula* f, Lib::DHMap& map, bool ignoreBound = false); static bool areImmediateSortsValidPoly(Term* t); static bool areImmediateSortsValidMono(Term* t); @@ -91,7 +91,7 @@ class SortHelper { static bool areSortsValid(Clause* cl); static bool areSortsValid(Term* t); - static bool areSortsValid(Term* t, DHMap& varSorts); + static bool areSortsValid(Term* t, Lib::DHMap& varSorts); private: static bool tryGetVariableSortTerm(TermList var, Term* t, TermList& result, bool recurseToSubformulas); }; diff --git a/Kernel/SubformulaIterator.hpp b/Kernel/SubformulaIterator.hpp index 9b998ff03..ee009d1db 100644 --- a/Kernel/SubformulaIterator.hpp +++ b/Kernel/SubformulaIterator.hpp @@ -28,7 +28,7 @@ namespace Kernel { * Implements an iterator over subformulas of a formula or formula list. */ class SubformulaIterator -: public IteratorCore +: public Lib::IteratorCore { public: SubformulaIterator (Formula*); diff --git a/Kernel/SubstHelper.hpp b/Kernel/SubstHelper.hpp index f3b0a51fb..e14df76aa 100644 --- a/Kernel/SubstHelper.hpp +++ b/Kernel/SubstHelper.hpp @@ -25,7 +25,6 @@ namespace Kernel { -using namespace Lib; struct SubstApplicator { virtual ~SubstApplicator() = default; @@ -216,7 +215,7 @@ class SubstHelper template static Literal* applyToLiteral(Literal* lit, Subst subst) { - static DArray ts(32); + static Lib::DArray ts(32); int arity = lit->arity(); ts.ensure(arity); @@ -387,7 +386,7 @@ Term* SubstHelper::applyImpl(Term* trm, Applicator& applicator, bool noSharing) // TODO in principle this should not be so difficult to handle ASSERTION_VIOLATION; case SpecialFunctor::MATCH: { - DArray terms(trm->arity()); + Lib::DArray terms(trm->arity()); for (unsigned i = 0; i < trm->arity(); i++) { terms[i] = applyImpl(*trm->nthArgument(i), applicator, noSharing); } @@ -397,10 +396,10 @@ Term* SubstHelper::applyImpl(Term* trm, Applicator& applicator, bool noSharing) ASSERTION_VIOLATION; } - Recycled> toDo; - Recycled> terms; - Recycled> modified; - Recycled> args; + Lib::Recycled> toDo; + Lib::Recycled> terms; + Lib::Recycled> modified; + Lib::Recycled> args; modified->push(false); toDo->push(trm->args()); @@ -630,7 +629,7 @@ FormulaList* SubstHelper::applyImpl(FormulaList* fs, Applicator& applicator, boo return fs; } - Stack args; + Lib::Stack args; while (FormulaList::isNonEmpty(fs)) { args.push(fs); fs = fs->tail(); diff --git a/Kernel/Substitution.hpp b/Kernel/Substitution.hpp index be2e45d95..599c176dc 100644 --- a/Kernel/Substitution.hpp +++ b/Kernel/Substitution.hpp @@ -28,7 +28,6 @@ namespace Kernel { -using namespace Lib; /** * The class Substitution implementing substitutions. @@ -61,7 +60,7 @@ class Substitution #endif friend std::ostream& operator<<(std::ostream& out, Substitution const&); private: - DHMap _map; + Lib::DHMap _map; }; // class Substitution diff --git a/Kernel/Term.hpp b/Kernel/Term.hpp index 823ce02f3..84b32396d 100644 --- a/Kernel/Term.hpp +++ b/Kernel/Term.hpp @@ -56,7 +56,6 @@ namespace Kernel { std::ostream& operator<<(std::ostream& out, Literal const& self); bool operator<(TermList const&,TermList const&); -using namespace Lib; /** Tag denoting the kind of this term * @since 19/02/2008 Manchester, moved outside of the Term class @@ -179,7 +178,7 @@ class TermList { /** set the content manually - hazardous, such terms should then only be used as integers */ void setContent(uint64_t content) { _content = content; } /** default hash is to hash the content */ - unsigned defaultHash() const { return DefaultHash::hash(content()); } + unsigned defaultHash() const { return Lib::DefaultHash::hash(content()); } unsigned defaultHash2() const { return content(); } std::string toString(bool topLevel = true) const; @@ -199,7 +198,7 @@ class TermList { /** the top of a term is either a function symbol or a variable id. this class is model this */ class Top { - using Inner = Coproduct; + using Inner = Lib::Coproduct; static constexpr unsigned VAR = 0; static constexpr unsigned FUN = 1; Inner _inner; @@ -210,8 +209,8 @@ class TermList { // static Top functor(unsigned f) { return Top(Inner::variant(f)); } template static Top functor(T const* t) { return Top(Inner::variant({ t->functor(), t->kind(), })); } - Option var() const { return _inner.as().toOwned(); } - Option functor() const { return _inner.as().toOwned(); } + Lib::Option var() const { return _inner.as().toOwned(); } + Lib::Option functor() const { return _inner.as().toOwned(); } Lib::Comparison compare(Top const& other) const { return _inner.compare(other._inner); } IMPL_COMPARISONS_FROM_COMPARE(Top); @@ -479,11 +478,11 @@ class alignas(8) Term explicit Term(const Term& t) throw(); static Term* create(unsigned function, unsigned arity, const TermList* args); static Term* create(unsigned fn, std::initializer_list args); - static Term* create(unsigned fn, Stack const& args) { return Term::create(fn, args.length(), args.begin()); } + static Term* create(unsigned fn, Lib::Stack const& args) { return Term::create(fn, args.length(), args.begin()); } template static Term* createFromIter(unsigned fn, Iter args) { - Recycled> stack; + Lib::Recycled> stack; stack->loadFromIterator(args); return Term::create(fn, *stack); } @@ -614,15 +613,16 @@ class alignas(8) Term template static unsigned termHash(unsigned functor, GetArg getArg, unsigned arity) { - return DefaultHash::hashIter( + using namespace Lib; + return Lib::DefaultHash::hashIter( range(0, arity).map([&](auto i) { TermList t = getArg(i); - return DefaultHash::hashBytes( + return Lib::DefaultHash::hashBytes( reinterpret_cast(&t), sizeof(TermList) ); }), - DefaultHash::hash(functor)); + Lib::DefaultHash::hash(functor)); } /** @@ -1106,12 +1106,12 @@ class Literal { return Literal::literalHash(functor(), polarity() ^ flip, [&](auto i) -> TermList const& { return *nthArgument(i); }, arity(), - someIf(isTwoVarEquality(), [&](){ return twoVarEqSort(); }), + Lib::someIf(isTwoVarEquality(), [&](){ return twoVarEqSort(); }), commutative()); } template - static unsigned literalEquals(const Literal* lit, unsigned functor, bool polarity, GetArg getArg, unsigned arity, Option twoVarEqSort, bool commutative) { + static unsigned literalEquals(const Literal* lit, unsigned functor, bool polarity, GetArg getArg, unsigned arity, Lib::Option twoVarEqSort, bool commutative) { if (functor != lit->functor() || polarity != lit->polarity()) return false; if (commutative) { @@ -1119,34 +1119,34 @@ class Literal ASS(rightArgOrder(getArg(0), getArg(1))) ASS(rightArgOrder(*lit->nthArgument(0), *lit->nthArgument(1))) - if (someIf(lit->isTwoVarEquality(), [&](){ return lit->twoVarEqSort(); }) != twoVarEqSort) { + if (Lib::someIf(lit->isTwoVarEquality(), [&](){ return lit->twoVarEqSort(); }) != twoVarEqSort) { return false; } return std::make_tuple(*lit->nthArgument(0), *lit->nthArgument(1)) == std::make_tuple(getArg(0), getArg(1)); } else { ASS(twoVarEqSort.isNone()) - return range(0, arity).all([&](auto i) { return *lit->nthArgument(i) == getArg(i); }); + return Lib::range(0, arity).all([&](auto i) { return *lit->nthArgument(i) == getArg(i); }); } } static bool rightArgOrder(TermList const& lhs, TermList const& rhs); template - static unsigned literalHash(unsigned functor, bool polarity, GetArg getArg, unsigned arity, Option twoVarEqSort, bool commutative) { + static unsigned literalHash(unsigned functor, bool polarity, GetArg getArg, unsigned arity, Lib::Option twoVarEqSort, bool commutative) { if (commutative) { ASS_EQ(arity, 2) ASS(rightArgOrder(getArg(0), getArg(1))) - return HashUtils::combine( - DefaultHash::hash(polarity), - DefaultHash::hash(functor), - DefaultHash::hash(twoVarEqSort), + return Lib::HashUtils::combine( + Lib::DefaultHash::hash(polarity), + Lib::DefaultHash::hash(functor), + Lib::DefaultHash::hash(twoVarEqSort), getArg(0).defaultHash(), getArg(1).defaultHash()); } else { ASS(twoVarEqSort.isNone()) - return HashUtils::combine( - DefaultHash::hash(polarity), + return Lib::HashUtils::combine( + Lib::DefaultHash::hash(polarity), Term::termHash(functor, getArg, arity)); } } @@ -1232,7 +1232,7 @@ class Literal private: template - static Literal* create(unsigned predicate, unsigned arity, bool polarity, bool commutative, GetArg args, Option twoVarEqSort = Option()); + static Literal* create(unsigned predicate, unsigned arity, bool polarity, bool commutative, GetArg args, Lib::Option twoVarEqSort = Lib::Option()); }; // class Literal // TODO used in some proofExtra output diff --git a/Kernel/TermIterators.cpp b/Kernel/TermIterators.cpp index 228e3c7f8..09c3e0ed1 100644 --- a/Kernel/TermIterators.cpp +++ b/Kernel/TermIterators.cpp @@ -23,6 +23,8 @@ namespace Kernel { +using namespace Lib; + typedef ApplicativeHelper AH; /** diff --git a/Kernel/TermIterators.hpp b/Kernel/TermIterators.hpp index 91e03070f..3b63e1dc6 100644 --- a/Kernel/TermIterators.hpp +++ b/Kernel/TermIterators.hpp @@ -38,7 +38,7 @@ namespace Kernel { * use VariableIterator2 below, having read its documentation. */ class VariableIterator -: public IteratorCore +: public Lib::IteratorCore { public: DECL_ELEMENT_TYPE(TermList); @@ -114,21 +114,21 @@ class VariableIterator return *_stack.top(); } private: - Stack _stack; + Lib::Stack _stack; bool _used; TermList _aux[2]; }; struct VariableIteratorFn { - VirtualIterator operator()(Term* t) + Lib::VirtualIterator operator()(Term* t) { return vi( new VariableIterator(t) ); } - VirtualIterator operator()(TermList t) + Lib::VirtualIterator operator()(TermList t) { if(t.isVar()) { - return pvi( getSingletonIterator(t) ); + return pvi( Lib::getSingletonIterator(t) ); } else { return (*this)(t.term()); @@ -158,7 +158,7 @@ struct OrdVarNumberExtractorFn * with SortHelper::collectVariableSorts as it is more efficient. */ class VariableWithSortIterator -: public IteratorCore> +: public Lib::IteratorCore> { public: @@ -182,9 +182,9 @@ class VariableWithSortIterator return std::make_pair(*_stack.top(), SortHelper::getArgSort(const_cast(_terms.top()), _argNums.top())); } private: - Stack _stack; - Stack _terms; - Stack _argNums; + Lib::Stack _stack; + Lib::Stack _terms; + Lib::Stack _argNums; bool _used; }; @@ -193,7 +193,7 @@ class VariableWithSortIterator * of @b term in DFS left to right order. */ class SubtermIterator - : public IteratorCore + : public Lib::IteratorCore { public: SubtermIterator(const Term* term) : _used(false) @@ -228,7 +228,7 @@ class SubtermIterator } } - Recycled> _stack; + Lib::Recycled> _stack; bool _used; }; @@ -246,7 +246,7 @@ class SubtermIterator * of @b applicative term */ class ApplicativeArgsIt - : public IteratorCore + : public Lib::IteratorCore { public: ApplicativeArgsIt(const TermList term, bool returnTypeArgs = true) @@ -305,7 +305,7 @@ class ApplicativeArgsIt }; class TopLevelVarLikeTermIterator - : public IteratorCore + : public Lib::IteratorCore { public: TopLevelVarLikeTermIterator(Term* term) @@ -327,12 +327,12 @@ class TopLevelVarLikeTermIterator } private: - Stack _stack; + Lib::Stack _stack; Term* _next; }; class TopLevelVarIterator - : public IteratorCore + : public Lib::IteratorCore { public: TopLevelVarIterator(TermList t); @@ -357,7 +357,7 @@ class RewritableVarsIt { public: //includeSelf for compatibility DECL_ELEMENT_TYPE(TypedTermList); - RewritableVarsIt(DHSet* unstableVars, Term* t, bool includeSelf = false) : _next(), _stack(8) + RewritableVarsIt(Lib::DHSet* unstableVars, Term* t, bool includeSelf = false) : _next(), _stack(8) { _unstableVars = unstableVars; if(t->isLiteral()){ @@ -384,14 +384,14 @@ class RewritableVarsIt return *_next.take(); } private: - Option _next; - Stack _stack; - Stack _sorts; - DHSet* _unstableVars; + Lib::Option _next; + Lib::Stack _stack; + Lib::Stack _sorts; + Lib::DHSet* _unstableVars; }; class UnstableVarIt - : public IteratorCore + : public Lib::IteratorCore { public: UnstableVarIt(Term* t) : _stable(8), _stack(8) @@ -419,12 +419,12 @@ class UnstableVarIt private: TermList _next; - Stack _stable; - Stack _stack; + Lib::Stack _stable; + Lib::Stack _stack; }; class FirstOrderSubtermIt -: public IteratorCore +: public Lib::IteratorCore { public: FirstOrderSubtermIt(Term* term, bool includeSelf=false) @@ -448,13 +448,13 @@ class FirstOrderSubtermIt void right(); private: - Stack _stack; + Lib::Stack _stack; int _added; }; class NarrowableSubtermIt -: public IteratorCore +: public Lib::IteratorCore { public: NarrowableSubtermIt(Term* term, bool includeSelf=false) @@ -481,14 +481,14 @@ class NarrowableSubtermIt private: bool _used; TermList _next; - Stack _stack; + Lib::Stack _stack; }; /* * Returns Boolean subterms of a term. */ class BooleanSubtermIt -: public IteratorCore +: public Lib::IteratorCore { public: BooleanSubtermIt(Term* term, bool includeSelf=false) @@ -514,7 +514,7 @@ class BooleanSubtermIt private: bool _used; TermList _next; - Stack _stack; + Lib::Stack _stack; }; ////////////////////////////////////////////////////////////////////////// @@ -555,7 +555,7 @@ class ReversedCommutativeSubtermIterator * its arguments left to right, and then the function itself. */ class PolishSubtermIterator -: public IteratorCore +: public Lib::IteratorCore { public: PolishSubtermIterator(const Term* term) : _stack(8), _used(false) @@ -584,7 +584,7 @@ class PolishSubtermIterator t=t->term()->args(); } } - Stack _stack; + Lib::Stack _stack; bool _used; }; @@ -598,7 +598,7 @@ class PolishSubtermIterator * are required. */ class NonVariableIterator - : public IteratorCore + : public Lib::IteratorCore { public: NonVariableIterator(const NonVariableIterator&); @@ -625,7 +625,7 @@ class NonVariableIterator void right(); private: /** available non-variable subterms */ - Stack _stack; + Lib::Stack _stack; /** the number of non-variable subterms added at the last iteration, used by right() */ int _added; }; // NonVariableIterator @@ -643,7 +643,7 @@ class NonVariableIterator * another */ class NonVariableNonTypeIterator - : public IteratorCore + : public Lib::IteratorCore { public: NonVariableNonTypeIterator(const NonVariableNonTypeIterator&); @@ -667,7 +667,7 @@ class NonVariableNonTypeIterator void right(); private: /** available non-variable subterms */ - Stack _stack; + Lib::Stack _stack; /** the number of non-variable subterms added at the last iteration, used by right() */ int _added; }; // NonVariableIterator @@ -677,7 +677,7 @@ class NonVariableNonTypeIterator * or literals in DFS left to right order. */ class DisagreementSetIterator -: public IteratorCore > +: public Lib::IteratorCore > { public: /** @@ -764,7 +764,7 @@ class DisagreementSetIterator return res; } private: - Stack _stack; + Lib::Stack _stack; bool _disjunctVariables; TermList _arg1; TermList _arg2; @@ -779,7 +779,7 @@ class DisagreementSetIterator * @since 26/05/2007 Manchester, made from class TermVarIterator */ class TermFunIterator -: public IteratorCore +: public Lib::IteratorCore { public: TermFunIterator (const Term*); @@ -792,7 +792,7 @@ class TermFunIterator /** next symbol, previously found */ unsigned _next; /** Stack of term lists (not terms!) */ - Stack _stack; + Lib::Stack _stack; }; // class TermFunIterator @@ -802,7 +802,7 @@ class TermFunIterator * @since 26/05/2007 Manchester, reimplemented for different data structures */ class TermVarIterator -: public IteratorCore +: public Lib::IteratorCore { public: TermVarIterator (const Term*); @@ -816,7 +816,7 @@ class TermVarIterator /** next variable, previously found */ unsigned _next; /** Stack of term lists (not terms!) */ - Stack _stack; + Lib::Stack _stack; }; // class TermVarIterator @@ -837,19 +837,19 @@ class LiteralArgIterator /** iterator over all term arguments of @code term */ static const auto termArgIter = [](Term* term) - { return iterTraits(getRangeIterator(0, term->numTermArguments())) + { return iterTraits(Lib::getRangeIterator(0, term->numTermArguments())) .map([=](auto i) { return term->termArg(i); }); }; /** iterator over all type arguments of @code term */ static const auto typeArgIter = [](Term* term) - { return iterTraits(getRangeIterator(0, term->numTypeArguments())) + { return iterTraits(Lib::getRangeIterator(0, term->numTypeArguments())) .map([=](auto i) { return term->typeArg(i); }); }; /** iterator over all type and term arguments of @code term */ static const auto anyArgIter = [](Term* term) - { return iterTraits(getRangeIterator(0, term->arity())) + { return iterTraits(Lib::getRangeIterator(0, term->arity())) .map([=](auto i) { return *term->nthArgument(i); }); }; diff --git a/Kernel/TermTransformer.cpp b/Kernel/TermTransformer.cpp index 49ae5490a..7b192183a 100644 --- a/Kernel/TermTransformer.cpp +++ b/Kernel/TermTransformer.cpp @@ -22,6 +22,7 @@ namespace Kernel { using namespace std; +using namespace Lib; Literal* TermTransformerCommon::transformLiteral(Literal* lit) diff --git a/Kernel/Theory.hpp b/Kernel/Theory.hpp index 1967e4126..eebaf9fbe 100644 --- a/Kernel/Theory.hpp +++ b/Kernel/Theory.hpp @@ -37,7 +37,7 @@ class RealConstantType; * Exception to be thrown when the requested operation cannot be performed, * e.g. because of overflow of a native type. */ -class ArithmeticException : public Exception { +class ArithmeticException : public Lib::Exception { protected: ArithmeticException(const char* msg) : Exception(msg) {} }; @@ -110,7 +110,7 @@ class IntegerConstantType static IntegerConstantType ceiling(IntegerConstantType rat); IntegerConstantType abs() const; - static Comparison comparePrecedence(IntegerConstantType n1, IntegerConstantType n2); + static Lib::Comparison comparePrecedence(IntegerConstantType n1, IntegerConstantType n2); size_t hash() const; std::string toString() const; @@ -185,7 +185,7 @@ struct RationalConstantType { const InnerType& denominator() const { return _den; } size_t hash() const; - static Comparison comparePrecedence(RationalConstantType n1, RationalConstantType n2); + static Lib::Comparison comparePrecedence(RationalConstantType n1, RationalConstantType n2); protected: void init(InnerType num, InnerType den); @@ -238,7 +238,7 @@ class RealConstantType : public RationalConstantType std::string toNiceString() const; size_t hash() const; - static Comparison comparePrecedence(RealConstantType n1, RealConstantType n2); + static Lib::Comparison comparePrecedence(RealConstantType n1, RealConstantType n2); /** * returns the internal represenation of this RealConstantType. @@ -410,7 +410,7 @@ class Theory typedef std::pair MonomorphisedInterpretation; private: - DHMap _indexedInterpretations; + Lib::DHMap _indexedInterpretations; public: @@ -501,9 +501,9 @@ class Theory private: // For recording the templates for predicate and function symbols - DHMap _predLaTeXnamesPos; - DHMap _predLaTeXnamesNeg; - DHMap _funcLaTeXnames; + Lib::DHMap _predLaTeXnamesPos; + Lib::DHMap _predLaTeXnamesNeg; + Lib::DHMap _funcLaTeXnames; public: @@ -560,7 +560,7 @@ class Theory Theory(); static OperatorType* getConversionOperationType(Interpretation i); - DHMap _arraySkolemFunctions; + Lib::DHMap _arraySkolemFunctions; public: class Tuples { diff --git a/Kernel/UnificationWithAbstraction.cpp b/Kernel/UnificationWithAbstraction.cpp index 4f85491a3..5cd5f4001 100644 --- a/Kernel/UnificationWithAbstraction.cpp +++ b/Kernel/UnificationWithAbstraction.cpp @@ -38,6 +38,8 @@ namespace Kernel { +using namespace Lib; + Shell::Options::UnificationWithAbstraction AbstractionOracle::create() { if (env.options->unificationWithAbstraction()!=Options::UnificationWithAbstraction::OFF) { diff --git a/Kernel/UnificationWithAbstraction.hpp b/Kernel/UnificationWithAbstraction.hpp index e5b18e03b..81fb08b52 100644 --- a/Kernel/UnificationWithAbstraction.hpp +++ b/Kernel/UnificationWithAbstraction.hpp @@ -32,7 +32,7 @@ namespace Kernel class UnificationConstraintStack { - Stack _cont; + Lib::Stack _cont; public: USE_ALLOCATOR(UnificationConstraintStack) UnificationConstraintStack() : _cont() {} @@ -42,7 +42,7 @@ class UnificationConstraintStack auto iter() const { return iterTraits(_cont.iter()); } - Recycled> literals(RobSubstitution& s); + Lib::Recycled> literals(RobSubstitution& s); // returns the maximum number of constraints of this stack. this is not equal to the actual number of constraints it will hold, as constraints // might become trivial (i.e. of the form t != t) after applying the substitution, so they will be filtered out when calling literals(RobSubstitution&) @@ -61,8 +61,8 @@ class UnificationConstraintStack bool isEmpty() const { return _cont.isEmpty(); } - void add(UnificationConstraint c, Option bd); - UnificationConstraint pop(Option bd); + void add(UnificationConstraint c, Lib::Option bd); + UnificationConstraint pop(Lib::Option bd); }; class AbstractionOracle final @@ -73,8 +73,8 @@ class AbstractionOracle final AbstractionOracle(Shell::Options::UnificationWithAbstraction mode) : _mode(mode) {} struct EqualIf { - Recycled> _unify; - Recycled> _constr; + Lib::Recycled> _unify; + Lib::Recycled> _constr; EqualIf() : _unify(), _constr() {} @@ -110,7 +110,7 @@ class AbstractionOracle final { return out << "NeverEqual"; } }; - using AbstractionResult = Coproduct; + using AbstractionResult = Lib::Coproduct; /** main function that either returns nothing, which means that unification with abstraction will * shall not be applied for the given terms, or an AbstractionResult, which tells wether the given @@ -123,7 +123,7 @@ class AbstractionOracle final * * For details check out the paper "Refining Unification with Absraction" from LPAR 2023. */ - Option tryAbstract( + Lib::Option tryAbstract( AbstractingUnifier* au, TermSpec const& t1, TermSpec const& t2) const; @@ -142,9 +142,9 @@ class AbstractionOracle final class AbstractingUnifier { - Recycled _subs; - Recycled _constr; - Option _bd; + Lib::Recycled _subs; + Lib::Recycled _constr; + Lib::Option _bd; AbstractionOracle _uwa; friend class RobSubstitution; @@ -167,26 +167,26 @@ class AbstractingUnifier bool fixedPointIteration(); // TODO document - Option>> unifiableSymbols(SymbolId f); + Lib::Option>> unifiableSymbols(SymbolId f); - static Option unify(TermList t1, unsigned bank1, TermList t2, unsigned bank2, AbstractionOracle uwa, bool fixedPointIteration) + static Lib::Option unify(TermList t1, unsigned bank1, TermList t2, unsigned bank2, AbstractionOracle uwa, bool fixedPointIteration) { auto au = AbstractingUnifier::empty(uwa); if (!au.unify(t1, bank1, t2, bank2)) return {}; - if (!fixedPointIteration || au.fixedPointIteration()) return some(std::move(au)); + if (!fixedPointIteration || au.fixedPointIteration()) return Lib::some(std::move(au)); else return {}; } UnificationConstraintStack& constr() { return *_constr; } - Recycled> computeConstraintLiterals() { return _constr->literals(*_subs); } + Lib::Recycled> computeConstraintLiterals() { return _constr->literals(*_subs); } unsigned maxNumberOfConstraints() { return _constr->maxNumberOfConstraints(); } RobSubstitution & subs() { return *_subs; } RobSubstitution const& subs() const { return *_subs; } - Option bd() { return someIf(_subs->bdIsRecording(), [&]() -> decltype(auto) { return _subs->bdGet(); }); } - BacktrackData& bdGet() { return _subs->bdGet(); } - void bdRecord(BacktrackData& bd) { _subs->bdRecord(bd); } + Lib::Option bd() { return Lib::someIf(_subs->bdIsRecording(), [&]() -> decltype(auto) { return _subs->bdGet(); }); } + Lib::BacktrackData& bdGet() { return _subs->bdGet(); } + void bdRecord(Lib::BacktrackData& bd) { _subs->bdRecord(bd); } void bdDone() { _subs->bdDone(); } bool usesUwa() const { return _uwa._mode != Options::UnificationWithAbstraction::OFF; } diff --git a/Kernel/Unit.cpp b/Kernel/Unit.cpp index f76faadf7..0e9299136 100644 --- a/Kernel/Unit.cpp +++ b/Kernel/Unit.cpp @@ -35,6 +35,7 @@ #include "Unit.hpp" using namespace std; +using namespace Lib; using namespace Kernel; unsigned Unit::_lastNumber = 0; diff --git a/Kernel/Unit.hpp b/Kernel/Unit.hpp index cc511d159..30bac0e01 100644 --- a/Kernel/Unit.hpp +++ b/Kernel/Unit.hpp @@ -25,7 +25,6 @@ namespace Kernel { -using namespace Lib; /** * Class to represent units of inference (such as clauses and formulas). diff --git a/Lib/BitUtils.hpp b/Lib/BitUtils.hpp index f63896106..28174c190 100644 --- a/Lib/BitUtils.hpp +++ b/Lib/BitUtils.hpp @@ -116,12 +116,12 @@ class BitUtils } #define BITFIELD64_GET_AND_SET(type, name, Name, NAME) \ - type _##name() const { return BitUtils::getBits(this->_content); } \ - void _set##Name(type val) { BitUtils::setBits(this->_content, val); } + type _##name() const { return Lib::BitUtils::getBits(this->_content); } \ + void _set##Name(type val) { Lib::BitUtils::setBits(this->_content, val); } #define BITFIELD64_GET_AND_SET_PTR(type, name, Name, NAME) \ - type _##name() const { return reinterpret_cast(BitUtils::getBits(this->_content)); } \ - void _set##Name(type val) { BitUtils::setBits(this->_content, reinterpret_cast(val)); } + type _##name() const { return reinterpret_cast(Lib::BitUtils::getBits(this->_content)); } \ + void _set##Name(type val) { Lib::BitUtils::setBits(this->_content, reinterpret_cast(val)); } }; }; diff --git a/Lib/Coproduct.hpp b/Lib/Coproduct.hpp index fe784ff43..646218091 100644 --- a/Lib/Coproduct.hpp +++ b/Lib/Coproduct.hpp @@ -279,7 +279,7 @@ namespace CoproductImpl { #else //!VDEBUG size; #endif // VDEBUG - static constexpr unsigned bitMask = ::bitMask(nTags); + static constexpr unsigned bitMask = Lib::bitMask(nTags); static_assert(nTags == 0 || nTags - 1 == ((nTags - 1) & bitMask), "bug in function neededBits"); diff --git a/Lib/Recycled.hpp b/Lib/Recycled.hpp index 4e7107038..6ef13ae9d 100644 --- a/Lib/Recycled.hpp +++ b/Lib/Recycled.hpp @@ -224,17 +224,17 @@ bool Recycled::memAlive = true; }; template -using RStack = Recycled>; +using RStack = Lib::Recycled>; template -Recycled> recycledStack() -{ return Recycled>(); } +Lib::Recycled> recycledStack() +{ return Lib::Recycled>(); } template -Recycled> recycledStack(T t, Ts... ts) +Lib::Recycled> recycledStack(T t, Ts... ts) { - Recycled> out; + Lib::Recycled> out; out->pushMany(std::move(t), std::move(ts)...); return out; } diff --git a/Lib/Reflection.hpp b/Lib/Reflection.hpp index 1104dbbda..ff77aa196 100644 --- a/Lib/Reflection.hpp +++ b/Lib/Reflection.hpp @@ -42,7 +42,7 @@ #define __IMPL_COMPARISONS_FROM_COMPARE(Class, op, ...) \ friend bool operator op(Class const& l, Class const& r) { \ - switch (DefaultComparator::compare(l,r)) { \ + switch (Lib::DefaultComparator::compare(l,r)) { \ __VA_ARGS__ return true; \ default: return false; \ } \ @@ -50,16 +50,16 @@ #define IMPL_EQ_FROM_COMPARE(Class) \ friend bool operator==(Class const& l, Class const& r) \ - { return DefaultComparator::compare(l,r) == Comparison::EQUAL; } \ + { return Lib::DefaultComparator::compare(l,r) == Lib::Comparison::EQUAL; } \ \ friend bool operator!=(Class const& l, Class const& r) \ { return !(l == r); } \ #define IMPL_COMPARISONS_FROM_COMPARE(Class) \ - __IMPL_COMPARISONS_FROM_COMPARE(Class, > , case GREATER: ) \ - __IMPL_COMPARISONS_FROM_COMPARE(Class, < , case LESS : ) \ - __IMPL_COMPARISONS_FROM_COMPARE(Class, >=, case GREATER: case EQUAL: ) \ - __IMPL_COMPARISONS_FROM_COMPARE(Class, <=, case LESS : case EQUAL: ) \ + __IMPL_COMPARISONS_FROM_COMPARE(Class, > , case Lib::Comparison::GREATER: ) \ + __IMPL_COMPARISONS_FROM_COMPARE(Class, < , case Lib::Comparison::LESS : ) \ + __IMPL_COMPARISONS_FROM_COMPARE(Class, >=, case Lib::Comparison::GREATER: case Lib::Comparison::EQUAL: ) \ + __IMPL_COMPARISONS_FROM_COMPARE(Class, <=, case Lib::Comparison::LESS : case Lib::Comparison::EQUAL: ) \ #define IMPL_COMPARISONS_FROM_LESS_AND_EQUALS(Class) \ @@ -69,8 +69,8 @@ friend bool operator!=(Class const& l, Class const& r) { return !(l == r); } \ #define IMPL_HASH_FROM_TUPLE(Class) \ - unsigned defaultHash() const { return DefaultHash::hash(asTuple()); } \ - unsigned defaultHash2() const { return DefaultHash2::hash(asTuple()); } \ + unsigned defaultHash() const { return Lib::DefaultHash::hash(asTuple()); } \ + unsigned defaultHash2() const { return Lib::DefaultHash2::hash(asTuple()); } \ //The obvious way to define this macro would be //#define DECL_ELEMENT_TYPE(T) typedef T _ElementType diff --git a/Lib/Timer.cpp b/Lib/Timer.cpp index d5856aec1..4b976d034 100644 --- a/Lib/Timer.cpp +++ b/Lib/Timer.cpp @@ -36,6 +36,7 @@ #define MEGA (1 << 20) using namespace std; +using namespace Lib; // things that need to be signal-safe because they are used in timer_sigalrm_handler // in principle we also need is_lock_free() to avoid deadlock as well diff --git a/Parse/SMTLIB2.cpp b/Parse/SMTLIB2.cpp index 47dbc5ec5..d32394093 100644 --- a/Parse/SMTLIB2.cpp +++ b/Parse/SMTLIB2.cpp @@ -58,6 +58,7 @@ namespace Parse { using namespace std; +using namespace Lib; static const char* PAR = "par"; static const char* TYPECON_POSTFIX = "()"; diff --git a/Parse/SMTLIB2.hpp b/Parse/SMTLIB2.hpp index 3a32d0bcd..c7c644232 100644 --- a/Parse/SMTLIB2.hpp +++ b/Parse/SMTLIB2.hpp @@ -28,7 +28,6 @@ namespace Parse { -using namespace Lib; using namespace Kernel; using namespace Shell; @@ -137,7 +136,7 @@ class SMTLIB2 { /** * Maps smtlib name of a defined sort to its SortDefinition struct. */ - DHMap _sortDefinitions; + Lib::DHMap _sortDefinitions; /** * Handle "define-sort" entry. @@ -230,7 +229,7 @@ class SMTLIB2 { /** */ typedef std::pair DeclaredSymbol; /** symbols are implicitly declared also when they are defined (see below) */ - DHMap _declaredSymbols; + Lib::DHMap _declaredSymbols; /** * Given a symbol name, range sort (which can be Bool) and argSorts, @@ -266,7 +265,7 @@ class SMTLIB2 { void readDeclareDatatypes(LExprList* sorts, LExprList* datatypes, bool codatatype = false); TermAlgebraConstructor* buildTermAlgebraConstructor(std::string constrName, TermList taSort, - Stack destructorNames, TermStack argSorts); + Lib::Stack destructorNames, TermStack argSorts); /** * Parse result of parsing an smtlib term (which can be of sort Bool and therefore represented in vampire by a formula) @@ -339,8 +338,8 @@ class SMTLIB2 { /** < termlist, vampire sort id > */ typedef std::pair SortedTerm; /** mast an identifier to SortedTerm */ - typedef DHMap TermLookup; - typedef Stack Scopes; + typedef Lib::DHMap TermLookup; + typedef Lib::Stack Scopes; /** Stack of parsing contexts: * for variables from quantifiers and * for symbols bound by let (which are variables from smtlib perspective, @@ -351,7 +350,7 @@ class SMTLIB2 { /** * Stack of partial results used by parseTermOrFormula below. */ - Stack _results; + Lib::Stack _results; /** * Possible operations during parsing a term. @@ -379,7 +378,7 @@ class SMTLIB2 { /** * Main smtlib term parsing stack. */ - Stack > _todo; + Lib::Stack > _todo; // global parsing data structures -- END @@ -510,7 +509,7 @@ class SMTLIB2 { * To support a mechanism for dealing with large arithmetic constants. * Adapted from the tptp parser. */ - Set _overflow; + Lib::Set _overflow; /** * Top-level expression that is parsed presently. diff --git a/Parse/TPTP.hpp b/Parse/TPTP.hpp index 9ee8a44c3..1aade8955 100644 --- a/Parse/TPTP.hpp +++ b/Parse/TPTP.hpp @@ -33,7 +33,6 @@ //#define DEBUG_SHOW_STATE -using namespace Lib; using namespace Kernel; namespace Kernel { @@ -302,7 +301,7 @@ class TPTP * Implements lexer and parser exceptions. */ class ParseErrorException - : public ParsingRelatedException + : public Lib::ParsingRelatedException { public: ParseErrorException(std::string message,unsigned ln) : _message(message), _ln(ln) {} @@ -352,7 +351,7 @@ class TPTP static void assignAxiomName(const Unit* unit, std::string& name); unsigned lineNumber(){ return _lineNumber; } - static Map* findQuestionVars(unsigned questionNumber) { + static Lib::Map* findQuestionVars(unsigned questionNumber) { auto res = _questionVariableNames.findPtr(questionNumber); return res ? *res : nullptr; } @@ -529,30 +528,30 @@ class TPTP * This is to support the feature formula_selection of the include * directive of the TPTP format. */ - Set* _allowedNames; + Lib::Set* _allowedNames; /** stacks of allowed names when include is used */ - Stack*> _allowedNamesStack; + Lib::Stack*> _allowedNamesStack; /** set of files whose inclusion should be ignored */ - Set _forbiddenIncludes; + Lib::Set _forbiddenIncludes; /** the input stream */ std::istream* _in; /** in the case include() is used, previous streams will be saved here */ - Stack _inputs; + Lib::Stack _inputs; /** the current include directory */ std::string _includeDirectory; /** in the case include() is used, previous sequence of directories will be * saved here, this is required since TPTP requires the directory to be * relative to the "current directory, that is, the directory used by the last include() */ - Stack _includeDirectories; + Lib::Stack _includeDirectories; /** input characters */ - Array _chars; + Lib::Array _chars; /** position in the input stream of the 0th character in _chars[] */ int _gpos; /** the position beyond the last read characters */ int _cend; /** tokens currently at work */ - Array _tokens; + Lib::Array _tokens; /** the position beyond the last processed token */ int _tend; /** line number */ @@ -560,7 +559,7 @@ class TPTP /** The list of units read (with additions directed to the end) */ UnitList::FIFO _units; /** stack of unprocessed states */ - Stack _states; + Lib::Stack _states; /** input type of the last read unit */ // it must be int since -1 can be used as a value UnitInputType _lastInputType; /** true if the last read unit is a question */ @@ -573,41 +572,41 @@ class TPTP /** */ bool _containsPolymorphism; /** various strings saved during parsing */ - Stack _strings; + Lib::Stack _strings; /** various connectives saved during parsing */ // they must be int, since non-existing value -1 can be used - Stack _connectives; + Lib::Stack _connectives; /** various boolean values saved during parsing */ - Stack _bools; + Lib::Stack _bools; /** various integer values saved during parsing */ - Stack _ints; + Lib::Stack _ints; /** variable lists for building formulas */ - Stack _varLists; + Lib::Stack _varLists; /** sort lists for building formulas */ - Stack _sortLists; + Lib::Stack _sortLists; /** variable lists for binding variables */ - Stack _bindLists; + Lib::Stack _bindLists; /** various tokens to consume */ - Stack _tags; + Lib::Stack _tags; /** various formulas */ - Stack _formulas; + Lib::Stack _formulas; /** various literals */ - Stack _literals; + Lib::Stack _literals; /** term lists */ - Stack _termLists; + Lib::Stack _termLists; /** name table for variable names */ - IntNameTable _vars; + Lib::IntNameTable _vars; /** When parsing a question, make note of the inverse mapping to _vars, i.e. from the ints back to the vstrings, for better user reporting */ - Map _curQuestionVarNames; + Lib::Map _curQuestionVarNames; /** parsed types */ - Stack _types; + Lib::Stack _types; /** various type tags saved during parsing */ - Stack _typeTags; + Lib::Stack _typeTags; /** */ - Stack _theoryFunctions; + Lib::Stack _theoryFunctions; /** bindings of variables to sorts */ - Map _variableSorts; + Lib::Map _variableSorts; /** overflown arithmetical constants for which uninterpreted constants are introduced */ - Set _overflow; + Lib::Set _overflow; /** current color, if the input contains colors */ Color _currentColor; /** a robsubstitution object to be used temporarily that is kept around to safe memory allocation time */ @@ -625,11 +624,11 @@ class TPTP typedef std::pair LetSymbol; /** a scope of function definitions */ - typedef Stack LetSymbols; + typedef Lib::Stack LetSymbols; /** a stack of scopes */ - Stack _letSymbols; - Stack _letTypedSymbols; + Lib::Stack _letSymbols; + Lib::Stack _letTypedSymbols; /** Record wheter a formula or term has been pushed more recently */ LastPushed _lastPushed; @@ -638,8 +637,8 @@ class TPTP bool findLetSymbol(LetSymbolName symbolName, LetSymbolReference& symbolReference); bool findLetSymbol(LetSymbolName symbolName, LetSymbols scope, LetSymbolReference& symbolReference); - typedef Stack LetDefinitions; - Stack _letDefinitions; + typedef Lib::Stack LetDefinitions; + Lib::Stack _letDefinitions; /** model definition formula */ bool _modelDefinition; @@ -818,10 +817,10 @@ class TPTP public: // make the tptp routines for dealing with overflown constants available to other parsers - static unsigned addIntegerConstant(const std::string&, Set& overflow, bool defaultSort); - static unsigned addRationalConstant(const std::string&, Set& overflow, bool defaultSort); - static unsigned addRealConstant(const std::string&, Set& overflow, bool defaultSort); - static unsigned addUninterpretedConstant(const std::string& name, Set& overflow, bool& added); + static unsigned addIntegerConstant(const std::string&, Lib::Set& overflow, bool defaultSort); + static unsigned addRationalConstant(const std::string&, Lib::Set& overflow, bool defaultSort); + static unsigned addRealConstant(const std::string&, Lib::Set& overflow, bool defaultSort); + static unsigned addUninterpretedConstant(const std::string& name, Lib::Set& overflow, bool& added); // also here, simply made public static to share the code with another use site static Unit* processClaimFormula(Unit* unit, Formula* f, const std::string& nm); @@ -842,12 +841,12 @@ class TPTP }; struct InferenceSourceRecord : SourceRecord{ const std::string name; - Stack premises; + Lib::Stack premises; bool isFile(){ return false; } InferenceSourceRecord(std::string n) : name(n) {} }; - void setUnitSourceMap(DHMap* m){ + void setUnitSourceMap(Lib::DHMap* m){ _unitSources = m; } SourceRecord* getSource(); @@ -855,11 +854,11 @@ class TPTP void setFilterReserved(){ _filterReserved=true; } private: - DHMap* _unitSources; + Lib::DHMap* _unitSources; /** This field stores names of input units if the * output_axiom_names option is enabled */ - static DHMap _axiomNames; + static Lib::DHMap _axiomNames; /** * During question parsing, we store the mapping from int variables @@ -870,11 +869,11 @@ class TPTP * * (Can there be more than one question? Yes, e.g., in the interactive mode.) */ - static DHMap*> _questionVariableNames; + static Lib::DHMap*> _questionVariableNames; /** Stores the type arities of function symbols */ - DHMap _typeArities; - DHMap _typeConstructorArities; + Lib::DHMap _typeArities; + Lib::DHMap _typeConstructorArities; bool _filterReserved; bool _seenConjecture; diff --git a/SAT/BufferedSolver.hpp b/SAT/BufferedSolver.hpp index 690f54caa..063525ab7 100644 --- a/SAT/BufferedSolver.hpp +++ b/SAT/BufferedSolver.hpp @@ -31,7 +31,6 @@ namespace SAT { -using namespace Lib; class BufferedSolver : public SATSolver { public: @@ -79,12 +78,12 @@ class BufferedSolver : public SATSolver { // Add any clauses that have been buffered to _inner and solve. void flushUnadded(); - ScopedPtr _inner; + Lib::ScopedPtr _inner; /** * A buffer for new literals that do not yet appear in the solver */ - DHMap _literalBuffer; + Lib::DHMap _literalBuffer; /** * Clauses that have not been added to _inner as they are either implied by the assignment of _inner diff --git a/SAT/FallbackSolverWrapper.cpp b/SAT/FallbackSolverWrapper.cpp index abe22a60a..ebc8b039b 100644 --- a/SAT/FallbackSolverWrapper.cpp +++ b/SAT/FallbackSolverWrapper.cpp @@ -54,7 +54,7 @@ SATSolver::Status FallbackSolverWrapper::solve(unsigned conflictCountLimit) status = _fallback->solve(conflictCountLimit); _usingFallback = true; ASS(status != Status::UNKNOWN); - env.statistics->smtFallbacks++; + Lib::env.statistics->smtFallbacks++; } else{ _usingFallback = false; diff --git a/SAT/FallbackSolverWrapper.hpp b/SAT/FallbackSolverWrapper.hpp index dc697faf9..29c20fc0c 100644 --- a/SAT/FallbackSolverWrapper.hpp +++ b/SAT/FallbackSolverWrapper.hpp @@ -33,7 +33,6 @@ namespace SAT { -using namespace Lib; class FallbackSolverWrapper : public SATSolver { public: @@ -105,8 +104,8 @@ class FallbackSolverWrapper : public SATSolver { private: - ScopedPtr _inner; - ScopedPtr _fallback; + Lib::ScopedPtr _inner; + Lib::ScopedPtr _fallback; bool _usingFallback; diff --git a/SAT/MinimizingSolver.cpp b/SAT/MinimizingSolver.cpp index 6319150bd..c925aa878 100644 --- a/SAT/MinimizingSolver.cpp +++ b/SAT/MinimizingSolver.cpp @@ -19,6 +19,8 @@ namespace SAT { +using namespace Lib; + MinimizingSolver::MinimizingSolver(SATSolver* inner) : _varCnt(0), _inner(inner), _assignmentValid(false), _heap(CntComparator(_unsClCnt)) { diff --git a/SAT/MinimizingSolver.hpp b/SAT/MinimizingSolver.hpp index 47e903b2c..839bf211e 100644 --- a/SAT/MinimizingSolver.hpp +++ b/SAT/MinimizingSolver.hpp @@ -32,7 +32,6 @@ namespace SAT { -using namespace Lib; class MinimizingSolver : public SATSolver { public: @@ -88,7 +87,7 @@ class MinimizingSolver : public SATSolver { void updateAssignment(); unsigned _varCnt; - ScopedPtr _inner; + Lib::ScopedPtr _inner; /** * If true, _asgn assignment corresponds to the assignment in @@ -111,7 +110,7 @@ class MinimizingSolver : public SATSolver { * We define a literal "corresponding to variable var in _asgn" * as SATLiteral(var,_asgn[var]). Used below. */ - DArray _asgn; + Lib::DArray _asgn; /** * Array of clauses made satisfied by giving up the don't-care value @@ -119,9 +118,9 @@ class MinimizingSolver : public SATSolver { * * The length of the array is _varCnt. */ - DArray _watcher; + Lib::DArray _watcher; - typedef DArray CntArray; + typedef Lib::DArray CntArray; /** * Number of unsatisfied clauses for each literal @@ -137,11 +136,11 @@ class MinimizingSolver : public SATSolver { { CntComparator(CntArray& ctr) : _ctr(ctr) {} - Comparison compare(unsigned v1, unsigned v2) + Lib::Comparison compare(unsigned v1, unsigned v2) { // DynamicHeap is minimal and we want maximum, // so we need to swap the arguments - return Int::compare(_ctr[v2], _ctr[v1]); + return Lib::Int::compare(_ctr[v2], _ctr[v1]); } CntArray& _ctr; }; @@ -151,7 +150,7 @@ class MinimizingSolver : public SATSolver { * * Heap is empty when _assignmentValid. */ - DynamicHeap > _heap; + Lib::DynamicHeap > _heap; /** * Not yet satisfied clauses indexed by each variable @@ -162,14 +161,14 @@ class MinimizingSolver : public SATSolver { * * The length of the array is _varCnt. */ - DArray _clIdx; + Lib::DArray _clIdx; /** * A set of satisfied clauses. To correctly maintain * _unsClCnt, when there is more than one way to make clause * satisfied. */ - DHSet _satisfiedClauses; + Lib::DHSet _satisfiedClauses; }; diff --git a/SAT/SAT2FO.hpp b/SAT/SAT2FO.hpp index cf5ad5a3b..de0c2ddbb 100644 --- a/SAT/SAT2FO.hpp +++ b/SAT/SAT2FO.hpp @@ -23,7 +23,6 @@ namespace SAT { -using namespace Lib; using namespace Kernel; /** @@ -49,7 +48,7 @@ class SAT2FO { void reset(){ _posMap.reset(); } friend std::ostream& operator<<(std::ostream& out, SAT2FO const& self); private: - typedef Numbering TwoWayMap; + typedef Lib::Numbering TwoWayMap; TwoWayMap _posMap; }; diff --git a/SAT/SATClause.hpp b/SAT/SATClause.hpp index 16a6a1c21..8c1d72ae9 100644 --- a/SAT/SATClause.hpp +++ b/SAT/SATClause.hpp @@ -27,7 +27,6 @@ namespace SAT { -using namespace Lib; using namespace Kernel; /** @@ -39,7 +38,7 @@ class SATClause public: DECL_ELEMENT_TYPE(SATLiteral); - auto iter() const { return arrayIter(*this); } + auto iter() const { return Lib::arrayIter(*this); } /** New clause */ SATClause(unsigned length); @@ -53,7 +52,7 @@ class SATClause unsigned defaultHash() const { unsigned hash = 0; for(unsigned i = 0; i < length(); i++) - hash ^= DefaultHash::hash(_literals[i]); + hash ^= Lib::DefaultHash::hash(_literals[i]); return hash; } diff --git a/SAT/SATInference.cpp b/SAT/SATInference.cpp index 0e2c06d3e..2c8eb8f37 100644 --- a/SAT/SATInference.cpp +++ b/SAT/SATInference.cpp @@ -22,6 +22,7 @@ namespace SAT { +using namespace Lib; /////////////////////// // SATInference // diff --git a/SAT/SATInference.hpp b/SAT/SATInference.hpp index 4e9b59929..f79eb8d43 100644 --- a/SAT/SATInference.hpp +++ b/SAT/SATInference.hpp @@ -70,9 +70,9 @@ class SATInference virtual InfType getType() const = 0; template - static void collectFilteredFOPremises(SATClause* cl, Stack& acc, Filter f); + static void collectFilteredFOPremises(SATClause* cl, Lib::Stack& acc, Filter f); - static void collectFOPremises(SATClause* cl, Stack& acc); + static void collectFOPremises(SATClause* cl, Lib::Stack& acc); static void collectPropAxioms(SATClause* cl, SATClauseStack& res); @@ -135,12 +135,12 @@ class AssumptionInference : public SATInference * Only consider those SATClauses and their parents which pass the given Filter f. */ template -void SATInference::collectFilteredFOPremises(SATClause* cl, Stack& acc, Filter f) +void SATInference::collectFilteredFOPremises(SATClause* cl, Lib::Stack& acc, Filter f) { ASS_ALLOC_TYPE(cl, "SATClause"); - static Stack toDo; - static DHSet seen; + static Lib::Stack toDo; + static Lib::DHSet seen; toDo.reset(); seen.reset(); diff --git a/SAT/SATLiteral.hpp b/SAT/SATLiteral.hpp index 0db9fcbd5..79ff9ad38 100644 --- a/SAT/SATLiteral.hpp +++ b/SAT/SATLiteral.hpp @@ -55,7 +55,7 @@ class SATLiteral inline unsigned oppositePolarity() const { return 1-_polarity; } inline unsigned content() const { return _content; } - unsigned defaultHash() const { return DefaultHash::hash(content()); } + unsigned defaultHash() const { return Lib::DefaultHash::hash(content()); } unsigned defaultHash2() const { return content(); } inline SATLiteral opposite() const { return SATLiteral(content()^1); } diff --git a/SAT/SATSolver.hpp b/SAT/SATSolver.hpp index daebdaa04..2911354af 100644 --- a/SAT/SATSolver.hpp +++ b/SAT/SATSolver.hpp @@ -140,7 +140,7 @@ class SATSolver { */ virtual void randomizeForNextAssignment(unsigned maxVar) { for (unsigned var=1; var <= maxVar; var++) { - suggestPolarity(var,Random::getBit()); + suggestPolarity(var,Lib::Random::getBit()); } } @@ -308,7 +308,7 @@ class SATSolverWithAssumptions: // randomly permute the content of _failedAssumptionBuffer // not to bias minimization from one side or another for(unsigned i=sz-1; i>0; i--) { - unsigned tgtPos=Random::getInteger(i+1); + unsigned tgtPos=Lib::Random::getInteger(i+1); std::swap(_failedAssumptionBuffer[i], _failedAssumptionBuffer[tgtPos]); } } diff --git a/SAT/Z3Interfacing.hpp b/SAT/Z3Interfacing.hpp index 2e023a244..474b92859 100644 --- a/SAT/Z3Interfacing.hpp +++ b/SAT/Z3Interfacing.hpp @@ -46,7 +46,7 @@ namespace SAT{ - struct UninterpretedForZ3Exception : public ThrowableBase + struct UninterpretedForZ3Exception : public Lib::ThrowableBase { UninterpretedForZ3Exception() { @@ -178,8 +178,8 @@ class Z3Interfacing : public PrimitiveProofRecordingSATSolver out << (self.isPredicate ? "pred " : "func "); out << ( self.isPredicate - ? env.signature->getPredicate(self.id)->name() - : env.signature->getFunction(self.id)->name() + ? Lib::env.signature->getPredicate(self.id)->name() + : Lib::env.signature->getFunction(self.id)->name() ); if(self.forSorts) for(unsigned i = 0; i < self.forSorts->numTypeArguments(); i++) @@ -190,16 +190,16 @@ class Z3Interfacing : public PrimitiveProofRecordingSATSolver private: - Map _sorts; + Lib::Map _sorts; struct Z3Hash { static unsigned hash(z3::func_decl const& c) { return c.hash(); } static unsigned hash(z3::expr const& c) { return c.hash(); } static bool equals(z3::func_decl const& l, z3::func_decl const& r) { return z3::eq(l,r); } static bool equals(z3::expr const& l, z3::expr const& r) { return z3::eq(l,r); } }; - Map _fromZ3; - Map _toZ3; - Set _createdTermAlgebras; + Lib::Map _fromZ3; + Lib::Map _toZ3; + Lib::Set _createdTermAlgebras; z3::func_decl const& findConstructor(Term* t); void createTermAlgebra(TermList sort); @@ -220,10 +220,10 @@ class Z3Interfacing : public PrimitiveProofRecordingSATSolver struct Representation { - Representation(z3::expr expr, Stack defs) : expr(expr), defs(defs) {} + Representation(z3::expr expr, Lib::Stack defs) : expr(expr), defs(defs) {} Representation(Representation&&) = default; z3::expr expr; - Stack defs; + Lib::Stack defs; }; Representation getRepresentation(Term* trm); @@ -241,14 +241,14 @@ class Z3Interfacing : public PrimitiveProofRecordingSATSolver z3::context _context; z3::solver _solver; z3::model _model; - Stack _assumptions; - BiMap _assumptionLookup; + Lib::Stack _assumptions; + Lib::BiMap _assumptionLookup; const bool _showZ3; const bool _unsatCore; - Option _out; - Map _varNames; - Map _termIndexedConstants; - Map _constantNames; + Lib::Option _out; + Lib::Map _varNames; + Lib::Map _termIndexedConstants; + Lib::Map _constantNames; bool isNamedExpr(unsigned var) const; z3::expr getNameExpr(unsigned var); diff --git a/SAT/Z3MainLoop.hpp b/SAT/Z3MainLoop.hpp index 00562c8b3..a415bbaaf 100644 --- a/SAT/Z3MainLoop.hpp +++ b/SAT/Z3MainLoop.hpp @@ -33,7 +33,6 @@ namespace SAT{ using namespace Kernel; using namespace Shell; -using namespace Lib; class Z3MainLoop : public MainLoop { diff --git a/SATSubsumption/SATSubsumptionAndResolution.cpp b/SATSubsumption/SATSubsumptionAndResolution.cpp index aac8d233b..32fb34d05 100644 --- a/SATSubsumption/SATSubsumptionAndResolution.cpp +++ b/SATSubsumption/SATSubsumptionAndResolution.cpp @@ -85,6 +85,7 @@ using namespace Indexing; using namespace Kernel; using namespace SATSubsumption; using namespace std; +using namespace Lib; const unsigned INVALID = std::numeric_limits::max(); diff --git a/SATSubsumption/SATSubsumptionAndResolution.hpp b/SATSubsumption/SATSubsumptionAndResolution.hpp index b1133f76e..add8aa7b1 100644 --- a/SATSubsumption/SATSubsumptionAndResolution.hpp +++ b/SATSubsumption/SATSubsumptionAndResolution.hpp @@ -160,10 +160,10 @@ class SATSubsumptionAndResolution { * @param i the index of the row * @return a slice of the matches at row i */ - Slice getIMatches(unsigned i) + Lib::Slice getIMatches(unsigned i) { ASS_L(i, _indexI.size()) - return Slice( + return Lib::Slice( &_matchesByI[_indexI[i]], &_matchesByI[_indexI[i + 1]]); } @@ -173,10 +173,10 @@ class SATSubsumptionAndResolution { * @param j the index of the column * @return a slice of the matches at column j */ - Slice getJMatches(unsigned j) + Lib::Slice getJMatches(unsigned j) { ASS_L(j, _indexJ.size()) - return Slice( + return Lib::Slice( &_matchesByJ[_indexJ[j]], &_matchesByJ[_indexJ[j + 1]]); } diff --git a/SATSubsumption/subsat/SubstitutionTheory.hpp b/SATSubsumption/subsat/SubstitutionTheory.hpp index c0e6ea57f..aaa511bd8 100644 --- a/SATSubsumption/subsat/SubstitutionTheory.hpp +++ b/SATSubsumption/subsat/SubstitutionTheory.hpp @@ -365,7 +365,7 @@ class SubstitutionTheory final // TODO: replace bindings_by_pos by a single contiguous vector, and instead of VampireVarPos; use an index/length into that vector. // (probably only makes sense if we construct that data lazily? in the current version we'd need an extra loop to determine counts for each variable first.) // OTOH the current version isn't that bad, since we do map the vampire variables into a contiguous range first. so the vectors in m_bindings_by_pos are being reused anyway. - Lib::DHMap m_var_pos; + Lib::DHMap m_var_pos; vector_map>> m_bindings_by_pos; }; diff --git a/Saturation/AWPassiveClauseContainer.hpp b/Saturation/AWPassiveClauseContainer.hpp index f9a6b9f53..b0133bb14 100644 --- a/Saturation/AWPassiveClauseContainer.hpp +++ b/Saturation/AWPassiveClauseContainer.hpp @@ -80,7 +80,7 @@ class AWPassiveClauseContainer unsigned sizeEstimate() const override { return _size; } - static Comparison compareWeight(Clause* cl1, Clause* cl2, const Shell::Options& opt); + static Lib::Comparison compareWeight(Clause* cl1, Clause* cl2, const Shell::Options& opt); private: /** The age queue, empty if _ageRatio=0 */ diff --git a/Saturation/ClauseContainer.cpp b/Saturation/ClauseContainer.cpp index 3501e95f2..1e32bf9df 100644 --- a/Saturation/ClauseContainer.cpp +++ b/Saturation/ClauseContainer.cpp @@ -32,6 +32,7 @@ using namespace std; namespace Saturation { +using namespace Lib; using namespace Kernel; using namespace Indexing; diff --git a/Saturation/ClauseContainer.hpp b/Saturation/ClauseContainer.hpp index 42043ed66..b9499b125 100644 --- a/Saturation/ClauseContainer.hpp +++ b/Saturation/ClauseContainer.hpp @@ -32,7 +32,6 @@ namespace Saturation { -using namespace Lib; using namespace Kernel; using namespace Shell; @@ -78,7 +77,7 @@ class RandomAccessClauseContainer virtual void onLimitsUpdated() {} private: SaturationAlgorithm* _salg; - SubscriptionData _limitChangeSData; + Lib::SubscriptionData _limitChangeSData; }; class PlainClauseContainer : public ClauseContainer { @@ -101,10 +100,10 @@ class UnprocessedClauseContainer bool isEmpty() const { return _data.isEmpty(); } private: - Deque _data; + Lib::Deque _data; }; -typedef PlainEvent LimitsChangeEvent; +typedef Lib::PlainEvent LimitsChangeEvent; class PassiveClauseContainer : public RandomAccessClauseContainer @@ -179,7 +178,7 @@ class ActiveClauseContainer protected: void onLimitsUpdated() override; private: - Set _clauses; + Lib::Set _clauses; // const Shell::Options& _opt; }; diff --git a/Saturation/ConsequenceFinder.hpp b/Saturation/ConsequenceFinder.hpp index 8467f612b..06efb7467 100644 --- a/Saturation/ConsequenceFinder.hpp +++ b/Saturation/ConsequenceFinder.hpp @@ -57,24 +57,24 @@ class ConsequenceFinder { SaturationAlgorithm* _sa; - Stack _redundantsToHandle; + Lib::Stack _redundantsToHandle; - typedef SkipList ClauseSL; + typedef Lib::SkipList ClauseSL; /** Index of clauses that contain specific consequence-finding * name predicate */ - ZIArray _index; + Lib::ZIArray _index; /** Keeps information on which claims have already been found * redundant (implied by others) */ - ZIArray _redundant; + Lib::ZIArray _redundant; TautologyDeletionISE _td; DuplicateLiteralRemovalISE _dlr; /** SubscriptionData for the @b onClauseInserted method */ - SubscriptionData _sdInsertion; + Lib::SubscriptionData _sdInsertion; /** SubscriptionData for the @b onClauseRemoved method */ - SubscriptionData _sdRemoval; + Lib::SubscriptionData _sdRemoval; }; } diff --git a/Saturation/ExtensionalityClauseContainer.cpp b/Saturation/ExtensionalityClauseContainer.cpp index bbc55bb31..4848c97b2 100644 --- a/Saturation/ExtensionalityClauseContainer.cpp +++ b/Saturation/ExtensionalityClauseContainer.cpp @@ -20,6 +20,7 @@ namespace Saturation { using namespace std; +using namespace Lib; using namespace Shell; /** diff --git a/Saturation/ExtensionalityClauseContainer.hpp b/Saturation/ExtensionalityClauseContainer.hpp index 49a873460..f7a98ed6b 100644 --- a/Saturation/ExtensionalityClauseContainer.hpp +++ b/Saturation/ExtensionalityClauseContainer.hpp @@ -39,9 +39,9 @@ struct ExtensionalityClause TermList sort; }; -typedef List ExtensionalityClauseList; -typedef VirtualIterator ExtensionalityClauseIterator; -typedef DHMap ClausesBySort; +typedef Lib::List ExtensionalityClauseList; +typedef Lib::VirtualIterator ExtensionalityClauseIterator; +typedef Lib::DHMap ClausesBySort; /** * Container for tracking extensionality-like clauses, i.e. clauses with exactly * one positive equality between variables. diff --git a/Saturation/LabelFinder.hpp b/Saturation/LabelFinder.hpp index 86950ec19..f63b1313c 100644 --- a/Saturation/LabelFinder.hpp +++ b/Saturation/LabelFinder.hpp @@ -36,11 +36,11 @@ class LabelFinder { void onNewPropositionalClause(Clause* cl); - Stack getFoundLabels(){ return _foundLabels;} + Lib::Stack getFoundLabels(){ return _foundLabels;} private: - Stack _foundLabels; + Lib::Stack _foundLabels; }; diff --git a/Saturation/SaturationAlgorithm.hpp b/Saturation/SaturationAlgorithm.hpp index 8865225f1..22cf7bd22 100644 --- a/Saturation/SaturationAlgorithm.hpp +++ b/Saturation/SaturationAlgorithm.hpp @@ -44,7 +44,6 @@ namespace Shell { class AnswerLiteralManager; } namespace Saturation { -using namespace Lib; using namespace Kernel; using namespace Indexing; using namespace Inferences; @@ -169,7 +168,7 @@ class SaturationAlgorithm : public MainLoop void handleEmptyClause(Clause* cl); Clause* doImmediateSimplification(Clause* cl); MainLoopResult saturateImpl(); - SmartPtr _imgr; + Lib::SmartPtr _imgr; class TotalSimplificationPerformer; class PartialSimplificationPerformer; @@ -192,24 +191,24 @@ class SaturationAlgorithm : public MainLoop ActiveClauseContainer* _active; ExtensionalityClauseContainer* _extensionality; - ScopedPtr _generator; - ScopedPtr _immediateSimplifier; + Lib::ScopedPtr _generator; + Lib::ScopedPtr _immediateSimplifier; - typedef List FwSimplList; + typedef Lib::List FwSimplList; FwSimplList* _fwSimplifiers; //Simplification occurs at the same point in the loop //as forward and backward simplification, but does not involve //clauses in active. At the moment, the only simplification inference //is the higher-order cnfOnTheFly - typedef List SimplList; + typedef Lib::List SimplList; SimplList* _simplifiers; - typedef List BwSimplList; + typedef Lib::List BwSimplList; BwSimplList* _bwSimplifiers; OrderingSP _ordering; - ScopedPtr _selector; + Lib::ScopedPtr _selector; Splitter* _splitter; @@ -221,8 +220,8 @@ class SaturationAlgorithm : public MainLoop FunctionDefinitionHandler& _fnDefHandler; std::unique_ptr _conditionalRedundancyHandler; - SubscriptionData _passiveContRemovalSData; - SubscriptionData _activeContRemovalSData; + Lib::SubscriptionData _passiveContRemovalSData; + Lib::SubscriptionData _activeContRemovalSData; /** * Literal selector for set-of-support. @@ -230,7 +229,7 @@ class SaturationAlgorithm : public MainLoop * This variable is initialized and used only by the * @c getSosLiteralSelector() function */ - ScopedPtr _sosLiteralSelector; + Lib::ScopedPtr _sosLiteralSelector; // counters diff --git a/Saturation/Splitter.hpp b/Saturation/Splitter.hpp index 309bc98c0..39e251b4b 100644 --- a/Saturation/Splitter.hpp +++ b/Saturation/Splitter.hpp @@ -41,14 +41,13 @@ namespace Saturation { -using namespace Lib; using namespace Kernel; using namespace Shell; using namespace SAT; using namespace DP; using namespace Indexing; -typedef Stack SplitLevelStack; +typedef Lib::Stack SplitLevelStack; class Splitter; @@ -97,10 +96,10 @@ _solver=0; Splitter& _parent; bool _solverIsSMT; - ScopedPtr _solver; - ScopedPtr _dp; + Lib::ScopedPtr _solver; + Lib::ScopedPtr _dp; // use a separate copy of the decision procedure for ccModel computations and fill it up only with equalities - ScopedPtr _dpModel; + Lib::ScopedPtr _dpModel; /** * Contains selected component names (splitlevels) @@ -166,8 +165,8 @@ class Splitter { Clause* component; RCClauseStack children; - Stack reduced; - Stack conditionalRedundancyEntries; + Lib::Stack reduced; + Lib::Stack conditionalRedundancyEntries; bool active; USE_ALLOCATOR(SplitRecord); @@ -209,7 +208,7 @@ class Splitter { SAT2FO& satNaming() { return _sat2fo; } UnitList* preprendCurrentlyAssumedComponentClauses(UnitList* clauses); - static bool getComponents(Clause* cl, Stack& acc, bool shuffle = false); + static bool getComponents(Clause* cl, Lib::Stack& acc, bool shuffle = false); /* * Clauses with answer literals cannot be split -- hence if we obtain a clause with @@ -263,7 +262,7 @@ class Splitter { //utility objects SplittingBranchSelector _branchSelector; - ScopedPtr _componentIdx; + Lib::ScopedPtr _componentIdx; /** * Registers all the sat variables and keeps track * of associated ground literals for those variables @@ -278,13 +277,13 @@ class Splitter { * Invariant: if there is a clause with a level in its splitting history, * the _db record of this level is non-null. */ - Stack _db; + Lib::Stack _db; /** * Definitions of ground components C and ~C are shared and placed at the slot of C. * (So the key here is never odd!) **/ - DHMap _defs; + Lib::DHMap _defs; //state variable used for flushing: /** When this number of generated clauses is reached, it will cause flush */ @@ -313,7 +312,7 @@ class Splitter { // clauses we already added to the SAT solver // not just optimisation: also prevents the SAT solver oscillating between two models in some cases - Set> _already_added; + Lib::Set> _already_added; public: static std::string splPrefix; diff --git a/Saturation/SymElOutput.hpp b/Saturation/SymElOutput.hpp index 26fee0302..690e241d5 100644 --- a/Saturation/SymElOutput.hpp +++ b/Saturation/SymElOutput.hpp @@ -23,7 +23,6 @@ namespace Saturation { -using namespace Lib; using namespace Kernel; using namespace Shell; @@ -63,7 +62,7 @@ class SymElOutput { * It is used so that we output symbol eliminating clauses * after they are simplified and shown to be non-redundant. */ - DHMap _symElRewrites; + Lib::DHMap _symElRewrites; /** * Contains record of colors that were aliminated in @@ -71,7 +70,7 @@ class SymElOutput { * * Is reset in the call to the @b onAllProcessed method. */ - DHMap _symElColors; + Lib::DHMap _symElColors; SaturationAlgorithm* _sa; diff --git a/Shell/AnswerLiteralManager.cpp b/Shell/AnswerLiteralManager.cpp index 2572a386b..bf8453ec7 100644 --- a/Shell/AnswerLiteralManager.cpp +++ b/Shell/AnswerLiteralManager.cpp @@ -45,6 +45,7 @@ #include "AnswerLiteralManager.hpp" static bool isProperAnswerClause(Clause* cl) { + using namespace Lib; static bool ground_only = (env.options->questionAnswering() == Options::QuestionAnsweringMode::PLAIN) && (env.options->questionAnsweringGroundOnly()); return !cl->isEmpty() && forAll(cl->iterLits(),[] (Literal* l) { return l->isAnswerLiteral() && (!ground_only || l->ground()); } ); @@ -53,6 +54,8 @@ static bool isProperAnswerClause(Clause* cl) { namespace Inferences { +using namespace Lib; + Clause* AnswerLiteralResolver::simplify(Clause* cl) { if (isProperAnswerClause(cl)) { diff --git a/Shell/AnswerLiteralManager.hpp b/Shell/AnswerLiteralManager.hpp index 26fa1f0fd..d28d2fb48 100644 --- a/Shell/AnswerLiteralManager.hpp +++ b/Shell/AnswerLiteralManager.hpp @@ -47,7 +47,6 @@ class AnswerLiteralResolver namespace Shell { -using namespace Lib; using namespace Kernel; using namespace Indexing; @@ -57,7 +56,7 @@ class AnswerLiteralManager friend class Inferences::AnswerLiteralResolver; /** * There should be at most one AnswerLiteralManager instance in the whole wide world. - * Depending on env.options this will be + * Depending on Lib::env.options this will be * - either AnswerLiteralManager proper (for QuestionAnsweringMode::PLAIN) * - or a SynthesisALManager (for QuestionAnsweringMode::SYNTHESIS) */ @@ -67,7 +66,7 @@ class AnswerLiteralManager virtual ~AnswerLiteralManager() {} - virtual bool tryGetAnswer(Clause* refutation, Stack& answer); + virtual bool tryGetAnswer(Clause* refutation, Lib::Stack& answer); void addAnswerLiterals(Problem& prb); bool addAnswerLiterals(UnitList*& units); @@ -113,11 +112,11 @@ class AnswerLiteralManager * (which, in particular, has the variables for arguments * as they were in the conecture). */ - DHMap> _originUnitsAndInjectedLiterals; + Lib::DHMap> _originUnitsAndInjectedLiterals; - DHMap _resolverClauses; + Lib::DHMap _resolverClauses; - DHMap> _skolemsOrigin; + Lib::DHMap> _skolemsOrigin; }; class PlainALManager : public AnswerLiteralManager @@ -128,13 +127,13 @@ class PlainALManager : public AnswerLiteralManager void optionalAnswerPrefix(std::ostream& out) override; std::string postprocessAnswerString(std::string answer) override; private: - Stack> _skolemNames; + Lib::Stack> _skolemNames; }; class SynthesisALManager : public AnswerLiteralManager { public: - bool tryGetAnswer(Clause* refutation, Stack& answer) override; + bool tryGetAnswer(Clause* refutation, Lib::Stack& answer) override; void onNewClause(Clause* cl) override; Clause* recordAnswerAndReduce(Clause* cl) override; @@ -145,7 +144,7 @@ class SynthesisALManager : public AnswerLiteralManager void recordSkolemBinding(Term*,unsigned,std::string) override; private: - void getNeededUnits(Clause* refutation, ClauseStack& premiseClauses, Stack& conjectures, DHSet& allProofUnits); + void getNeededUnits(Clause* refutation, ClauseStack& premiseClauses, Lib::Stack& conjectures, Lib::DHSet& allProofUnits); class ConjectureSkolemReplacement : public TermTransformer { public: @@ -158,7 +157,7 @@ class SynthesisALManager : public AnswerLiteralManager private: std::map _skolemToVar; // Map from functions to predicates they represent in answer literal conditions - DHMap _condFnToPred; + Lib::DHMap _condFnToPred; }; Formula* getConditionFromClause(Clause* cl); @@ -170,9 +169,9 @@ class SynthesisALManager : public AnswerLiteralManager static unsigned getITEFunctionSymbol(TermList sort) { std::string name = "$ite_" + sort.toString(); bool added = false; - unsigned fn = env.signature->addFunction(name, 3, added); + unsigned fn = Lib::env.signature->addFunction(name, 3, added); if (added) { - Signature::Symbol* sym = env.signature->getFunction(fn); + Signature::Symbol* sym = Lib::env.signature->getFunction(fn); sym->setType(OperatorType::getFunctionType({AtomicSort::defaultSort(), sort, sort}, sort)); } return fn; @@ -180,7 +179,7 @@ class SynthesisALManager : public AnswerLiteralManager ConjectureSkolemReplacement _skolemReplacement; - List>>* _answerPairs = nullptr; + Lib::List>>* _answerPairs = nullptr; Literal* _lastAnsLit = nullptr; }; diff --git a/Shell/BlockedClauseElimination.hpp b/Shell/BlockedClauseElimination.hpp index 29f62c92b..9479db204 100644 --- a/Shell/BlockedClauseElimination.hpp +++ b/Shell/BlockedClauseElimination.hpp @@ -50,8 +50,8 @@ class BlockedClauseElimination }; struct CandidateComparator { - static Comparison compare(Candidate* c1, Candidate* c2) { - return Int::compare(c1->weight,c2->weight); + static Lib::Comparison compare(Candidate* c1, Candidate* c2) { + return Lib::Int::compare(c1->weight,c2->weight); } }; @@ -60,7 +60,7 @@ class BlockedClauseElimination Clause* cl; // the actual clause bool blocked; // if already blocked, don't need to try again - Stack toResurrect; // when getting block (effectively deleted, all these have a chance again) + Lib::Stack toResurrect; // when getting block (effectively deleted, all these have a chance again) ClWrapper(Clause* cl) : cl(cl), blocked(false) {} }; diff --git a/Shell/CNF.cpp b/Shell/CNF.cpp index bc1799f97..f8ae3bce5 100644 --- a/Shell/CNF.cpp +++ b/Shell/CNF.cpp @@ -21,6 +21,7 @@ #include "Kernel/FormulaUnit.hpp" #include "CNF.hpp" +using namespace Lib; using namespace Kernel; using namespace Shell; diff --git a/Shell/CNF.hpp b/Shell/CNF.hpp index f460f357d..c5afaacd0 100644 --- a/Shell/CNF.hpp +++ b/Shell/CNF.hpp @@ -27,7 +27,6 @@ namespace Kernel { class Literal; }; -using namespace Lib; using namespace Kernel; namespace Shell { @@ -40,7 +39,7 @@ class CNF { public: CNF(); - void clausify (Unit*,Stack& stack); + void clausify (Unit*,Lib::Stack& stack); private: void clausify(Formula*); // the original recurisive version (for documentation and reference) @@ -48,11 +47,11 @@ class CNF /** The unit currently being processed */ FormulaUnit* _unit; /** stack to collect the results */ - Stack* _result; + Lib::Stack* _result; /** stack of literals collected so far */ - Stack _literals; + Lib::Stack _literals; /** stack of formulas */ - Stack _formulas; + Lib::Stack _formulas; }; // class CNF } diff --git a/Shell/DistinctGroupExpansion.cpp b/Shell/DistinctGroupExpansion.cpp index 07a59bd7c..1997c248c 100644 --- a/Shell/DistinctGroupExpansion.cpp +++ b/Shell/DistinctGroupExpansion.cpp @@ -32,6 +32,7 @@ #include "DistinctGroupExpansion.hpp" using namespace std; +using namespace Lib; using namespace Shell; /** diff --git a/Shell/DistinctGroupExpansion.hpp b/Shell/DistinctGroupExpansion.hpp index 40fb1fb54..eeb49a91c 100644 --- a/Shell/DistinctGroupExpansion.hpp +++ b/Shell/DistinctGroupExpansion.hpp @@ -30,7 +30,7 @@ class DistinctGroupExpansion { void apply(Problem& prb); bool apply(UnitList*& units); - Formula* expand(Stack& constants); + Formula* expand(Lib::Stack& constants); private: unsigned _expandUpToSize; }; diff --git a/Shell/DistinctProcessor.cpp b/Shell/DistinctProcessor.cpp index 172a47b75..7304daf97 100644 --- a/Shell/DistinctProcessor.cpp +++ b/Shell/DistinctProcessor.cpp @@ -26,6 +26,8 @@ namespace Shell { +using namespace Lib; + //TODO: add expansion of non-top-level and negative distinct predicates /** diff --git a/Shell/DistinctProcessor.hpp b/Shell/DistinctProcessor.hpp index 1ec8a7b49..a9c1137a6 100644 --- a/Shell/DistinctProcessor.hpp +++ b/Shell/DistinctProcessor.hpp @@ -23,7 +23,6 @@ namespace Shell { using namespace Kernel; -using namespace Lib; /** * Registers top-level distinct predicates in the Signature. Should be diff --git a/Shell/EqResWithDeletion.hpp b/Shell/EqResWithDeletion.hpp index c41c695e5..ea37bf816 100644 --- a/Shell/EqResWithDeletion.hpp +++ b/Shell/EqResWithDeletion.hpp @@ -24,7 +24,6 @@ namespace Shell { -using namespace Lib; using namespace Kernel; class EqResWithDeletion @@ -42,7 +41,7 @@ class EqResWithDeletion /** The substitution induced by resolved inequalities * (It is reset with each clause). */ - DHMap _subst; + Lib::DHMap _subst; Literal* _ansLit = nullptr; }; diff --git a/Shell/EqualityProxy.hpp b/Shell/EqualityProxy.hpp index 1af04dd1c..53472326b 100644 --- a/Shell/EqualityProxy.hpp +++ b/Shell/EqualityProxy.hpp @@ -26,7 +26,6 @@ namespace Shell { -using namespace Lib; using namespace Kernel; // Polymorphic version of equality proxy transformation. @@ -65,8 +64,8 @@ class EqualityProxy void addLocalAxioms(UnitList*& units); void addAxioms(UnitList*& units); void addCongruenceAxioms(UnitList*& units); - void getArgumentEqualityLiterals(unsigned cnt, LiteralStack& lits, Stack& vars1, - Stack& vars2, OperatorType* symbolType); + void getArgumentEqualityLiterals(unsigned cnt, LiteralStack& lits, Lib::Stack& vars1, + Lib::Stack& vars2, OperatorType* symbolType); Literal* apply(Literal* lit); Literal* makeProxyLiteral(bool polarity, TermList arg0, TermList arg1, TermList sort); @@ -80,7 +79,7 @@ class EqualityProxy unsigned _proxyPredicate; /** array of proxy definitions E(x,y) <=> x = y */ - //static ZIArray s_proxyPremises; + //static Lib::ZIArray s_proxyPremises; Unit* _defUnit; }; diff --git a/Shell/EqualityProxyMono.hpp b/Shell/EqualityProxyMono.hpp index 16b65f47f..602381976 100644 --- a/Shell/EqualityProxyMono.hpp +++ b/Shell/EqualityProxyMono.hpp @@ -25,7 +25,6 @@ namespace Shell { -using namespace Lib; using namespace Kernel; // Monomorphic version of equality proxy transformation. @@ -64,8 +63,8 @@ class EqualityProxyMono void addLocalAxioms(UnitList*& units, TermList sort); void addAxioms(UnitList*& units); void addCongruenceAxioms(UnitList*& units); - bool getArgumentEqualityLiterals(unsigned cnt, LiteralStack& lits, Stack& vars1, - Stack& vars2, OperatorType* symbolType, bool skipSortsWithoutEquality); + bool getArgumentEqualityLiterals(unsigned cnt, LiteralStack& lits, Lib::Stack& vars1, + Lib::Stack& vars2, OperatorType* symbolType, bool skipSortsWithoutEquality); Literal* apply(Literal* lit); Literal* makeProxyLiteral(bool polarity, TermList arg0, TermList arg1, TermList sort); @@ -80,11 +79,11 @@ class EqualityProxyMono * Proxy predicate numbers for each sort (which can be a complex term, even in mono - think arrays) * but must be ground (and shared). */ - static DHMap s_proxyPredicates; + static Lib::DHMap s_proxyPredicates; /** equality proxy predicate sorts */ - static DHMap s_proxyPredicateSorts; + static Lib::DHMap s_proxyPredicateSorts; /** array of proxy definitions E(x,y) <=> x = y */ - static DHMap s_proxyPremises; + static Lib::DHMap s_proxyPremises; }; }; diff --git a/Shell/FOOLElimination.hpp b/Shell/FOOLElimination.hpp index 062d543b2..d09fa93c4 100644 --- a/Shell/FOOLElimination.hpp +++ b/Shell/FOOLElimination.hpp @@ -56,7 +56,7 @@ class FOOLElimination { void addDefinition(FormulaUnit* unit); /** Lexical scope of the current unit */ - DHMap _varSorts; + Lib::DHMap _varSorts; /** Process a given part of the unit */ FormulaList* process(FormulaList* fs); diff --git a/Shell/Flattening.cpp b/Shell/Flattening.cpp index 0dfdaefe5..4ff9a4e22 100644 --- a/Shell/Flattening.cpp +++ b/Shell/Flattening.cpp @@ -30,6 +30,8 @@ namespace Shell { +using namespace Lib; + /** * Assuming formula @c f is flattened, return its negation which is also flattened. */ diff --git a/Shell/FunctionDefinition.hpp b/Shell/FunctionDefinition.hpp index debbe5126..7edffeef7 100644 --- a/Shell/FunctionDefinition.hpp +++ b/Shell/FunctionDefinition.hpp @@ -34,7 +34,6 @@ namespace Shell { -using namespace Lib; using namespace Kernel; /** @@ -80,7 +79,7 @@ class FunctionDefinition bool isDefined(Term* t); - Term* applyDefinitions(Literal* t, Stack* usedDefs); + Term* applyDefinitions(Literal* t, Lib::Stack* usedDefs); Clause* applyDefinitions(Clause* cl); void checkDefinitions(Def* t); @@ -97,15 +96,15 @@ class FunctionDefinition // void apply (TermList& ls,UnitList& parents); // void apply (Term& l,UnitList& parents); - typedef DHMap Fn2DefMap; + typedef Lib::DHMap Fn2DefMap; Fn2DefMap _defs; /** stack where definitions are put when they're marked as blocked */ - Stack _blockedDefs; + Lib::Stack _blockedDefs; - Stack _safeDefs; + Lib::Stack _safeDefs; /** Counters for occurrences of function symbols */ - MultiCounter _counter; + Lib::MultiCounter _counter; /** The number of found definitions */ int _found; /** The number of removed definitions */ diff --git a/Shell/FunctionDefinitionHandler.hpp b/Shell/FunctionDefinitionHandler.hpp index 5165447ba..44d0d6481 100644 --- a/Shell/FunctionDefinitionHandler.hpp +++ b/Shell/FunctionDefinitionHandler.hpp @@ -24,7 +24,6 @@ namespace Shell { using namespace Indexing; using namespace Kernel; -using namespace Lib; /** * Corresponds to the branches of a function definition, @@ -98,7 +97,7 @@ class FunctionDefinitionHandler auto getGeneralizations(TypedTermList t) { if (_is.isEmpty()) { - return VirtualIterator>::getEmpty(); + return Lib::VirtualIterator>::getEmpty(); } return _is->getGeneralizations(t, true); } @@ -110,8 +109,8 @@ class FunctionDefinitionHandler } private: - ScopedPtr> _is; - DHMap, InductionTemplate> _templates; + Lib::ScopedPtr> _is; + Lib::DHMap, InductionTemplate> _templates; }; /** diff --git a/Shell/GoalGuessing.cpp b/Shell/GoalGuessing.cpp index fa78f6cdf..d5cae73b9 100644 --- a/Shell/GoalGuessing.cpp +++ b/Shell/GoalGuessing.cpp @@ -30,6 +30,7 @@ namespace Shell { using namespace std; +using namespace Lib; ////////////////////////// // GoalGuessing diff --git a/Shell/InequalitySplitting.hpp b/Shell/InequalitySplitting.hpp index ae8e47aeb..2d5d8df03 100644 --- a/Shell/InequalitySplitting.hpp +++ b/Shell/InequalitySplitting.hpp @@ -22,7 +22,6 @@ namespace Shell { -using namespace Lib; using namespace Kernel; @@ -43,7 +42,7 @@ class InequalitySplitting bool isSplittable(Literal* lit); bool isSplittableEqualitySide(TermList t); - Stack _predDefs; + Lib::Stack _predDefs; unsigned _splittingTreshold; bool _appify; // do it the higher-order way }; diff --git a/Shell/InterpolantMinimizer.cpp b/Shell/InterpolantMinimizer.cpp index e2cb56f0b..7760ba687 100644 --- a/Shell/InterpolantMinimizer.cpp +++ b/Shell/InterpolantMinimizer.cpp @@ -27,6 +27,7 @@ namespace Shell { using namespace std; + using namespace Lib; using namespace Kernel; std::unordered_map InterpolantMinimizer::computeSplittingFunction(Kernel::Unit* refutation, UnitWeight weightFunction) diff --git a/Shell/Interpolants.cpp b/Shell/Interpolants.cpp index bfdcd2222..59d8bdae1 100644 --- a/Shell/Interpolants.cpp +++ b/Shell/Interpolants.cpp @@ -64,6 +64,7 @@ namespace Shell { using namespace std; + using namespace Lib; using namespace Kernel; diff --git a/Shell/InterpretedNormalizer.cpp b/Shell/InterpretedNormalizer.cpp index 1542e011e..a8bb492d2 100644 --- a/Shell/InterpretedNormalizer.cpp +++ b/Shell/InterpretedNormalizer.cpp @@ -32,6 +32,7 @@ namespace Shell { using namespace std; +using namespace Lib; /** * Base term transforming class diff --git a/Shell/LambdaElimination.hpp b/Shell/LambdaElimination.hpp index f1a8e9c4a..7ca2f087c 100644 --- a/Shell/LambdaElimination.hpp +++ b/Shell/LambdaElimination.hpp @@ -32,7 +32,7 @@ class LambdaElimination { public: LambdaElimination() {}; -// LambdaElimination(DHMap varSorts) : _varSorts(varSorts){}; +// LambdaElimination(Lib::DHMap varSorts) : _varSorts(varSorts){}; /** Set of recursive functions that rconvert lambda terms to * combinatory terms and replace logical symbols by proxies. @@ -40,7 +40,7 @@ class LambdaElimination { */ TermList elimLambda(Term* lambdaTerm); TermList elimLambda(TermList term); - TermList elimLambda(Stack& vars, TermStack& sorts, TermList body, TermList sort); + TermList elimLambda(Lib::Stack& vars, TermStack& sorts, TermList body, TermList sort); TermList elimLambda(int var, TermList varSort, TermList body, TermList sort); TermList elimLambda(Formula*); @@ -66,21 +66,21 @@ class LambdaElimination { TermList sortOf(TermList t); - void addToProcessed(TermList ts, TermList sort, Stack &_argNums); + void addToProcessed(TermList ts, TermList sort, Lib::Stack &_argNums); void dealWithApp(Term* app, const unsigned lambdaVar, - TermStack &toBeProcessed, TermStack &sorts, Stack &argNums); + TermStack &toBeProcessed, TermStack &sorts, Lib::Stack &argNums); TermList createKTerm(TermList s1, TermList s2, TermList arg1); TermList createSCorBTerm(TermList arg1, TermList arg1sort, TermList arg2, TermList arg2sort, Signature::Combinator comb); - void process(Stack &vars, TermStack &varSorts, + void process(Lib::Stack &vars, TermStack &varSorts, TermStack &toBeProcessed, TermStack &sorts); /** Lexical scope of the current unit */ TermStack _processed; TermStack _processedSorts; - Stack _combinators; + Lib::Stack _combinators; }; #endif // __LambdaElimination__ diff --git a/Shell/Lexer.hpp b/Shell/Lexer.hpp index ddfdea0ac..2d0c1e974 100644 --- a/Shell/Lexer.hpp +++ b/Shell/Lexer.hpp @@ -24,7 +24,6 @@ #include "Token.hpp" -using namespace Lib; namespace Shell { @@ -36,7 +35,7 @@ class Lexer; * @since 14/07/2004 Turku */ class LexerException - : public ParsingRelatedException + : public Lib::ParsingRelatedException { public: LexerException(std::string message,const Lexer&); @@ -69,7 +68,7 @@ class Lexer /** Last read character */ int _lastCharacter; /** Character buffer, used to store currently read token */ - Array _charBuffer; + Lib::Array _charBuffer; /** cursor to the current character */ int _charCursor; /** the input stream */ diff --git a/Shell/LispParser.hpp b/Shell/LispParser.hpp index 005d424c5..15dbc2a16 100644 --- a/Shell/LispParser.hpp +++ b/Shell/LispParser.hpp @@ -27,7 +27,6 @@ namespace Shell { -using namespace Lib; class LispLexer; @@ -55,7 +54,7 @@ class LispParser /** the value (for atoms and numbers) */ std::string str; /** list of expressions */ - List* list; + Lib::List* list; /** build a list expressions with the list initially empty */ explicit Expression(Tag t) : tag(t), @@ -108,7 +107,7 @@ class LispParser }; // class LispParser typedef LispParser::Expression LExpr; -typedef List LExprList; +typedef Lib::List LExprList; class LispListReader { @@ -201,7 +200,7 @@ class LispListWriter ASS(!_destroyed); LExprList* res = 0; - LExprList::pushFromIterator(Stack::TopFirstIterator(_elements), res); + LExprList::pushFromIterator(Lib::Stack::TopFirstIterator(_elements), res); return res; } @@ -216,7 +215,7 @@ class LispListWriter #if VDEBUG bool _destroyed; #endif - Stack _elements; + Lib::Stack _elements; }; } diff --git a/Shell/NNF.cpp b/Shell/NNF.cpp index 24638be1a..8790a49eb 100644 --- a/Shell/NNF.cpp +++ b/Shell/NNF.cpp @@ -23,6 +23,7 @@ #include "NNF.hpp" +using namespace Lib; using namespace Kernel; using namespace Shell; diff --git a/Shell/NewCNF.hpp b/Shell/NewCNF.hpp index 3768efb08..6e5631d65 100644 --- a/Shell/NewCNF.hpp +++ b/Shell/NewCNF.hpp @@ -64,7 +64,7 @@ class NewCNF : _namingThreshold(namingThreshold), _iteInliningThreshold((unsigned)ceil(log2(namingThreshold))), _collectedVarSorts(false), _maxVar(0),_forInduction(false) {} - void clausify(FormulaUnit* unit, Stack& output); + void clausify(FormulaUnit* unit, Lib::Stack& output); void setForInduction(){ _forInduction=true; } private: unsigned _namingThreshold; @@ -81,11 +81,11 @@ class NewCNF * However, not merging distinct occurrences of a single subformula * from the input does not compromise correctness. */ - Deque _queue; + Lib::Deque _queue; typedef std::pair Binding; // used for skolem bindings of the form - typedef List BindingList; + typedef Lib::List BindingList; // all allocations of shared BindingLists should go via BindingStore so that they get destroyed in the end struct BindingStore { @@ -95,14 +95,14 @@ class NewCNF } void pushAndRememberWhileApplying(Binding b, BindingList* &lst); ~BindingStore() { - Stack::Iterator it(_stored); + Lib::Stack::Iterator it(_stored); while(it.hasNext()) { BindingList* cell = it.next(); delete cell; } } private: - Stack _stored; + Lib::Stack _stored; }; BindingStore _bindingStore; @@ -124,7 +124,7 @@ class NewCNF // generalized literal typedef std::pair GenLit; - typedef std::pair*> LPair; + typedef std::pair*> LPair; inline static Formula* &formula(GenLit &gl) { return gl.first; @@ -146,11 +146,11 @@ class NewCNF BindingList* foolBindings; // we could/should carry bindings on the GenLits-level; but GenClause seems sufficient as long as we are rectified - DArray _literals; // TODO: remove the extra indirection and allocate inside GenClause + Lib::DArray _literals; // TODO: remove the extra indirection and allocate inside GenClause unsigned _size; struct Iterator { - Iterator(DArray::Iterator iter, unsigned left) : _iter(iter), _left(left) {} + Iterator(Lib::DArray::Iterator iter, unsigned left) : _iter(iter), _left(left) {} bool hasNext() { if (_left == 0) return false; @@ -163,12 +163,12 @@ class NewCNF } private: - DArray::Iterator _iter; + Lib::DArray::Iterator _iter; unsigned _left; }; Iterator genLiterals() { - return Iterator(DArray::Iterator(_literals), _size); + return Iterator(Lib::DArray::Iterator(_literals), _size); } unsigned size() { @@ -176,9 +176,10 @@ class NewCNF } // Position of a gen literal in _genClauses - std::list>::iterator iter; + std::list>::iterator iter; std::string toString() { + using namespace Lib; std::string res = "GC("+Int::toString(size())+")"; if (!valid) { res += " [INVALID]"; @@ -203,10 +204,10 @@ class NewCNF } }; - typedef SmartPtr SPGenClause; + typedef Lib::SmartPtr SPGenClause; - void toClauses(SPGenClause gc, Stack& output); - bool mapSubstitution(List* gc, Substitution subst, bool onlyFormulaLevel, List* &output); + void toClauses(SPGenClause gc, Lib::Stack& output); + bool mapSubstitution(Lib::List* gc, Substitution subst, bool onlyFormulaLevel, Lib::List* &output); Clause* toClause(SPGenClause gc); typedef std::list GenClauses; @@ -225,8 +226,8 @@ class NewCNF * without it popping the first occurrence of a formula will invalidate the * entire generalised clause, and other occurrences will never be seen. */ - DHMap _literalsCache; - DHMap _formulasCache; + Lib::DHMap _literalsCache; + Lib::DHMap _formulasCache; inline void pushLiteral(SPGenClause gc, GenLit gl) { if (formula(gl)->connective() == LITERAL) { /** @@ -291,10 +292,10 @@ class NewCNF /** * Occurrences represents a list of occurrences in valid generalised clauses. - * Occurrences is used instead of an obvious List because it + * Occurrences is used instead of an obvious Lib::List because it * maintains a (1) convenient (2) constant time size() method. * - * (1) Occurrences maintains a List * _occurrences, where each + * (1) Occurrences maintains a Lib::List * _occurrences, where each * Occurrence points to a generalised clause which can become invalid. * We are only interested in occurrences in valid generalised clauses. * It wouldn't be enough to call _occurrences->length(), as it might @@ -311,7 +312,7 @@ class NewCNF */ class Occurrences { private: - List* _occurrences; + Lib::List* _occurrences; unsigned _size; public: @@ -322,23 +323,23 @@ class NewCNF unsigned size() { return _size; } inline void add(Occurrence occ) { - List::push(occ, _occurrences); + Lib::List::push(occ, _occurrences); _size++; } inline void append(Occurrences occs) { - _occurrences = List::concat(_occurrences, occs._occurrences); + _occurrences = Lib::List::concat(_occurrences, occs._occurrences); _size += occs.size(); } bool isNonEmpty() { while (true) { - if (List::isEmpty(_occurrences)) { + if (Lib::List::isEmpty(_occurrences)) { ASS_EQ(_size, 0); return false; } if (!_occurrences->head().gc->valid) { - List::pop(_occurrences); + Lib::List::pop(_occurrences); } else { ASS_G(_size, 0); return true; @@ -353,7 +354,7 @@ class NewCNF Occurrence pop() { ASS(isNonEmpty()); - Occurrence occ = List::pop(_occurrences); + Occurrence occ = Lib::List::pop(_occurrences); ASS(occ.gc->valid); _size--; ASS_GE(_size, 0); @@ -393,7 +394,7 @@ class NewCNF class Iterator { public: - Iterator(Occurrences &occurrences): _iterator(List::DelIterator(occurrences._occurrences)) {} + Iterator(Occurrences &occurrences): _iterator(Lib::List::DelIterator(occurrences._occurrences)) {} inline bool hasNext() { while (_iterator.hasNext()) { @@ -402,7 +403,7 @@ class NewCNF _iterator.del(); continue; } - _current = SmartPtr(new Occurrence(occ.gc, occ.position)); + _current = Lib::SmartPtr(new Occurrence(occ.gc, occ.position)); return true; } return false; @@ -411,18 +412,18 @@ class NewCNF return *_current; } private: - List::DelIterator _iterator; - SmartPtr _current; + Lib::List::DelIterator _iterator; + Lib::SmartPtr _current; }; }; - SPGenClause makeGenClause(List* gls, BindingList* bindings, BindingList* foolBindings) { - SPGenClause gc = SPGenClause(new GenClause(List::length(gls), bindings, foolBindings)); + SPGenClause makeGenClause(Lib::List* gls, BindingList* bindings, BindingList* foolBindings) { + SPGenClause gc = SPGenClause(new GenClause(Lib::List::length(gls), bindings, foolBindings)); ASS(_literalsCache.isEmpty()); ASS(_formulasCache.isEmpty()); - List::Iterator glit(gls); + Lib::List::Iterator glit(gls); while (glit.hasNext()) { pushLiteral(gc, glit.next()); } @@ -433,11 +434,11 @@ class NewCNF return gc; } - void introduceGenClause(List* gls, BindingList* bindings, BindingList* foolBindings) { + void introduceGenClause(Lib::List* gls, BindingList* bindings, BindingList* foolBindings) { SPGenClause gc = makeGenClause(gls, bindings, foolBindings); - if (gc->size() != List::length(gls)) { - LOG4("Eliminated", List::length(gls) - gc->size(), "duplicate literal(s) from", gc->toString()); + if (gc->size() != Lib::List::length(gls)) { + LOG4("Eliminated", Lib::List::length(gls) - gc->size(), "duplicate literal(s) from", gc->toString()); } if (gc->valid) { @@ -460,18 +461,18 @@ class NewCNF } void introduceGenClause(GenLit gl, BindingList* bindings=BindingList::empty(), BindingList* foolBindings=BindingList::empty()) { - introduceGenClause(new List(gl), bindings, foolBindings); + introduceGenClause(new Lib::List(gl), bindings, foolBindings); } void introduceGenClause(GenLit gl0, GenLit gl1, BindingList* bindings=BindingList::empty(), BindingList* foolBindings=BindingList::empty()) { - introduceGenClause(new List(gl0, new List(gl1)), bindings, foolBindings); + introduceGenClause(new Lib::List(gl0, new Lib::List(gl1)), bindings, foolBindings); } - void introduceExtendedGenClause(Occurrence occ, List* gls) { + void introduceExtendedGenClause(Occurrence occ, Lib::List* gls) { SPGenClause gc = occ.gc; unsigned position = occ.position; - unsigned size = gc->size() + List::length(gls) - 1; + unsigned size = gc->size() + Lib::List::length(gls) - 1; SPGenClause newGc = SPGenClause(new GenClause(size, gc->bindings, gc->foolBindings)); ASS(_literalsCache.isEmpty()); @@ -482,7 +483,7 @@ class NewCNF while (gcit.hasNext()) { GenLit gl = gcit.next(); if (i == position) { - List::Iterator glit(gls); + Lib::List::Iterator glit(gls); while (glit.hasNext()) { pushLiteral(newGc, glit.next()); } @@ -519,17 +520,17 @@ class NewCNF } void removeGenLit(Occurrence occ) { - introduceExtendedGenClause(occ, List::empty()); + introduceExtendedGenClause(occ, Lib::List::empty()); } void introduceExtendedGenClause(Occurrence occ, GenLit replacement) { // CHECK: leaking below? - introduceExtendedGenClause(occ, new List(replacement)); + introduceExtendedGenClause(occ, new Lib::List(replacement)); } void introduceExtendedGenClause(Occurrence occ, GenLit replacement, GenLit extension) { // CHECK: leaking below? - introduceExtendedGenClause(occ, new List(replacement, new List(extension))); + introduceExtendedGenClause(occ, new Lib::List(replacement, new Lib::List(extension))); } Occurrence pop(Occurrences &occurrences) { @@ -553,10 +554,10 @@ class NewCNF return occ; } - DHMap _occurrences; + Lib::DHMap _occurrences; /** map var --> sort */ - DHMap _varSorts; + Lib::DHMap _varSorts; bool _collectedVarSorts; unsigned _maxVar; @@ -567,20 +568,20 @@ class NewCNF bool _forInduction; // caching of free variables for subformulas - DHMap _freeVars; + Lib::DHMap _freeVars; VarSet* freeVars(Formula* g); // two level caching scheme for quantifier bindings // reset after skolemizing a particular subformula - DHMap _skolemsByBindings; - DHMap _skolemsByFreeVars; + Lib::DHMap _skolemsByBindings; + Lib::DHMap _skolemsByFreeVars; - DHMap _foolSkolemsByBindings; - DHMap _foolSkolemsByFreeVars; + Lib::DHMap _foolSkolemsByBindings; + Lib::DHMap _foolSkolemsByFreeVars; // caching binding substitutions for the final phase of GenClause -> Clause transformation // this saves time, because bindings are potentially shared - DHMap _substitutionsByBindings; + Lib::DHMap _substitutionsByBindings; void skolemise(QuantifiedFormula* g, BindingList* &bindings, BindingList*& foolBindings); @@ -634,10 +635,10 @@ class NewCNF TermList nameLetBinding(unsigned symbol, VList *bindingVariables, TermList binding, TermList contents); TermList inlineLetBinding(unsigned symbol, VList *bindingVariables, TermList binding, TermList contents); - TermList findITEs(TermList ts, Stack &variables, Stack &conditions, - Stack &thenBranches, Stack &elseBranches, - Stack &matchVariables, Stack*> &matchConditions, - Stack*> &matchBranches); + TermList findITEs(TermList ts, Lib::Stack &variables, Lib::Stack &conditions, + Lib::Stack &thenBranches, Lib::Stack &elseBranches, + Lib::Stack &matchVariables, Lib::Stack*> &matchConditions, + Lib::Stack*> &matchBranches); unsigned createFreshVariable(TermList sort); void createFreshVariableRenaming(unsigned oldVar, unsigned freshVar); diff --git a/Shell/Normalisation.cpp b/Shell/Normalisation.cpp index dc3a62a70..59b8c25a6 100644 --- a/Shell/Normalisation.cpp +++ b/Shell/Normalisation.cpp @@ -27,6 +27,7 @@ #include "Normalisation.hpp" +using namespace Lib; using namespace Kernel; using namespace Shell; diff --git a/Shell/Normalisation.hpp b/Shell/Normalisation.hpp index e4fe7d253..21636caf7 100644 --- a/Shell/Normalisation.hpp +++ b/Shell/Normalisation.hpp @@ -25,7 +25,6 @@ namespace Shell { -using namespace Lib; using namespace Kernel; /** @@ -42,19 +41,20 @@ class Normalisation bool lessThan(Unit*, Unit*); private: void normalise(Unit*); - Comparison compare(Term*, Term*); - Comparison compare(Formula*, Formula*); - Comparison compare(Literal*, Literal*); + Lib::Comparison compare(Term*, Term*); + Lib::Comparison compare(Formula*, Formula*); + Lib::Comparison compare(Literal*, Literal*); bool lessThan(Formula*, Formula*); bool lessThan(Clause*, Clause*); - Comparison compare(TermList ss, TermList ts); + Lib::Comparison compare(TermList ss, TermList ts); /** * Return the result of comparison of two integers i1 and i2 */ inline static - Comparison compare (int i1, int i2) + Lib::Comparison compare (int i1, int i2) { + using namespace Lib; return i1 > i2 ? GREATER : i1 == i2 @@ -63,16 +63,20 @@ class Normalisation } inline static - Comparison compare (unsigned i1, unsigned i2) - { return i1 > i2 ? GREATER : i1 == i2 ? EQUAL : LESS; } + Lib::Comparison compare (unsigned i1, unsigned i2) + { + using namespace Lib; + return i1 > i2 ? GREATER : i1 == i2 ? EQUAL : LESS; + } /** * Return the result of comparison of two booleans b1 and b2. * @since 30/04/2005 Manchester */ inline static - Comparison compare (bool b1, bool b2) + Lib::Comparison compare (bool b1, bool b2) { + using namespace Lib; return b1 ? (b2 ? EQUAL : LESS) : (b2 ? GREATER : EQUAL); } diff --git a/Shell/Options.hpp b/Shell/Options.hpp index c6b9d7633..5f44f2322 100644 --- a/Shell/Options.hpp +++ b/Shell/Options.hpp @@ -58,7 +58,6 @@ namespace Shell { -using namespace Lib; using namespace Kernel; class Property; @@ -81,7 +80,7 @@ static size_t distance(const std::string &s1, const std::string &s2) if( m==0 ) return n; if( n==0 ) return m; - DArray costs = DArray(n+1); + Lib::DArray costs = Lib::DArray(n+1); for( size_t k=0; k<=n; k++ ) costs[k] = k; @@ -777,8 +776,8 @@ class Options // The details are explained in comments below private: // helper function of sampleStrategy - void strategySamplingAssign(std::string optname, std::string value, DHMap& fakes); - std::string strategySamplingLookup(std::string optname, DHMap& fakes); + void strategySamplingAssign(std::string optname, std::string value, Lib::DHMap& fakes); + std::string strategySamplingLookup(std::string optname, Lib::DHMap& fakes); /** * These store the names of the choices for an option. @@ -797,7 +796,7 @@ class Options } public: OptionChoiceValues() : _names() { }; - OptionChoiceValues(Stack names) : _names(std::move(names)) + OptionChoiceValues(Lib::Stack names) : _names(std::move(names)) { check_names_are_short(); } @@ -817,7 +816,7 @@ class Options const std::string operator[](int i) const{ return _names[i];} private: - Stack _names; + Lib::Stack _names; }; // Declare constraints here so they can be referred to, but define them below @@ -930,7 +929,7 @@ class Options bool _should_copy; bool shouldCopy() const { return _should_copy; } - typedef std::unique_ptr> stringDArrayUP; + typedef std::unique_ptr> stringDArrayUP; typedef std::pair RandEntry; @@ -940,7 +939,7 @@ class Options Lib::Stack _modes; stringDArrayUP toArray(std::initializer_list& list){ - DArray* array = new DArray(list.size()); + Lib::DArray* array = new Lib::DArray(list.size()); unsigned index=0; for(typename std::initializer_list::iterator it = list.begin(); it!=list.end();++it){ (*array)[index++] =*it; } @@ -952,8 +951,9 @@ class Options }; struct AbstractOptionValueCompatator{ - Comparison compare(AbstractOptionValue* o1, AbstractOptionValue* o2) + Lib::Comparison compare(AbstractOptionValue* o1, AbstractOptionValue* o2) { + using namespace Lib; int value = strcmp(o1->longName.c_str(),o2->longName.c_str()); return value < 0 ? LESS : (value==0 ? EQUAL : GREATER); } @@ -1142,7 +1142,7 @@ class Options IntOptionValue(){} IntOptionValue(std::string l,std::string s, int d) : OptionValue(l,s,d){} bool setValue(const std::string& value){ - return Int::stringToInt(value.c_str(),actualValue); + return Lib::Int::stringToInt(value.c_str(),actualValue); } std::string getStringOfValue(int value) const{ return Lib::Int::toString(value); } }; @@ -1152,7 +1152,7 @@ class Options UnsignedOptionValue(std::string l,std::string s, unsigned d) : OptionValue(l,s,d){} bool setValue(const std::string& value){ - return Int::stringToUnsignedInt(value.c_str(),actualValue); + return Lib::Int::stringToUnsignedInt(value.c_str(),actualValue); } std::string getStringOfValue(unsigned value) const{ return Lib::Int::toString(value); } }; @@ -1174,7 +1174,7 @@ class Options LongOptionValue(){} LongOptionValue(std::string l,std::string s, long d) : OptionValue(l,s,d){} bool setValue(const std::string& value){ - return Int::stringToLong(value.c_str(),actualValue); + return Lib::Int::stringToLong(value.c_str(),actualValue); } std::string getStringOfValue(long value) const{ return Lib::Int::toString(value); } }; @@ -1183,7 +1183,7 @@ struct FloatOptionValue : public OptionValue{ FloatOptionValue(){} FloatOptionValue(std::string l,std::string s, float d) : OptionValue(l,s,d){} bool setValue(const std::string& value){ - return Int::stringToFloat(value.c_str(),actualValue); + return Lib::Int::stringToFloat(value.c_str(),actualValue); } std::string getStringOfValue(float value) const{ return Lib::Int::toString(value); } }; @@ -1868,7 +1868,7 @@ bool _hard; static OptionProblemConstraintUP hasTheories() { return OptionProblemConstraintUP(new HasTheories); } static OptionProblemConstraintUP hasGoal() { return OptionProblemConstraintUP(new HasGoal); } - //Cheating - we refer to env.options to ask about option values + //Cheating - we refer to Lib::env.options to ask about option values // There is an assumption that the option values used have been // set to their final values // These are used in randomisation where we guarantee a certain @@ -1887,7 +1887,7 @@ bool _hard; bool check(Property*p){ bool res = is_and; - Stack::RefIterator it(cons); + Lib::Stack::RefIterator it(cons); while(it.hasNext()){ bool n=it.next()->check(p);res = is_and ? (res && n) : (res || n);} return res; @@ -1895,14 +1895,14 @@ bool _hard; std::string msg(){ std::string res=""; - Stack::RefIterator it(cons); + Lib::Stack::RefIterator it(cons); if(it.hasNext()){ res=it.next()->msg();} while(it.hasNext()){ res+=",and\n"+it.next()->msg();} return res; } void add(OptionProblemConstraintUP& c){ cons.push(std::move(c));} - Stack cons; + Lib::Stack cons; bool is_and; }; @@ -2333,21 +2333,21 @@ bool _hard; ASS(new_long && new_short); } AbstractOptionValue* findLong(std::string longName) const{ - if(!_longMap.find(longName)){ throw ValueNotFoundException(); } + if(!_longMap.find(longName)){ throw Lib::ValueNotFoundException(); } return _longMap.get(longName); } AbstractOptionValue* findShort(std::string shortName) const{ - if(!_shortMap.find(shortName)){ throw ValueNotFoundException(); } + if(!_shortMap.find(shortName)){ throw Lib::ValueNotFoundException(); } return _shortMap.get(shortName); } - VirtualIterator values() const { + Lib::VirtualIterator values() const { return _longMap.range(); } private: - DHMap _longMap; - DHMap _shortMap; + Lib::DHMap _longMap; + Lib::DHMap _shortMap; }; LookupWrapper _lookup; @@ -2357,21 +2357,21 @@ bool _hard; try{ return _lookup.findLong(name); } - catch(ValueNotFoundException&){ + catch(Lib::ValueNotFoundException&){ try{ return _lookup.findShort(name); } - catch(ValueNotFoundException&){ + catch(Lib::ValueNotFoundException&){ return 0; } } } - Stack getSimilarOptionNames(std::string name, bool is_short) const{ + Lib::Stack getSimilarOptionNames(std::string name, bool is_short) const{ - Stack similar_names; + Lib::Stack similar_names; - VirtualIterator options = _lookup.values(); + Lib::VirtualIterator options = _lookup.values(); while(options.hasNext()){ AbstractOptionValue* opt = options.next(); std::string opt_name = is_short ? opt->shortName : opt->longName; diff --git a/Shell/PredicateDefinition.hpp b/Shell/PredicateDefinition.hpp index 4fd5e8aaf..6d33562a4 100644 --- a/Shell/PredicateDefinition.hpp +++ b/Shell/PredicateDefinition.hpp @@ -27,7 +27,6 @@ namespace Shell { -using namespace Lib; using namespace Kernel; /** @@ -41,7 +40,7 @@ using namespace Kernel; class PredicateDefinition { public: - typedef DHMap ReplMap; + typedef Lib::DHMap ReplMap; PredicateDefinition(); ~PredicateDefinition(); @@ -84,10 +83,10 @@ class PredicateDefinition unsigned _predCnt; PredData* _preds; - DHMap _defs; - DHMap _purePreds; - Stack _eliminable; - Stack _pureToReplace; + Lib::DHMap _defs; + Lib::DHMap _purePreds; + Lib::Stack _eliminable; + Lib::Stack _pureToReplace; }; }; diff --git a/Shell/Preprocess.cpp b/Shell/Preprocess.cpp index e428e90e0..9d7e21ffe 100644 --- a/Shell/Preprocess.cpp +++ b/Shell/Preprocess.cpp @@ -61,6 +61,7 @@ #include "Kernel/TermIterators.hpp" using namespace std; +using namespace Lib; using namespace Shell; /** diff --git a/Shell/Property.hpp b/Shell/Property.hpp index 09ba34ef3..f3711ebee 100644 --- a/Shell/Property.hpp +++ b/Shell/Property.hpp @@ -39,7 +39,6 @@ namespace Kernel { namespace Shell { using namespace Kernel; -using namespace Lib; /** * Represents syntactic properties of problems. @@ -301,7 +300,7 @@ class Property /** Symbols in this formula, used during counting Functions are positive, predicates stored in the negative part **/ - DHSet _symbolsInFormula; + Lib::DHSet _symbolsInFormula; /** Bitwise OR of all properties of this problem */ uint64_t _props; @@ -314,13 +313,13 @@ class Property /** Problem contains non-default sorts */ bool _hasNonDefaultSorts; unsigned _sortsUsed; - Array _usesSort; + Lib::Array _usesSort; /** Makes sense for all interpretations, but for polymorphic ones we also keep * the more precise information about which monomorphisations are present (see below). */ - DArray _interpretationPresence; - DHSet _polymorphicInterpretations; + Lib::DArray _interpretationPresence; + Lib::DHSet _polymorphicInterpretations; bool _hasFOOL; bool _hasCombs; diff --git a/Shell/Rectify.cpp b/Shell/Rectify.cpp index 28052ac54..4ce04f360 100644 --- a/Shell/Rectify.cpp +++ b/Shell/Rectify.cpp @@ -31,6 +31,7 @@ #include "Rectify.hpp" using namespace std; +using namespace Lib; using namespace Shell; bool Rectify::Renaming::tryGetBoundAndMarkUsed (int var,int& boundTo) const diff --git a/Shell/Rectify.hpp b/Shell/Rectify.hpp index 0cb675b52..839fc1725 100644 --- a/Shell/Rectify.hpp +++ b/Shell/Rectify.hpp @@ -50,14 +50,14 @@ class Rectify static void rectify(UnitList*& units); private: typedef std::pair VarWithUsageInfo; - typedef List VarUsageTrackingList; + typedef Lib::List VarUsageTrackingList; /** Renaming stores bindings for free and bound variables */ class Renaming - : public Array + : public Lib::Array { public: Renaming() - : Array(15), + : Lib::Array(15), _nextVar(0) { fillInterval(0,15); diff --git a/Shell/Shuffling.cpp b/Shell/Shuffling.cpp index 17d34d273..233446cd5 100644 --- a/Shell/Shuffling.cpp +++ b/Shell/Shuffling.cpp @@ -29,6 +29,7 @@ #include "Shuffling.hpp" using namespace std; +using namespace Lib; using namespace Kernel; using namespace Shell; diff --git a/Shell/Shuffling.hpp b/Shell/Shuffling.hpp index 3fff2c698..6c6162d4a 100644 --- a/Shell/Shuffling.hpp +++ b/Shell/Shuffling.hpp @@ -26,7 +26,6 @@ namespace Shell { -using namespace Lib; using namespace Kernel; /** @@ -36,7 +35,7 @@ using namespace Kernel; class Shuffling { private: - typedef Coproduct Shufflable; + typedef Lib::Coproduct Shufflable; static void shuffleIter(Shufflable sh); @@ -59,7 +58,7 @@ class Shuffling // Implements Fisher–Yates shuffling (each permutation equally likely) static void shuffleArray(Arrayish& a, unsigned len) { for(unsigned i=0;i - static void shuffleList(List*& list) { - unsigned len = List::length(list); + static void shuffleList(Lib::List*& list) { + unsigned len = Lib::List::length(list); if (len <= 1) { return; } - DArray*> aux(len); + Lib::DArray*> aux(len); unsigned idx = 0; - List* els = list; + Lib::List* els = list; while (els != nullptr) { aux[idx++] = els; els = els->tail(); @@ -88,12 +87,12 @@ class Shuffling shuffleArray(aux,len); // create the new list - List* res = nullptr; + Lib::List* res = nullptr; for(idx = 0; idx < len; idx++) { - res = List::cons(aux[idx]->head(),res); + res = Lib::List::cons(aux[idx]->head(),res); } - // List::destroy(list); + // Lib::List::destroy(list); list = res; } @@ -101,18 +100,18 @@ class Shuffling // get two new lists by shuffling the originals and leaking the old ones // they get shuffled "in sync" template - static void shuffleTwoList(List*& list1, List*& list2) { - unsigned len = List::length(list1); + static void shuffleTwoList(Lib::List*& list1, Lib::List*& list2) { + unsigned len = Lib::List::length(list1); if (len <= 1) { return; } - DArray*,List*>> aux(len); + Lib::DArray*,Lib::List*>> aux(len); unsigned idx = 0; - List* els1 = list1; - List* els2 = list2; + Lib::List* els1 = list1; + Lib::List* els2 = list2; while (els1 != nullptr) { ASS_NEQ(els2,0); aux[idx++] = std::make_pair(els1,els2); @@ -123,15 +122,15 @@ class Shuffling shuffleArray(aux,len); // create the new lists - List* res1 = nullptr; - List* res2 = nullptr; + Lib::List* res1 = nullptr; + Lib::List* res2 = nullptr; for(idx = 0; idx < len; idx++) { - res1 = List::cons(aux[idx].first->head(),res1); - res2 = List::cons(aux[idx].second->head(),res2); + res1 = Lib::List::cons(aux[idx].first->head(),res1); + res2 = Lib::List::cons(aux[idx].second->head(),res2); } - // List::destroy(list1); - // List::destroy(list2); + // Lib::List::destroy(list1); + // Lib::List::destroy(list2); list1 = res1; list2 = res2; diff --git a/Shell/SineUtils.hpp b/Shell/SineUtils.hpp index caea0f165..71a34853f 100644 --- a/Shell/SineUtils.hpp +++ b/Shell/SineUtils.hpp @@ -22,14 +22,13 @@ namespace Shell { -using namespace Lib; using namespace Kernel; class SineSymbolExtractor { public: typedef unsigned SymId; - typedef VirtualIterator SymIdIterator; + typedef Lib::VirtualIterator SymIdIterator; SymId getSymIdBound(); @@ -38,9 +37,9 @@ class SineSymbolExtractor static void decodeSymId(SymId s, bool& pred, unsigned& functor); bool validSymId(SymId s); private: - void addSymIds(Term* term,DHSet& ids); - void addSymIds(Literal* lit,DHSet& ids); - void extractFormulaSymbols(Formula* f,DHSet& itms); + void addSymIds(Term* term,Lib::DHSet& ids); + void addSymIds(Literal* lit,Lib::DHSet& ids); + void extractFormulaSymbols(Formula* f,Lib::DHSet& itms); }; @@ -53,7 +52,7 @@ class SineBase void initGeneralityFunction(UnitList* units); /** Stores symbol generality */ - DArray _gen; + Lib::DArray _gen; SineSymbolExtractor _symExtr; }; @@ -73,7 +72,7 @@ class SineSelector void perform(Problem& prb); ~SineSelector() { - DArray::Iterator it(_def); + Lib::DArray::Iterator it(_def); while (it.hasNext()) { UnitList::destroy(it.next()); } @@ -92,14 +91,14 @@ class SineSelector bool _justForSineLevels; /** Stored the D-relation */ - DArray _def; + Lib::DArray _def; /** * Stored formulas that don't contain any symbols * * These formulas are always selected. */ - Stack _unitsWithoutSymbols; + Lib::Stack _unitsWithoutSymbols; }; @@ -141,17 +140,17 @@ class SineTheorySelector unsigned short minTolerance; Unit* unit; }; - typedef List DEntryList; + typedef Lib::List DEntryList; /** Stored the D-relation */ - DArray _def; + Lib::DArray _def; /** * Stored formulas that don't contain any symbols * * These formulas are always selected. */ - Stack _unitsWithoutSymbols; + Lib::Stack _unitsWithoutSymbols; const Options& _opt; }; diff --git a/Shell/Skolem.cpp b/Shell/Skolem.cpp index 8bd7239d2..a2fa273b1 100644 --- a/Shell/Skolem.cpp +++ b/Shell/Skolem.cpp @@ -35,6 +35,7 @@ #include "Skolem.hpp" using namespace std; +using namespace Lib; using namespace Kernel; using namespace Shell; diff --git a/Shell/Skolem.hpp b/Shell/Skolem.hpp index 4afbc2c2e..cf39a3842 100644 --- a/Shell/Skolem.hpp +++ b/Shell/Skolem.hpp @@ -27,7 +27,6 @@ namespace Kernel { class Unit; } -using namespace Lib; using namespace Kernel; namespace Shell { @@ -62,7 +61,7 @@ class Skolem /** the collected substitution */ Substitution _subst; - typedef List BoolList; + typedef Lib::List BoolList; /** In the first pass (preskolemise) we collect information * for each variable and in each quantified subformula @@ -81,7 +80,7 @@ class Skolem BoolList* occurs_below; }; // from vars to their VarOccInfo - typedef DHMap VarOccInfos; + typedef Lib::DHMap VarOccInfos; /* starts empty at the top level, and fininshes also empty after bubbling up from the recursion; Only used temporarily during preskolemise! */ @@ -94,17 +93,17 @@ class Skolem VarSet* exist; }; // stored by the blocks, i.e. those Formulas* with the EXISTS connective - typedef DHMap ExVarDepInfos; + typedef Lib::DHMap ExVarDepInfos; ExVarDepInfos _varDeps; // map from an existential variable to its quantified formula (= block of quantifiers) - DHMap _blockLookup; + Lib::DHMap _blockLookup; /** map var --> sort */ - DHMap _varSorts; + Lib::DHMap _varSorts; // for some heuristic evaluations after we are done - Stack> _introducedSkolemSyms; + Lib::Stack> _introducedSkolemSyms; FormulaUnit* _beingSkolemised; diff --git a/Shell/SubexpressionIterator.hpp b/Shell/SubexpressionIterator.hpp index 432e4e695..24888ef1e 100644 --- a/Shell/SubexpressionIterator.hpp +++ b/Shell/SubexpressionIterator.hpp @@ -23,7 +23,6 @@ #include "Kernel/Term.hpp" namespace Shell { - using namespace Lib; using namespace Kernel; class SubexpressionIterator { @@ -93,7 +92,7 @@ namespace Shell { SubexpressionIterator(TermList ts); private: - Stack _subexpressions; + Lib::Stack _subexpressions; }; } diff --git a/Shell/SymbolDefinitionInlining.hpp b/Shell/SymbolDefinitionInlining.hpp index fab638ab1..8584e05f1 100644 --- a/Shell/SymbolDefinitionInlining.hpp +++ b/Shell/SymbolDefinitionInlining.hpp @@ -17,7 +17,6 @@ #include "Lib/Environment.hpp" #include "Lib/Set.hpp" -using namespace Lib; using namespace Kernel; using namespace Shell; @@ -32,7 +31,7 @@ class SymbolDefinitionInlining { FormulaList* process(FormulaList* formulas); TermList process(TermList ts); - List>* variableRenamings() { return _varRenames; }; + Lib::List>* variableRenamings() { return _varRenames; }; private: const bool _isPredicate; @@ -47,13 +46,13 @@ class SymbolDefinitionInlining { unsigned _counter; unsigned _freshVarOffset; - List>* _varRenames; + Lib::List>* _varRenames; void collectBoundVariables(TermList); void collectBoundVariables(Term*); void collectBoundVariables(Formula*); - Set _superformulas; + Lib::Set _superformulas; }; #endif // __SymbolDefinitionInlining__ diff --git a/Shell/SymbolOccurrenceReplacement.hpp b/Shell/SymbolOccurrenceReplacement.hpp index f66f9ccdf..02412e5c9 100644 --- a/Shell/SymbolOccurrenceReplacement.hpp +++ b/Shell/SymbolOccurrenceReplacement.hpp @@ -15,7 +15,6 @@ #include "Kernel/Signature.hpp" #include "Lib/Environment.hpp" -using namespace Lib; using namespace Kernel; using namespace Shell; @@ -37,13 +36,13 @@ class SymbolOccurrenceReplacement { : _isPredicate(isPredicate), _freshApplication(freshApplication), _symbol(symbol), _argVars(argVars) { if(isPredicate){ - ASS(VList::length(argVars) == env.signature->getPredicate(symbol)->arity()); + ASS(VList::length(argVars) == Lib::env.signature->getPredicate(symbol)->arity()); } else { - ASS(VList::length(argVars) == env.signature->getFunction(symbol)->arity()); + ASS(VList::length(argVars) == Lib::env.signature->getFunction(symbol)->arity()); } // The implementation of this class doesn't requite argVars to be // non-empty, however, its use case expects this constraint - //ASS(argVars || !env.signature->getFunction(symbol)->introduced()); + //ASS(argVars || !Lib::env.signature->getFunction(symbol)->introduced()); } Formula* process(Formula* formula); FormulaList* process(FormulaList* formulas); diff --git a/Shell/TPTPPrinter.cpp b/Shell/TPTPPrinter.cpp index 536c09677..115429c37 100644 --- a/Shell/TPTPPrinter.cpp +++ b/Shell/TPTPPrinter.cpp @@ -41,6 +41,8 @@ namespace Shell { using namespace std; +using namespace Lib; + TPTPPrinter::TPTPPrinter(ostream* tgtStream) : _tgtStream(tgtStream), _headersPrinted(false) { diff --git a/Shell/TheoryAxioms.hpp b/Shell/TheoryAxioms.hpp index 1be24bf01..2ada06e22 100644 --- a/Shell/TheoryAxioms.hpp +++ b/Shell/TheoryAxioms.hpp @@ -24,7 +24,6 @@ namespace Shell { -using namespace Lib; using namespace Kernel; class TheoryAxioms { diff --git a/Shell/TheoryFlattening.hpp b/Shell/TheoryFlattening.hpp index 437914b13..fa2628422 100644 --- a/Shell/TheoryFlattening.hpp +++ b/Shell/TheoryFlattening.hpp @@ -35,17 +35,17 @@ class TheoryFlattening void apply(Problem& prb); bool apply(UnitList*& units); bool apply(ClauseList*& units); - Clause* apply(Clause*& cl,Stack& target); + Clause* apply(Clause*& cl,Lib::Stack& target); Clause* apply(Clause*& cl){ - static Stack dummy; + static Lib::Stack dummy; return apply(cl,dummy); } private: - Literal* replaceTopTerms(Literal* lit, Stack& newLits,unsigned& maxVar, - DHMap& abstracted); - Term* replaceTopTermsInTerm(Term* term, Stack& newLits, + Literal* replaceTopTerms(Literal* lit, Lib::Stack& newLits,unsigned& maxVar, + Lib::DHMap& abstracted); + Term* replaceTopTermsInTerm(Term* term, Lib::Stack& newLits, unsigned& maxVar,bool interpreted, - DHMap& abstracted); + Lib::DHMap& abstracted); bool _recursive; bool _sharing; diff --git a/Shell/TweeGoalTransformation.cpp b/Shell/TweeGoalTransformation.cpp index 28831ef10..996f14d25 100644 --- a/Shell/TweeGoalTransformation.cpp +++ b/Shell/TweeGoalTransformation.cpp @@ -38,6 +38,10 @@ #include "TweeGoalTransformation.hpp" +using Lib::DHMap; +using Lib::DHSet; +using Lib::env; +using Lib::Stack; using Kernel::Clause; using Kernel::Literal; using Kernel::Problem; diff --git a/Shell/UIHelper.hpp b/Shell/UIHelper.hpp index 34d7138f6..a6fb38978 100644 --- a/Shell/UIHelper.hpp +++ b/Shell/UIHelper.hpp @@ -24,7 +24,6 @@ namespace Shell { -using namespace Lib; using namespace Kernel; bool szsOutputMode(); @@ -43,7 +42,7 @@ class UIHelper { SMTLIBLogic _smtLibLogic = SMT_UNDEFINED; bool _hasConjecture = false; }; - static Stack _loadedPieces; + static Lib::Stack _loadedPieces; static void tryParseTPTP(std::istream& input); static void tryParseSMTLIB2(std::istream& input); diff --git a/Test/ClausePattern.hpp b/Test/ClausePattern.hpp index 6326386e0..df2d47df5 100644 --- a/Test/ClausePattern.hpp +++ b/Test/ClausePattern.hpp @@ -34,13 +34,13 @@ struct AnyOf * A Clause matches a pattern Clause, if they are equal. * A Clause matches an AnyOf pattern if it matches both of the subpatterns. */ -class ClausePattern : Coproduct +class ClausePattern : Lib::Coproduct { public: ClausePattern(Kernel::Clause const* clause) - : Coproduct(clause) {} + : Lib::Coproduct(clause) {} - ClausePattern(ClausePattern l, ClausePattern r) : Coproduct(AnyOf { + ClausePattern(ClausePattern l, ClausePattern r) : Lib::Coproduct(AnyOf { std::make_unique(std::move(l)), std::make_unique(std::move(r)) }) {} diff --git a/Test/GenerationTester.hpp b/Test/GenerationTester.hpp index 38da480d2..552a7d94f 100644 --- a/Test/GenerationTester.hpp +++ b/Test/GenerationTester.hpp @@ -36,7 +36,7 @@ namespace Test { [] (std::string& s1, std::string& s2) { \ bool res = (VAL1 == VAL2); \ if (!res) { \ - s1 = Int::toString(VAL1); \ + s1 = Lib::Int::toString(VAL1); \ s1.append(" != "); \ s1.append(Int::toString(VAL2)); \ s2 = std::string(#VAL1); \ @@ -47,14 +47,14 @@ namespace Test { } template -Stack exactly(As... as) +Lib::Stack exactly(As... as) { - Stack out { as... }; + Lib::Stack out { as... }; return out; } -inline Stack none() { - return Stack(); +inline Lib::Stack none() { + return Lib::Stack(); } namespace Generation { @@ -80,18 +80,18 @@ class GenerationTester class TestCase { using Clause = Kernel::Clause; - using OptionMap = Stack>; + using OptionMap = Lib::Stack>; using Condition = std::function; - Option _rule; + Lib::Option _rule; Clause* _input; - Stack _expected; - Stack _context; + Lib::Stack _expected; + Lib::Stack _context; bool _premiseRedundant; - Stack _indices; + Lib::Stack _indices; std::function _setup = [](SaturationAlgorithm&){}; OptionMap _options; - Stack _preConditions; - Stack _postConditions; + Lib::Stack _preConditions; + Lib::Stack _postConditions; template void testFail(Is const& is, Expected const& expected) { @@ -117,14 +117,14 @@ class TestCase BUILDER_METHOD(Clause*, input) BUILDER_METHOD(ClauseStack, context) - BUILDER_METHOD(Stack, expected) + BUILDER_METHOD(Lib::Stack, expected) BUILDER_METHOD(bool, premiseRedundant) BUILDER_METHOD(SimplifyingGeneratingInference*, rule) - BUILDER_METHOD(Stack, indices) + BUILDER_METHOD(Lib::Stack, indices) BUILDER_METHOD(std::function, setup) BUILDER_METHOD(OptionMap, options) - BUILDER_METHOD(Stack, preConditions) - BUILDER_METHOD(Stack, postConditions) + BUILDER_METHOD(Lib::Stack, preConditions) + BUILDER_METHOD(Lib::Stack, postConditions) template void run(GenerationTester& simpl) { @@ -137,12 +137,12 @@ class TestCase auto ul = UnitList::empty(); UnitList::pushFromIterator(ClauseStack::Iterator(_context), ul); p.addUnits(ul); - env.setMainProblem(&p); + Lib::env.setMainProblem(&p); Options o; for (const auto& kv : _options) { o.set(kv.first, kv.second); - env.options->set(kv.first, kv.second); + Lib::env.options->set(kv.first, kv.second); } MockedSaturationAlgorithm alg(p, o); _setup(alg); @@ -175,7 +175,7 @@ class TestCase // run checks auto& sExp = this->_expected; - auto sRes = Stack::fromIterator(res.clauses); + auto sRes = Lib::Stack::fromIterator(res.clauses); if (!TestUtils::permEq(sExp, sRes, [&](auto exp, auto res) { return exp.matches(simpl, res); })) { testFail(sRes, sExp); diff --git a/Test/SimplificationTester.hpp b/Test/SimplificationTester.hpp index 808129805..3cccb0c06 100644 --- a/Test/SimplificationTester.hpp +++ b/Test/SimplificationTester.hpp @@ -38,7 +38,7 @@ class SimplificationTester class Success { Kernel::Clause* _input; - Option _expected; + Lib::Option _expected; public: Success() : _input(nullptr) {} @@ -51,7 +51,7 @@ class Success Success expected(ClausePattern x) { - _expected = Option(x); + _expected = Lib::Option(x); return *this; } diff --git a/Test/SyntaxSugar.hpp b/Test/SyntaxSugar.hpp index e2f0d3428..b4811262a 100644 --- a/Test/SyntaxSugar.hpp +++ b/Test/SyntaxSugar.hpp @@ -95,13 +95,13 @@ #define DECL_VAR(x, i) auto x = TermSugar(TermList::var(i)); #define DECL_SORT_VAR(x, i) auto x = SortSugar(TermList::var(i)); #define DECL_VAR_SORTED(x, i, s) auto x = TermSugar(TermList::var(i), s); -#define DECL_I_COMB(i) auto i = FuncSugar(env.signature->getCombinator(Signature::I_COMB)); -#define DECL_K_COMB(k) auto k = FuncSugar(env.signature->getCombinator(Signature::K_COMB)); -#define DECL_B_COMB(b) auto b = FuncSugar(env.signature->getCombinator(Signature::B_COMB)); -#define DECL_C_COMB(c) auto c = FuncSugar(env.signature->getCombinator(Signature::C_COMB)); -#define DECL_S_COMB(s) auto s = FuncSugar(env.signature->getCombinator(Signature::S_COMB)); -#define DECL_FUN_DEF(d, t) auto d = PredSugar(env.signature->getFnDef(t.sugaredExpr().term()->functor())); -#define DECL_PRED_DEF(d, t) auto d = PredSugar(env.signature->getBoolDef(((Literal*)t)->functor())); +#define DECL_I_COMB(i) auto i = FuncSugar(Lib::env.signature->getCombinator(Signature::I_COMB)); +#define DECL_K_COMB(k) auto k = FuncSugar(Lib::env.signature->getCombinator(Signature::K_COMB)); +#define DECL_B_COMB(b) auto b = FuncSugar(Lib::env.signature->getCombinator(Signature::B_COMB)); +#define DECL_C_COMB(c) auto c = FuncSugar(Lib::env.signature->getCombinator(Signature::C_COMB)); +#define DECL_S_COMB(s) auto s = FuncSugar(Lib::env.signature->getCombinator(Signature::S_COMB)); +#define DECL_FUN_DEF(d, t) auto d = PredSugar(Lib::env.signature->getFnDef(t.sugaredExpr().term()->functor())); +#define DECL_PRED_DEF(d, t) auto d = PredSugar(Lib::env.signature->getBoolDef(((Literal*)t)->functor())); #define DECL_DEFAULT_VARS \ __ALLOW_UNUSED( \ @@ -201,7 +201,7 @@ class SyntaxSugar { public: static void reset() { - env.signature = new Signature(); + Lib::env.signature = new Signature(); } }; @@ -327,12 +327,12 @@ struct SortSugar : public ExpressionSugar ASS(srt.isVar() || srt.term()->isSort()); } - SortSugar(const char* name, Stack as_) + SortSugar(const char* name, Lib::Stack as_) { if(as_.isEmpty()){ _sugaredExpr = TermList(AtomicSort::createConstant(name)); } else { - Stack as; + Lib::Stack as; for (auto a : as_){ as.push(a.sugaredExpr()); } _sugaredExpr = AtomicSort::arrowSort(as, as.pop()); } @@ -383,11 +383,11 @@ class TermSugar : public ExpressionSugar TermSugar sort(SortId s) { _srt = s; return *this; } static TermSugar createConstant(const char* name, SortSugar s, bool skolem) { - unsigned f = env.signature->addFunction(name,0); + unsigned f = Lib::env.signature->addFunction(name,0); - env.signature->getFunction(f)->setType(OperatorType::getFunctionType({}, s.sugaredExpr())); + Lib::env.signature->getFunction(f)->setType(OperatorType::getFunctionType({}, s.sugaredExpr())); if (skolem) { - env.signature->getFunction(f)->markSkolem(); + Lib::env.signature->getFunction(f)->markSkolem(); } return TermSugar(TermList(Term::createConstant(f))); } @@ -528,7 +528,7 @@ __IMPL_NUMBER_BIN_FUN(operator>=, Lit) inline SortSugar arrow(TermList args, TermList res) { return AtomicSort::arrowSort({ args }, res); } -inline SortSugar arrow(Stack args, TermList res) +inline SortSugar arrow(Lib::Stack args, TermList res) { return AtomicSort::arrowSort(args, res); } class FuncSugar { @@ -538,17 +538,17 @@ class FuncSugar { public: explicit FuncSugar(unsigned functor) : _functor(functor) - , _arity(env.signature->getFunction(functor)->arity()) {} + , _arity(Lib::env.signature->getFunction(functor)->arity()) {} FuncSugar(std::string const& name, std::initializer_list as_, ExpressionSugar result, unsigned taArity = 0) { - Stack as; + Lib::Stack as; for (auto a : as_) as.push(a.sugaredExpr()); bool added = false; - _functor = env.signature->addFunction(name, as.size() + taArity, added); + _functor = Lib::env.signature->addFunction(name, as.size() + taArity, added); _arity = as.size(); if (added){ TermList res = result.sugaredExpr(); @@ -559,7 +559,7 @@ class FuncSugar { SortHelper::normaliseSort(vars, res); } - env.signature + Lib::env.signature ->getFunction(_functor) ->setType(OperatorType::getFunctionType(as.size(), as.begin(), res, taArity)); } @@ -569,7 +569,7 @@ class FuncSugar { ASS_L(i, arity()) ASS (symbol()->termAlgebraCons()) return FuncSugar( - env.signature->getTermAlgebraConstructor(functor()) + Lib::env.signature->getTermAlgebraConstructor(functor()) ->destructorFunctor(i)); } @@ -578,14 +578,14 @@ class FuncSugar { template TermSugar operator()(As... args) const { - Stack as { TermSugar(args).sugaredExpr()... }; + Lib::Stack as { TermSugar(args).sugaredExpr()... }; return TermList(Term::create(_functor, as.size(), as.begin())); } unsigned functor() const { return _functor; } unsigned arity() const { return _arity; } - Signature::Symbol* symbol() const { return env.signature->getFunction(functor()); } + Signature::Symbol* symbol() const { return Lib::env.signature->getFunction(functor()); } friend std::ostream& operator<<(std::ostream& out, FuncSugar const& self) { return out << self.symbol()->name(); } @@ -609,16 +609,16 @@ class TypeConSugar { TypeConSugar(const char* name, unsigned arity) { bool added = false; - _functor = env.signature->addTypeCon(name, arity, added); + _functor = Lib::env.signature->addTypeCon(name, arity, added); if (added) - env.signature + Lib::env.signature ->getTypeCon(_functor) ->setType(OperatorType::getTypeConType(arity)); } template SortSugar operator()(As... args) const { - Stack as { SortSugar(args).sugaredExpr()... }; + Lib::Stack as { SortSugar(args).sugaredExpr()... }; return TermList(AtomicSort::create(_functor, as.size(), as.begin() )); @@ -645,7 +645,7 @@ class PredSugar { PredSugar(const char* name, std::initializer_list args, unsigned taArity = 0) { - Stack as; + Lib::Stack as; for (auto a : args) { as.push(a.sugaredExpr()); } @@ -656,15 +656,15 @@ class PredSugar { SortHelper::normaliseArgSorts(vars, as); } - _functor = env.signature->addPredicate(name, as.size() + taArity); - env.signature + _functor = Lib::env.signature->addPredicate(name, as.size() + taArity); + Lib::env.signature ->getPredicate(_functor) ->setType(OperatorType::getPredicateType(as.size(), as.begin(), taArity)); } template Lit operator()(As... args) const { - Stack as { TermSugar(args).sugaredExpr()... }; + Lib::Stack as { TermSugar(args).sugaredExpr()... }; return Literal::create(_functor, as.size(), /* polarity */ true, @@ -674,7 +674,7 @@ class PredSugar { unsigned functor() const { return _functor; } }; -inline Clause* clause(Stack ls) { +inline Clause* clause(Lib::Stack ls) { static Inference testInf = Kernel::NonspecificInference0(UnitInputType::ASSUMPTION, InferenceRule::INPUT); std::stable_sort(ls.begin(), ls.end(), [](Lit const& l1, Lit const& l2){ return l1.selected() > l2.selected(); }); @@ -691,10 +691,10 @@ inline Clause* clause(Stack ls) { } inline Clause* clause(std::initializer_list ls) -{ return clause(Stack(ls)); } +{ return clause(Lib::Stack(ls)); } -inline Stack clauses(std::initializer_list> cls) { - auto out = Stack(); +inline Lib::Stack clauses(std::initializer_list> cls) { + auto out = Lib::Stack(); for (auto cl : cls) { out.push(clause(cl)); } @@ -703,36 +703,36 @@ inline Stack clauses(std::initializer_list> inline void createTermAlgebra(SortSugar sort, std::initializer_list fs) { // avoid redeclaration - if (env.signature->isTermAlgebraSort(sort.sugaredExpr())) { + if (Lib::env.signature->isTermAlgebraSort(sort.sugaredExpr())) { return; } using namespace Shell; - Stack funcs = fs; - Stack cons; + Lib::Stack funcs = fs; + Lib::Stack cons; for (auto f : funcs) { - env.signature->getFunction(f.functor()) + Lib::env.signature->getFunction(f.functor()) ->markTermAlgebraCons(); auto dtor = [&](unsigned i) { std::stringstream name; name << f << "@" << i; auto d = FuncSugar(name.str(), { f.result() }, f.arg(i)); - env.signature->getFunction(d.functor()) + Lib::env.signature->getFunction(d.functor()) ->markTermAlgebraDest(); return d; }; - Array dtors(f.arity()); + Lib::Array dtors(f.arity()); for (unsigned i = 0; i < f.arity(); i++) { dtors[i] = dtor(i).functor(); } cons.push(new TermAlgebraConstructor(f.functor(), dtors)); } - env.signature->addTermAlgebra(new TermAlgebra(sort.sugaredExpr(), cons.size(), cons.begin())); + Lib::env.signature->addTermAlgebra(new TermAlgebra(sort.sugaredExpr(), cons.size(), cons.begin())); } #endif // __TEST__SYNTAX_SUGAR__H__ diff --git a/Test/TestUtils.cpp b/Test/TestUtils.cpp index bf5a251db..f66aeb007 100644 --- a/Test/TestUtils.cpp +++ b/Test/TestUtils.cpp @@ -28,6 +28,7 @@ namespace Test { using namespace std; +using namespace Lib; using namespace Kernel; using namespace Shell; diff --git a/Test/TestUtils.hpp b/Test/TestUtils.hpp index e7b048930..e903ed98a 100644 --- a/Test/TestUtils.hpp +++ b/Test/TestUtils.hpp @@ -79,7 +79,7 @@ class TestUtils { { class Inner { unsigned cnt = 0; - Map _self; + Lib::Map _self; public: unsigned get(unsigned var) { return _self.getOrInit(std::move(var), [&](){ return cnt++; }); } @@ -144,8 +144,8 @@ struct PrettyPrinter { }; template -struct PrettyPrinter> { - void operator()(std::ostream& out, Stack const& self) +struct PrettyPrinter> { + void operator()(std::ostream& out, Lib::Stack const& self) { auto iter = self.iterFifo(); out << "[ "; @@ -160,8 +160,8 @@ struct PrettyPrinter> { }; template -struct PrettyPrinter> { - void operator()(std::ostream& out, Option const& self) +struct PrettyPrinter> { + void operator()(std::ostream& out, Lib::Option const& self) { self.isSome() ? out << pretty(self.unwrap()) : out << "none"; } }; @@ -227,7 +227,7 @@ struct PrettyPrinter #undef NUM_CASE } } - Signature::Symbol* sym = env.signature->getPredicate(func); + Signature::Symbol* sym = Lib::env.signature->getPredicate(func); out << sym->name(); if (sym->arity() > 0) { out << "(" << pretty(*lit.nthArgument(0)); @@ -281,7 +281,7 @@ struct PrettyPrinter } } - Signature::Symbol* sym = env.signature->getFunction(func); + Signature::Symbol* sym = Lib::env.signature->getFunction(func); out << sym->name(); if (sym->arity() > 0) { out << "(" << pretty(*term->nthArgument(0)); @@ -297,8 +297,8 @@ struct PrettyPrinter // Helper function for permEq -- checks whether lhs is a permutation of // rhs via initial permutation perm with elements [0,idx) fixed. template -bool __permEq(L1& lhs, L2& rhs, Eq elemEq, DArray& perm, unsigned idx) { - auto checkPerm = [] (L1& lhs, L2& rhs, Eq elemEq, DArray& perm, unsigned idx) { +bool __permEq(L1& lhs, L2& rhs, Eq elemEq, Lib::DArray& perm, unsigned idx) { + auto checkPerm = [] (L1& lhs, L2& rhs, Eq elemEq, Lib::DArray& perm, unsigned idx) { ASS_EQ(lhs.size(), perm.size()); ASS_EQ(rhs.size(), perm.size()); @@ -335,7 +335,7 @@ template bool TestUtils::permEq(L1& lhs, L2& rhs, Eq elemEq) { if (lhs.size() != rhs.size()) return false; - DArray perm(lhs.size()); + Lib::DArray perm(lhs.size()); for (unsigned i = 0; i < lhs.size(); i++) { perm[i] = i; } diff --git a/Test/UnitTesting.hpp b/Test/UnitTesting.hpp index 86e120497..151f6e3c3 100644 --- a/Test/UnitTesting.hpp +++ b/Test/UnitTesting.hpp @@ -24,7 +24,6 @@ namespace Test { -using namespace Lib; typedef void (*TestProc)(); @@ -61,7 +60,7 @@ class TestUnit std::string const& id() const { return _name; } - Stack const& tests() { return _tests; } + Lib::Stack const& tests() { return _tests; } private: Test* findTest(std::string const& testCase); /** Runs a test as a single process and awaits its termination. @@ -72,7 +71,7 @@ class TestUnit bool spawnTest(TestProc proc); // TODO replace by Map as soon as integer-arithmetic PR with Map additions has landed - Stack _tests; + Lib::Stack _tests; std::string _name; }; @@ -80,15 +79,15 @@ class TestUnit class UnitTesting { static UnitTesting* _instance; - Stack _units; + Lib::Stack _units; UnitTesting() : _units() {} public: static UnitTesting& instance(); bool add(std::string const& testUnit, TestUnit::Test test); TestUnit* findUnit(std::string const& id); - bool listTests(Stackconst& args); - bool run(Stackconst& args); + bool listTests(Lib::Stackconst& args); + bool run(Lib::Stackconst& args); bool runUnit(std::string const& args); bool runTest(std::string const& unit, std::string const& testCase); }; diff --git a/UnitTests/tArithmeticSubtermGeneralization.cpp b/UnitTests/tArithmeticSubtermGeneralization.cpp index 4efa86545..b332e8f76 100644 --- a/UnitTests/tArithmeticSubtermGeneralization.cpp +++ b/UnitTests/tArithmeticSubtermGeneralization.cpp @@ -25,6 +25,7 @@ #include "Kernel/KBO.hpp" using namespace std; +using namespace Lib; using namespace Kernel; using namespace Inferences; using namespace Test; diff --git a/UnitTests/tBottomUpEvaluation.cpp b/UnitTests/tBottomUpEvaluation.cpp index bd378d64a..96e68e8f4 100644 --- a/UnitTests/tBottomUpEvaluation.cpp +++ b/UnitTests/tBottomUpEvaluation.cpp @@ -13,6 +13,7 @@ #include "Kernel/BottomUpEvaluation.hpp" #include "Kernel/Term.hpp" +using namespace Lib; using namespace Kernel; using namespace Inferences; using namespace Test; diff --git a/UnitTests/tDHMap.cpp b/UnitTests/tDHMap.cpp index 092dbaef7..ab250e033 100644 --- a/UnitTests/tDHMap.cpp +++ b/UnitTests/tDHMap.cpp @@ -11,6 +11,8 @@ #include "Lib/DHMap.hpp" #include "Test/UnitTesting.hpp" +using namespace Lib; + typedef DHMap MyMap; TEST_FUN(dhmap1) diff --git a/UnitTests/tKBO.cpp b/UnitTests/tKBO.cpp index 77ae85eae..0388d979b 100644 --- a/UnitTests/tKBO.cpp +++ b/UnitTests/tKBO.cpp @@ -21,6 +21,7 @@ //////////////////////////////////////////////////////////////////////////////// using namespace std; +using namespace Lib; using namespace Kernel; KBO kbo(unsigned introducedSymbolWeight, diff --git a/UnitTests/tKBO.hpp b/UnitTests/tKBO.hpp index 2e8e4f2c6..80eb66fb7 100644 --- a/UnitTests/tKBO.hpp +++ b/UnitTests/tKBO.hpp @@ -8,8 +8,8 @@ * and in the source directory */ -inline DArray predLevels() { - DArray out(env.signature->predicates()); +inline Lib::DArray predLevels() { + Lib::DArray out(Lib::env.signature->predicates()); out.init(out.size(), 1); return out; } @@ -17,12 +17,12 @@ inline DArray predLevels() { using namespace Kernel; template -inline KboWeightMap toWeightMap(unsigned introducedSymbolWeight, KboSpecialWeights ws, const Map& xs, unsigned sz) +inline KboWeightMap toWeightMap(unsigned introducedSymbolWeight, KboSpecialWeights ws, const Lib::Map& xs, unsigned sz) { auto df = KboWeightMap::dflt(); df._specialWeights = ws; - DArray out(sz); + Lib::DArray out(sz); for (unsigned i = 0; i < sz; i++) { auto w = xs.getPtr(i); out[i] = w == NULL ? df.symbolWeight(i) : *w; @@ -34,18 +34,18 @@ inline KboWeightMap toWeightMap(unsigned introducedSymbolWeight, KboS }; } -inline void __weights(Map& ws) { +inline void __weights(Lib::Map& ws) { } template -inline void __weights(Map& ws, std::pair a, std::pair... as) { +inline void __weights(Lib::Map& ws, std::pair a, std::pair... as) { ws.insert(std::get<0>(a).functor(), std::get<1>(a)); __weights(ws, as...); } template -inline Map weights(std::pair... as) { - Map out; +inline Lib::Map weights(std::pair... as) { + Lib::Map out; __weights(out, as...); return out; } diff --git a/UnitTests/tLPO.cpp b/UnitTests/tLPO.cpp index 22f72f062..6d974eb4b 100644 --- a/UnitTests/tLPO.cpp +++ b/UnitTests/tLPO.cpp @@ -14,6 +14,8 @@ #include "Kernel/Ordering.hpp" #include "Kernel/Problem.hpp" +using namespace Lib; + DArray lpoPredLevels() { DArray out(env.signature->predicates()); out.init(out.size(), 1); diff --git a/UnitTests/tRebalance.cpp b/UnitTests/tRebalance.cpp index abcf67207..2c41134dd 100644 --- a/UnitTests/tRebalance.cpp +++ b/UnitTests/tRebalance.cpp @@ -18,6 +18,7 @@ using namespace std; +using namespace Lib; using namespace Kernel; using namespace Rebalancing; using namespace Inverters; diff --git a/UnitTests/tSKIKBO.cpp b/UnitTests/tSKIKBO.cpp index 19dc78608..c9a948a8c 100644 --- a/UnitTests/tSKIKBO.cpp +++ b/UnitTests/tSKIKBO.cpp @@ -20,6 +20,7 @@ //////////////////////////////////////////////////////////////////////////////// using namespace std; +using namespace Lib; using namespace Kernel; SKIKBO skikbo(unsigned introducedSymbolWeight, diff --git a/UnitTests/tSet.cpp b/UnitTests/tSet.cpp index 692e69c21..ecea673de 100644 --- a/UnitTests/tSet.cpp +++ b/UnitTests/tSet.cpp @@ -12,6 +12,8 @@ #include "Test/UnitTesting.hpp" #include "UnitTests/dummyHash.hpp" +using namespace Lib; + TEST_FUN(find_remove_contains) { Set *test_set = new Set(); diff --git a/UnitTests/tTermAlgebra.cpp b/UnitTests/tTermAlgebra.cpp index 90c6fc506..6d829bd0c 100644 --- a/UnitTests/tTermAlgebra.cpp +++ b/UnitTests/tTermAlgebra.cpp @@ -13,6 +13,7 @@ #include "Shell/TermAlgebra.hpp" +using namespace Lib; using namespace Shell; #define DECL_VARS \ diff --git a/UnitTests/tTheoryInstAndSimp.cpp b/UnitTests/tTheoryInstAndSimp.cpp index e5e03e64b..6af166ab0 100644 --- a/UnitTests/tTheoryInstAndSimp.cpp +++ b/UnitTests/tTheoryInstAndSimp.cpp @@ -93,7 +93,7 @@ TheoryInstAndSimp* theoryInstAndSimp(Options::TheoryInstSimp mode, bool withGene /* export smtlib */ ""); } -using Shell::Int; +using Lib::Int; REGISTER_GEN_TESTER(TheoryInstAndSimp) TEST_GENERATION(test_01, diff --git a/UnitTests/tZ3Interfacing.cpp b/UnitTests/tZ3Interfacing.cpp index b067271ac..3c4fb4912 100644 --- a/UnitTests/tZ3Interfacing.cpp +++ b/UnitTests/tZ3Interfacing.cpp @@ -24,6 +24,7 @@ // #endif using namespace std; +using namespace Lib; using namespace Shell; using namespace SAT; diff --git a/vampire.cpp b/vampire.cpp index 425bafb05..522c423ff 100644 --- a/vampire.cpp +++ b/vampire.cpp @@ -62,6 +62,7 @@ #include "FMB/ModelCheck.hpp" using namespace std; +using namespace Lib; /** * Return value is non-zero unless we were successful.