| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2005-2015 Dmitry Tsarkov and The University of Manchester |
| 3 | Copyright (C) 2015-2017 Dmitry Tsarkov |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with this library; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #ifndef DATAREASONING_H |
| 21 | #define DATAREASONING_Hcxx . . $ `Kernel/DataReasoning.h:21:9`! |
| 22 | |
| 23 | |
| 24 | #include <map> |
| 25 | #include <vector> |
| 26 | |
| 27 | #include "tDataEntry.h"cxx . . $ `<file>/Kernel/tDataEntry.h`/ |
| 28 | #include "DataTypeComparator.h"cxx . . $ `<file>/Kernel/DataTypeComparator.h`/ |
| 29 | #include "ConceptWithDep.h"cxx . . $ `<file>/Kernel/ConceptWithDep.h`/ |
| 30 | #include "dlDag.h"cxx . . $ `<file>/Kernel/dlDag.h`/ |
| 31 | #include "logging.h"cxx . . $ `<file>/Kernel/logging.h`/ |
| 32 | |
| 33 | class DataTypeAppearancecxx . . $ DataTypeAppearance# |
| 34 | { |
| 35 | protected: // classes |
| 36 | /// data interval with dep-sets |
| 37 | class DepIntervalcxx . . $ DataTypeAppearance#DepInterval# |
| 38 | { |
| 39 | protected: // members |
| 40 | /// interval itself |
| 41 | TDataIntervalcxx . . $ TDataInterval# Constraintscxx . . $ DataTypeAppearance#DepInterval#Constraints.; |
| 42 | /// local dep-set |
| 43 | DepSetcxx . . $ DepSet# locDepcxx . . $ DataTypeAppearance#DepInterval#locDep.; |
| 44 | public: // interface |
| 45 | /// get RO access to the base data interval |
| 46 | const TDataIntervalcxx . . $ TDataInterval#& getDataIntervalcxx . . $ DataTypeAppearance#DepInterval#getDataInterval(46692a9b285f8bd6). ( void ) const { return Constraintscxx . . $ DataTypeAppearance#DepInterval#Constraints.; } |
| 47 | /// update MIN border of an TYPE's interval with VALUE wrt EXCL |
| 48 | bool updatecxx . . $ DataTypeAppearance#DepInterval#update(ceacd501d9b5a30e). ( bool min, bool excl, const ComparableDTcxx . . $ ComparableDT#& value, const DepSetcxx . . $ DepSet#& dep ) |
| 49 | { |
| 50 | if ( !Constraintscxx . . $ DataTypeAppearance#DepInterval#Constraints..updatecxx . . $ TDataInterval#update(facbc98c3426075c). ( min, excl, value ) ) |
| 51 | return false; |
| 52 | locDepcxx . . $ DataTypeAppearance#DepInterval#locDep. +=cxx . . $ TDepSet#`operator+=`(6a948e2ed08fa462). dep; |
| 53 | return true; |
| 54 | } |
| 55 | /// correct MIN and MAX operands of a type |
| 56 | bool checkMinMaxClashcxx . . $ DataTypeAppearance#DepInterval#checkMinMaxClash(86fbde385cece29c). ( DepSetcxx . . $ DepSet#& dep ) const; |
| 57 | /// check if the interval is consistent wrt given type |
| 58 | bool consistentcxx . . $ DataTypeAppearance#DepInterval#consistent(10c29f092662f364). ( const ComparableDTcxx . . $ ComparableDT#& type, DepSetcxx . . $ DepSet#& dep ) const |
| 59 | { |
| 60 | if ( Constraintscxx . . $ DataTypeAppearance#DepInterval#Constraints..consistentcxx . . $ TDataInterval#consistent(91deb93419938144).(type) ) |
| 61 | return true; |
| 62 | dep +=cxx . . $ TDepSet#`operator+=`(6a948e2ed08fa462). locDepcxx . . $ DataTypeAppearance#DepInterval#locDep.; |
| 63 | return false; |
| 64 | } |
| 65 | /// clear the interval |
| 66 | void clearcxx . . $ DataTypeAppearance#DepInterval#clear(49f6e7a06ebc5aa8). ( void ) { Constraintscxx . . $ DataTypeAppearance#DepInterval#Constraints..clearcxx . . $ TDataInterval#clear(49f6e7a06ebc5aa8).(); locDepcxx . . $ DataTypeAppearance#DepInterval#locDep..clearcxx . . $ TDepSet#clear(49f6e7a06ebc5aa8).(); } |
| 67 | }; // DepInterval |
| 68 | |
| 69 | /// datatype restriction is a set of intervals |
| 70 | typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<DepIntervalcxx . . $ DataTypeAppearance#DepInterval#> DTConstraintcxx . . $ DataTypeAppearance#DTConstraint#; |
| 71 | typedef DTConstraintcxx . . $ DataTypeAppearance#DTConstraint#::iteratorcxx . . $ std/vector#iterator# iteratorcxx . . $ DataTypeAppearance#iterator#; |
| 72 | typedef DTConstraintcxx . . $ DataTypeAppearance#DTConstraint#::const_iteratorcxx . . $ std/vector#const_iterator# const_iteratorcxx . . $ DataTypeAppearance#const_iterator#; |
| 73 | |
| 74 | public: // members |
| 75 | /// dep-set for positive type appearance |
| 76 | DepSetcxx . . $ DepSet#* PTypecxx . . $ DataTypeAppearance#PType. = nullptr; |
| 77 | /// dep-set for negative type appearance |
| 78 | DepSetcxx . . $ DepSet#* NTypecxx . . $ DataTypeAppearance#NType. = nullptr; |
| 79 | |
| 80 | protected: // members |
| 81 | /// interval of possible values |
| 82 | DTConstraintcxx . . $ DataTypeAppearance#DTConstraint# Constraintscxx . . $ DataTypeAppearance#Constraints.; |
| 83 | /// accumulated dep-set |
| 84 | DepSetcxx . . $ DepSet# accDepcxx . . $ DataTypeAppearance#accDep.; |
| 85 | /// dep-set for the clash |
| 86 | DepSetcxx . . $ DepSet#& clashDepcxx . . $ DataTypeAppearance#clashDep.; |
| 87 | |
| 88 | // local values for the updating |
| 89 | |
| 90 | /// local value for the min/max flag |
| 91 | bool localMincxx . . $ DataTypeAppearance#localMin. = false; |
| 92 | /// local value for the incl/excl flag |
| 93 | bool localExclcxx . . $ DataTypeAppearance#localExcl. = false; |
| 94 | /// local value for the added value |
| 95 | ComparableDTcxx . . $ ComparableDT# localValuecxx . . $ DataTypeAppearance#localValue.; |
| 96 | /// local dep-set for the update |
| 97 | DepSetcxx . . $ DepSet# localDepcxx . . $ DataTypeAppearance#localDep.; |
| 98 | |
| 99 | protected: // methods |
| 100 | /// set clash dep-set to DEP, report with given REASON; @return true to simplify callers |
| 101 | bool reportClashcxx . . $ DataTypeAppearance#reportClash(6e83bd8e52edb65e). ( const DepSetcxx . . $ DepSet#& dep, const char* reason ) |
| 102 | { |
| 103 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llCDActioncxx . . $ llCDAction.) ) // level of logging |
| 104 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " DT-" <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). reason; // inform about clash... |
| 105 | |
| 106 | clashDepcxx . . $ DataTypeAppearance#clashDep. =cxx . . $ TDepSet#`operator=`(6a948e2ed08fa462). dep; |
| 107 | return true; |
| 108 | } |
| 109 | /// set the local parameters for updating |
| 110 | void setLocalcxx . . $ DataTypeAppearance#setLocal(3703ed15ae49253e). ( bool min, bool excl, const ComparableDTcxx . . $ ComparableDT#& value, const DepSetcxx . . $ DepSet#& dep ) |
| 111 | { |
| 112 | localMincxx . . $ DataTypeAppearance#localMin. = min; |
| 113 | localExclcxx . . $ DataTypeAppearance#localExcl. = excl; |
| 114 | localValuecxx . . $ DataTypeAppearance#localValue. =cxx . . $ ComparableDT#`operator=`(d6659132de7aa9cd). value; |
| 115 | localDepcxx . . $ DataTypeAppearance#localDep. =cxx . . $ TDepSet#`operator=`(6a948e2ed08fa462). dep; |
| 116 | } |
| 117 | /// update and add a single interval I to the constraints. @return true iff clash occurs |
| 118 | bool addUpdatedIntervalcxx . . $ DataTypeAppearance#addUpdatedInterval(c3838b4431dee456). ( DepIntervalcxx . . $ DataTypeAppearance#DepInterval# i ) |
| 119 | { |
| 120 | if ( !i.consistentcxx . . $ DataTypeAppearance#DepInterval#consistent(10c29f092662f364). ( localValuecxx . . $ DataTypeAppearance#localValue., localDepcxx . . $ DataTypeAppearance#localDep. ) ) // types are mismatch |
| 121 | return reportClashcxx . . $ DataTypeAppearance#reportClash(6e83bd8e52edb65e). ( localDepcxx . . $ DataTypeAppearance#localDep., "C-IT" ); |
| 122 | if ( !i.updatecxx . . $ DataTypeAppearance#DepInterval#update(ceacd501d9b5a30e). ( localMincxx . . $ DataTypeAppearance#localMin., localExclcxx . . $ DataTypeAppearance#localExcl., localValuecxx . . $ DataTypeAppearance#localValue., localDepcxx . . $ DataTypeAppearance#localDep. ) ) |
| 123 | Constraintscxx . . $ DataTypeAppearance#Constraints..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(i); |
| 124 | else if ( !hasPTypecxx . . $ DataTypeAppearance#hasPType(50ce9a9e25b4a850).() || !i.checkMinMaxClashcxx . . $ DataTypeAppearance#DepInterval#checkMinMaxClash(86fbde385cece29c).(accDepcxx . . $ DataTypeAppearance#accDep.) ) |
| 125 | Constraintscxx . . $ DataTypeAppearance#Constraints..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(i); |
| 126 | return false; |
| 127 | } |
| 128 | /// update and add all the intervals from the given range. @return true iff clash occurs |
| 129 | bool addIntervalscxx . . $ DataTypeAppearance#addIntervals(85b4fd7dc680f52b). ( iteratorcxx . . $ DataTypeAppearance#iterator# begin, iteratorcxx . . $ DataTypeAppearance#iterator# end ) |
| 130 | { |
| 131 | for ( ; begin !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).begin ) |
| 132 | if ( addUpdatedIntervalcxx . . $ DataTypeAppearance#addUpdatedInterval(c3838b4431dee456).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).begin) ) |
| 133 | return true; |
| 134 | return false; |
| 135 | } |
| 136 | /// add interval INT positively to the DTA |
| 137 | bool addPosIntervalcxx . . $ DataTypeAppearance#addPosInterval(9fad8f796b1ecb4f). ( const TDataIntervalcxx . . $ TDataInterval#& Int, const DepSetcxx . . $ DepSet#& dep ); |
| 138 | /// add interval INT negatively to the DTA |
| 139 | bool addNegIntervalcxx . . $ DataTypeAppearance#addNegInterval(9fad8f796b1ecb4f). ( const TDataIntervalcxx . . $ TDataInterval#& Int, const DepSetcxx . . $ DepSet#& dep ); |
| 140 | |
| 141 | public: // methods |
| 142 | /// empty c'tor |
| 143 | explicit DataTypeAppearancecxx . . $ DataTypeAppearance#DataTypeAppearance(b464a0233ac968b9). ( DepSetcxx . . $ DepSet#& dep ) : clashDepcxx . . $ DataTypeAppearance#clashDep.(dep) {} |
| 144 | /// empty d'tor |
| 145 | ~cxx . . $ DataTypeAppearance#`~DataTypeAppearance`(49f6e7a06ebc5aa8).DataTypeAppearancecxx . . $ DataTypeAppearance#() { delete PTypecxx . . $ DataTypeAppearance#PType.; delete NTypecxx . . $ DataTypeAppearance#NType.; } |
| 146 | |
| 147 | /// clear the appearance flags |
| 148 | void clearcxx . . $ DataTypeAppearance#clear(49f6e7a06ebc5aa8). ( void ) |
| 149 | { |
| 150 | delete PTypecxx . . $ DataTypeAppearance#PType.; |
| 151 | PTypecxx . . $ DataTypeAppearance#PType. = nullptr; |
| 152 | delete NTypecxx . . $ DataTypeAppearance#NType.; |
| 153 | NTypecxx . . $ DataTypeAppearance#NType. = nullptr; |
| 154 | Constraintscxx . . $ DataTypeAppearance#Constraints..clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).(); |
| 155 | Constraintscxx . . $ DataTypeAppearance#Constraints..emplace_backcxx . . $ std/vector#emplace_back(b3d147e3bb711c35).(); |
| 156 | accDepcxx . . $ DataTypeAppearance#accDep..clearcxx . . $ TDepSet#clear(49f6e7a06ebc5aa8).(); |
| 157 | } |
| 158 | |
| 159 | // presence interface |
| 160 | |
| 161 | /// check if type is present positively in the node |
| 162 | bool hasPTypecxx . . $ DataTypeAppearance#hasPType(50ce9a9e25b4a850). ( void ) const { return PTypecxx . . $ DataTypeAppearance#PType. != nullptr; } |
| 163 | /// set the presence of the type depending of polarity (POS) and save a dep-set DEP; @return true if clash was found |
| 164 | bool setTypePresencecxx . . $ DataTypeAppearance#setTypePresence(8aac1513cdd44da0). ( bool pos, const DepSetcxx . . $ DepSet#& dep ) |
| 165 | { |
| 166 | DepSetcxx . . $ DepSet#*& pDep = pos ? PTypecxx . . $ DataTypeAppearance#PType. : NTypecxx . . $ DataTypeAppearance#NType.; |
| 167 | if ( likelycxx . . $ `Kernel/globaldef.h:28:10`!(pDep == nullptr) ) // 1st access |
| 168 | pDep = new DepSetcxx . . $ TDepSet#TDepSet(d0e32107376501c0).(dep); |
| 169 | else // FIXME!! think whether it is necessary to use the LATEST branching point |
| 170 | pDep->addcxx . . $ TDepSet#add(d0e32107376501c0).(dep); |
| 171 | |
| 172 | // check the case both pos- and neg types are present |
| 173 | if ( PTypecxx . . $ DataTypeAppearance#PType. != nullptr && NTypecxx . . $ DataTypeAppearance#NType. != nullptr ) |
| 174 | return reportClashcxx . . $ DataTypeAppearance#reportClash(6e83bd8e52edb65e). ( *PTypecxx . . $ DataTypeAppearance#PType.+cxx . . $ operator+(a79ac10aefecd7d4).*NTypecxx . . $ DataTypeAppearance#NType., "TNT" ); |
| 175 | return false; |
| 176 | } |
| 177 | |
| 178 | // comparison methods |
| 179 | |
| 180 | /// @return true iff there is at least one point that two DTA share |
| 181 | bool operatorcxx . . $ DataTypeAppearance#`operator==`(424a1824d79577c0). == ( const DataTypeAppearancecxx . . $ DataTypeAppearance#& other ) const; |
| 182 | /// @return true iff there is at least one point in OTHER that there is not in THIS |
| 183 | bool operatorcxx . . $ DataTypeAppearance#`operator<`(424a1824d79577c0). < ( const DataTypeAppearancecxx . . $ DataTypeAppearance#& other ) const; |
| 184 | |
| 185 | // complex methods |
| 186 | |
| 187 | /// add restrictions [POS]INT to intervals |
| 188 | bool addIntervalcxx . . $ DataTypeAppearance#addInterval(4021c1264220759f). ( bool pos, const TDataIntervalcxx . . $ TDataInterval#& Int, const DepSetcxx . . $ DepSet#& dep ) |
| 189 | { |
| 190 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llCDActioncxx . . $ llCDAction.) ) // level of logging |
| 191 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). ' ' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). (pos ? '+' : '-') <<cxx . . $ `operator<<`(71e68dfacb67ce94). Int; |
| 192 | return pos ? addPosIntervalcxx . . $ DataTypeAppearance#addPosInterval(9fad8f796b1ecb4f). ( Int, dep ) : addNegIntervalcxx . . $ DataTypeAppearance#addNegInterval(9fad8f796b1ecb4f). ( Int, dep ); |
| 193 | } |
| 194 | }; // DataTypeAppearance |
| 195 | |
| 196 | class DataTypeReasonercxx . . $ DataTypeReasoner# |
| 197 | { |
| 198 | protected: // types |
| 199 | /// vector of data types |
| 200 | typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<DataTypeAppearancecxx . . $ DataTypeAppearance#*> DTAVectorcxx . . $ DataTypeReasoner#DTAVector#; |
| 201 | /// map from positive BPs (DT pNames) to corresponding data type |
| 202 | typedef stdcxx . . $ std/::mapcxx . . $ std/map#<const TDataEntrycxx . . $ TDataEntry#*,size_tcxx . . $ size_t#> TypeMapcxx . . $ DataTypeReasoner#TypeMap#; |
| 203 | |
| 204 | protected: // members |
| 205 | /// vector of a types |
| 206 | DTAVectorcxx . . $ DataTypeReasoner#DTAVector# Typescxx . . $ DataTypeReasoner#Types.; |
| 207 | /// map Type.pName->Type appearance |
| 208 | TypeMapcxx . . $ DataTypeReasoner#TypeMap# Mapcxx . . $ DataTypeReasoner#Map.; |
| 209 | /// external DAG |
| 210 | const DLDagcxx . . $ DLDag#& DLHeapcxx . . $ DataTypeReasoner#DLHeap.; |
| 211 | /// type that has pos-entry |
| 212 | DataTypeAppearancecxx . . $ DataTypeAppearance#* posTypecxx . . $ DataTypeReasoner#posType. = nullptr; |
| 213 | /// dep-set for the clash for *all* the types |
| 214 | DepSetcxx . . $ DepSet# clashDepcxx . . $ DataTypeReasoner#clashDep.; |
| 215 | |
| 216 | protected: // methods |
| 217 | /// process data value |
| 218 | bool processDataValuecxx . . $ DataTypeReasoner#processDataValue(49ad94d50ca1887c). ( bool pos, const TDataEntrycxx . . $ TDataEntry#* c, const DepSetcxx . . $ DepSet#& dep ) |
| 219 | { |
| 220 | DataTypeAppearancecxx . . $ DataTypeAppearance#* type = getDTAbyValuecxx . . $ DataTypeReasoner#getDTAbyValue(1c0342045d0830e1).(c); |
| 221 | |
| 222 | if ( pos && setTypePresencecxx . . $ DataTypeReasoner#setTypePresence(16f7716646b17346). ( type, pos, dep ) ) |
| 223 | return true; |
| 224 | |
| 225 | // create interval [c,c] |
| 226 | TDataIntervalcxx . . $ TDataInterval# constraints; |
| 227 | constraints.updateMincxx . . $ TDataInterval#updateMin(f0fbbdfeeaf32751). ( /*excl=*/false, c->getCompcxx . . $ TDataEntry#getComp(6323d4ca51d1ffbc).() ); |
| 228 | constraints.updateMaxcxx . . $ TDataInterval#updateMax(f0fbbdfeeaf32751). ( /*excl=*/false, c->getCompcxx . . $ TDataEntry#getComp(6323d4ca51d1ffbc).() ); |
| 229 | return type->addIntervalcxx . . $ DataTypeAppearance#addInterval(4021c1264220759f). ( pos, constraints, dep ); |
| 230 | } |
| 231 | /// process data expr |
| 232 | bool processDataExprcxx . . $ DataTypeReasoner#processDataExpr(49ad94d50ca1887c). ( bool pos, const TDataEntrycxx . . $ TDataEntry#* c, const DepSetcxx . . $ DepSet#& dep ) |
| 233 | { |
| 234 | const TDataIntervalcxx . . $ TDataInterval#& constraints = *c->getFacetcxx . . $ TDataEntry#getFacet(e55f2b8bb1ed2996).(); |
| 235 | if ( constraints.emptycxx . . $ TDataInterval#empty(50ce9a9e25b4a850).() ) |
| 236 | return false; |
| 237 | DataTypeAppearancecxx . . $ DataTypeAppearance#* type = getDTAbyValuecxx . . $ DataTypeReasoner#getDTAbyValue(1c0342045d0830e1).(c); |
| 238 | if ( pos && setTypePresencecxx . . $ DataTypeReasoner#setTypePresence(16f7716646b17346). ( type, pos, dep ) ) |
| 239 | return true; |
| 240 | return type->addIntervalcxx . . $ DataTypeAppearance#addInterval(4021c1264220759f). ( pos, constraints, dep ); |
| 241 | } |
| 242 | |
| 243 | /// get data entry structure by a BP |
| 244 | const TDataEntrycxx . . $ TDataEntry#* getDataEntrycxx . . $ DataTypeReasoner#getDataEntry(8513d1ebfa7d4562). ( BipolarPointercxx . . $ BipolarPointer# p ) const |
| 245 | { return static_cast<const TDataEntrycxx . . $ TDataEntry#*>(DLHeapcxx . . $ DataTypeReasoner#DLHeap.[cxx . . $ DLDag#`operator[]`(5fe3b8e96045ba2c).p].getConceptcxx . . $ DLVertex#getConcept(1867504d72698304).()); } |
| 246 | |
| 247 | // get access to proper DataTypeAppearance |
| 248 | |
| 249 | /// get DTA by given data-type pointer |
| 250 | DataTypeAppearancecxx . . $ DataTypeAppearance#* getDTAbyTypecxx . . $ DataTypeReasoner#getDTAbyType(1c0342045d0830e1). ( const TDataEntrycxx . . $ TDataEntry#* dataType ) |
| 251 | { |
| 252 | # ifdef ENABLE_CHECKING |
| 253 | fpp_assert ( Map.find(dataType) != Map.end() ); |
| 254 | # endif |
| 255 | return Typescxx . . $ DataTypeReasoner#Types.[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).Mapcxx . . $ DataTypeReasoner#Map.[cxx . . $ std/map#`operator[]`(bbd415b616967878).dataType]]; |
| 256 | } |
| 257 | /// get DTA by given data-value pointer |
| 258 | DataTypeAppearancecxx . . $ DataTypeAppearance#* getDTAbyValuecxx . . $ DataTypeReasoner#getDTAbyValue(1c0342045d0830e1). ( const TDataEntrycxx . . $ TDataEntry#* dataValue ) |
| 259 | { |
| 260 | # ifdef ENABLE_CHECKING |
| 261 | fpp_assert ( !dataValue->isBasicDataType() ); |
| 262 | # endif |
| 263 | return getDTAbyTypecxx . . $ DataTypeReasoner#getDTAbyType(1c0342045d0830e1).(dataValue->getTypecxx . . $ TDataEntry#getType(bcfda270e2d2df96).()); |
| 264 | } |
| 265 | |
| 266 | bool setTypePresencecxx . . $ DataTypeReasoner#setTypePresence(16f7716646b17346). ( DataTypeAppearancecxx . . $ DataTypeAppearance#* type, bool pos, const DepSetcxx . . $ DepSet#& dep ) |
| 267 | { |
| 268 | // delegate negative ones to a type |
| 269 | if ( !pos ) |
| 270 | return type->setTypePresencecxx . . $ DataTypeAppearance#setTypePresence(8aac1513cdd44da0). ( /*pos=*/false, dep ); |
| 271 | |
| 272 | // setup pos-type if necessary |
| 273 | if ( posTypecxx . . $ DataTypeReasoner#posType. == nullptr ) |
| 274 | posTypecxx . . $ DataTypeReasoner#posType. = type; |
| 275 | // same type -- nothing to do |
| 276 | if ( posTypecxx . . $ DataTypeReasoner#posType. == type ) |
| 277 | return type->setTypePresencecxx . . $ DataTypeAppearance#setTypePresence(8aac1513cdd44da0). ( /*pos=*/true, dep ); |
| 278 | // the other type: clash straight away |
| 279 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llCDActioncxx . . $ llCDAction.) ) // level of logging |
| 280 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " DT-TT"; // inform about clash... |
| 281 | |
| 282 | clashDepcxx . . $ DataTypeReasoner#clashDep. =cxx . . $ TDepSet#`operator=`(6a948e2ed08fa462). *(posTypecxx . . $ DataTypeReasoner#posType.->PTypecxx . . $ DataTypeAppearance#PType.); |
| 283 | clashDepcxx . . $ DataTypeReasoner#clashDep. +=cxx . . $ TDepSet#`operator+=`(6a948e2ed08fa462). dep; |
| 284 | return true; |
| 285 | } |
| 286 | |
| 287 | public: // interface |
| 288 | /// c'tor: save DAG |
| 289 | explicit DataTypeReasonercxx . . $ DataTypeReasoner#DataTypeReasoner(dd585ec903520274). ( const DLDagcxx . . $ DLDag#& dag ) : DLHeapcxx . . $ DataTypeReasoner#DLHeap.(dag) {} |
| 290 | /// empty d'tor |
| 291 | ~cxx . . $ DataTypeReasoner#`~DataTypeReasoner`(49f6e7a06ebc5aa8).DataTypeReasonercxx . . $ DataTypeReasoner#() |
| 292 | { |
| 293 | for ( DTAVectorcxx . . $ DataTypeReasoner#DTAVector#::iteratorcxx . . $ std/vector#iterator# p = Typescxx . . $ DataTypeReasoner#Types..begincxx . . $ std/vector#begin(33b10a496a38335b).(); p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). Typescxx . . $ DataTypeReasoner#Types..endcxx . . $ std/vector#end(33b10a496a38335b).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 294 | delete *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p; |
| 295 | } |
| 296 | |
| 297 | // managing DTR |
| 298 | |
| 299 | /// add data type to the reasoner |
| 300 | void registerDataTypecxx . . $ DataTypeReasoner#registerDataType(e6573819832c2575). ( const TDataEntrycxx . . $ TDataEntry#* p ) |
| 301 | { |
| 302 | Mapcxx . . $ DataTypeReasoner#Map.[cxx . . $ std/map#`operator[]`(bbd415b616967878).p] = Typescxx . . $ DataTypeReasoner#Types..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); |
| 303 | Typescxx . . $ DataTypeReasoner#Types..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(new DataTypeAppearancecxx . . $ DataTypeAppearance#(clashDepcxx . . $ DataTypeReasoner#clashDep.)); |
| 304 | } |
| 305 | /// prepare types for the reasoning |
| 306 | void clearcxx . . $ DataTypeReasoner#clear(49f6e7a06ebc5aa8). ( void ) |
| 307 | { |
| 308 | for ( DTAVectorcxx . . $ DataTypeReasoner#DTAVector#::iteratorcxx . . $ std/vector#iterator# p = Typescxx . . $ DataTypeReasoner#Types..begincxx . . $ std/vector#begin(33b10a496a38335b).(), p_end = Typescxx . . $ DataTypeReasoner#Types..endcxx . . $ std/vector#end(33b10a496a38335b).(); p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 309 | (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->clearcxx . . $ DataTypeAppearance#clear(49f6e7a06ebc5aa8).(); |
| 310 | posTypecxx . . $ DataTypeReasoner#posType. = nullptr; |
| 311 | } |
| 312 | |
| 313 | // comparison methods |
| 314 | |
| 315 | /// @return true iff there is at least one point that two DTA share |
| 316 | bool operatorcxx . . $ DataTypeReasoner#`operator==`(ea11ccc8d5f8e779). == ( const DataTypeReasonercxx . . $ DataTypeReasoner#& other ) const |
| 317 | { |
| 318 | if ( posTypecxx . . $ DataTypeReasoner#posType. == nullptr || other.posTypecxx . . $ DataTypeReasoner#posType. == nullptr ) |
| 319 | return false; |
| 320 | return *posTypecxx . . $ DataTypeReasoner#posType. ==cxx . . $ DataTypeAppearance#`operator==`(424a1824d79577c0). *(other.posTypecxx . . $ DataTypeReasoner#posType.); |
| 321 | } |
| 322 | /// @return true iff there is at least one point in OTHER that there is not in THIS |
| 323 | bool operatorcxx . . $ DataTypeReasoner#`operator<`(ea11ccc8d5f8e779). < ( const DataTypeReasonercxx . . $ DataTypeReasoner#& other ) const |
| 324 | { |
| 325 | if ( posTypecxx . . $ DataTypeReasoner#posType. == nullptr || other.posTypecxx . . $ DataTypeReasoner#posType. == nullptr ) |
| 326 | return false; |
| 327 | return *posTypecxx . . $ DataTypeReasoner#posType. <cxx . . $ DataTypeAppearance#`operator<`(424a1824d79577c0). *(other.posTypecxx . . $ DataTypeReasoner#posType.); |
| 328 | } |
| 329 | |
| 330 | // filling structures and getting answers |
| 331 | |
| 332 | /// add data entry to the DTAVector; @return true iff data-data clash was found |
| 333 | bool addDataEntrycxx . . $ DataTypeReasoner#addDataEntry(cbd92d0fb85c8e0). ( BipolarPointercxx . . $ BipolarPointer# p, const DepSetcxx . . $ DepSet#& dep ); |
| 334 | /// get clash-set |
| 335 | const DepSetcxx . . $ DepSet#& getClashSetcxx . . $ DataTypeReasoner#getClashSet(bce6462a16d96b29). ( void ) const { return clashDepcxx . . $ DataTypeReasoner#clashDep.; } |
| 336 | }; // DataTypeReasoner |
| 337 | |
| 338 | |
| 339 | #endif |