| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef DLTBOX_H |
| 21 |
#define DLTBOX_H |
| 22 |
|
| 23 |
#include <string> |
| 24 |
#include <vector> |
| 25 |
#include <set> |
| 26 |
#include <map> |
| 27 |
|
| 28 |
#include "tConcept.h" |
| 29 |
#include "tIndividual.h" |
| 30 |
#include "modelCacheSingleton.h" |
| 31 |
#include "RoleMaster.h" |
| 32 |
#include "LogicFeature.h" |
| 33 |
#include "dlDag.h" |
| 34 |
#include "ifOptions.h" |
| 35 |
#include "PriorityMatrix.h" |
| 36 |
#include "tRelated.h" |
| 37 |
#include "tNECollection.h" |
| 38 |
#include "tAxiomSet.h" |
| 39 |
#include "DataTypeCenter.h" |
| 40 |
#include "tProgressMonitor.h" |
| 41 |
#include "tKBFlags.h" |
| 42 |
|
| 43 |
class DlSatTester; |
| 44 |
class Taxonomy; |
| 45 |
class DLConceptTaxonomy; |
| 46 |
class dumpInterface; |
| 47 |
class TSignature; |
| 48 |
class SaveLoadManager; |
| 49 |
|
| 50 |
|
| 51 |
enum KBStatus |
| 52 |
{ |
| 53 |
kbEmpty, |
| 54 |
kbLoading, |
| 55 |
kbCChecked, |
| 56 |
kbClassified, |
| 57 |
kbRealised, |
| 58 |
}; |
| 59 |
|
| 60 |
class TBox |
| 61 |
{ |
| 62 |
friend class DlSatTester; |
| 63 |
friend class NominalReasoner; |
| 64 |
friend class ReasoningKernel; |
| 65 |
friend class TAxiom; |
| 66 |
friend class DLConceptTaxonomy; |
| 67 |
|
| 68 |
public: |
| 69 |
|
| 70 |
typedef std::vector<TConcept*> ConceptVector; |
| 71 |
|
| 72 |
typedef std::vector<TIndividual*> SingletonVector; |
| 73 |
|
| 74 |
typedef std::map<const TNamedEntity*, const TSignature*> NameSigMap; |
| 75 |
|
| 76 |
protected: |
| 77 |
|
| 78 |
typedef std::vector<DLTree*> ExpressionArray; |
| 79 |
|
| 80 |
typedef TNECollection<TConcept> ConceptCollection; |
| 81 |
|
| 82 |
typedef TNECollection<TIndividual> IndividualCollection; |
| 83 |
|
| 84 |
typedef std::vector<TRelated*> RelatedCollection; |
| 85 |
|
| 86 |
typedef std::vector<SingletonVector> DifferentIndividuals; |
| 87 |
|
| 88 |
typedef std::map<TConcept*, DLTree*> ConceptDefMap; |
| 89 |
|
| 90 |
typedef std::set<TConcept*> ConceptSet; |
| 91 |
|
| 92 |
|
| 93 |
class TSimpleRule |
| 94 |
{ |
| 95 |
public: |
| 96 |
|
| 97 |
typedef TBox::ConceptVector TRuleBody; |
| 98 |
|
| 99 |
typedef TRuleBody::iterator iterator; |
| 100 |
|
| 101 |
typedef TRuleBody::const_iterator const_iterator; |
| 102 |
|
| 103 |
public: |
| 104 |
|
| 105 |
TRuleBody Body; |
| 106 |
|
| 107 |
DLTree* tHead; |
| 108 |
|
| 109 |
BipolarPointer bpHead = bpINVALID; |
| 110 |
|
| 111 |
public: |
| 112 |
|
| 113 |
TSimpleRule ( const TRuleBody& body, DLTree* head ) |
| 114 |
: Body(body) |
| 115 |
, tHead(head) |
| 116 |
{} |
| 117 |
|
| 118 |
TSimpleRule ( const TSimpleRule& ) = delete; |
| 119 |
|
| 120 |
TSimpleRule& operator= ( const TSimpleRule& ) = delete; |
| 121 |
|
| 122 |
virtual ~TSimpleRule() { deleteTree(tHead); } |
| 123 |
}; |
| 124 |
|
| 125 |
typedef std::vector<TSimpleRule*> TSimpleRules; |
| 126 |
|
| 127 |
typedef std::vector<std::pair<DLTree*,TConcept*> > TRCCache; |
| 128 |
|
| 129 |
protected: |
| 130 |
|
| 131 |
typedef ConceptCollection::iterator c_iterator; |
| 132 |
|
| 133 |
typedef IndividualCollection::iterator i_iterator; |
| 134 |
|
| 135 |
typedef ExpressionArray::const_iterator ea_iterator; |
| 136 |
|
| 137 |
public: |
| 138 |
|
| 139 |
typedef ConceptCollection::const_iterator c_const_iterator; |
| 140 |
|
| 141 |
typedef IndividualCollection::const_iterator i_const_iterator; |
| 142 |
|
| 143 |
protected: |
| 144 |
|
| 145 |
TLabeller relevance; |
| 146 |
|
| 147 |
DLDag DLHeap; |
| 148 |
|
| 149 |
|
| 150 |
DlSatTester* stdReasoner = nullptr; |
| 151 |
|
| 152 |
DlSatTester* nomReasoner = nullptr; |
| 153 |
|
| 154 |
|
| 155 |
TProgressMonitor* pMonitor = nullptr; |
| 156 |
|
| 157 |
|
| 158 |
ConceptVector arrayCD, arrayNoCD, arrayNP; |
| 159 |
|
| 160 |
Taxonomy* pTax = nullptr; |
| 161 |
|
| 162 |
DLConceptTaxonomy* pTaxCreator = nullptr; |
| 163 |
|
| 164 |
NameSigMap* pName2Sig = nullptr; |
| 165 |
|
| 166 |
DataTypeCenter DTCenter; |
| 167 |
|
| 168 |
const ifOptionSet* pOptions; |
| 169 |
|
| 170 |
KBStatus Status = kbLoading; |
| 171 |
|
| 172 |
|
| 173 |
LogicFeatures KBFeatures; |
| 174 |
|
| 175 |
LogicFeatures GCIFeatures; |
| 176 |
|
| 177 |
LogicFeatures NCFeatures; |
| 178 |
|
| 179 |
LogicFeatures auxFeatures; |
| 180 |
|
| 181 |
LogicFeatures* curFeature = nullptr; |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
TConcept* pTop; |
| 187 |
|
| 188 |
TConcept* pBottom; |
| 189 |
|
| 190 |
TConcept* pTemp; |
| 191 |
|
| 192 |
TConcept* pQuery = nullptr; |
| 193 |
|
| 194 |
|
| 195 |
ConceptCollection Concepts; |
| 196 |
|
| 197 |
IndividualCollection Individuals; |
| 198 |
|
| 199 |
RoleMaster ORM; |
| 200 |
|
| 201 |
RoleMaster DRM; |
| 202 |
|
| 203 |
TAxiomSet Axioms; |
| 204 |
|
| 205 |
RelatedCollection RelatedI; |
| 206 |
|
| 207 |
DifferentIndividuals Different; |
| 208 |
|
| 209 |
TSimpleRules SimpleRules; |
| 210 |
|
| 211 |
std::map<TConcept*, std::pair<TIndividual*,bool> > SameI; |
| 212 |
|
| 213 |
ConceptDefMap ExtraConceptDefs; |
| 214 |
|
| 215 |
|
| 216 |
BipolarPointer T_G = bpTOP; |
| 217 |
|
| 218 |
TKBFlags GCIs; |
| 219 |
|
| 220 |
|
| 221 |
TRCCache RCCache; |
| 222 |
|
| 223 |
|
| 224 |
ConceptVector ConceptMap; |
| 225 |
|
| 226 |
|
| 227 |
unsigned int nC = 0; |
| 228 |
|
| 229 |
unsigned int nR = 0; |
| 230 |
|
| 231 |
unsigned int auxConceptID = 0; |
| 232 |
|
| 233 |
unsigned int nNominalReferences = 0; |
| 234 |
|
| 235 |
unsigned long nRelevantCCalls = 0; |
| 236 |
|
| 237 |
unsigned long nRelevantBCalls = 0; |
| 238 |
|
| 239 |
|
| 240 |
std::set<TConcept*> CInProcess; |
| 241 |
|
| 242 |
std::vector<TConcept*> ToldSynonyms; |
| 243 |
|
| 244 |
|
| 245 |
ConceptVector Fairness; |
| 246 |
|
| 247 |
|
| 248 |
ToDoPriorMatrix PriorityMatrix; |
| 249 |
|
| 250 |
unsigned long testTimeout = 0; |
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
bool useSemanticBranching = true; |
| 258 |
|
| 259 |
bool useBackjumping = true; |
| 260 |
|
| 261 |
bool useLazyBlocking = true; |
| 262 |
|
| 263 |
bool useAnywhereBlocking = true; |
| 264 |
|
| 265 |
bool useNodeCache = true; |
| 266 |
|
| 267 |
int nSkipBeforeBlock = 0; |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
bool useCompletelyDefined = true; |
| 275 |
|
| 276 |
bool dumpQuery = false; |
| 277 |
|
| 278 |
bool needClassification = true; |
| 279 |
|
| 280 |
bool alwaysPreferEquals = true; |
| 281 |
|
| 282 |
bool useSpecialDomains = false; |
| 283 |
|
| 284 |
bool verboseOutput = false; |
| 285 |
|
| 286 |
bool precacheRelated = true; |
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
bool useSortedReasoning = true; |
| 294 |
|
| 295 |
bool isLikeGALEN = false; |
| 296 |
|
| 297 |
bool isLikeWINE = false; |
| 298 |
|
| 299 |
|
| 300 |
bool Consistent = true; |
| 301 |
|
| 302 |
|
| 303 |
float preprocTime = 0.0; |
| 304 |
|
| 305 |
float consistTime = 0.0; |
| 306 |
|
| 307 |
protected: |
| 308 |
|
| 309 |
void readConfig ( const ifOptionSet* Options ); |
| 310 |
|
| 311 |
void initTopBottom ( void ); |
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
c_iterator c_begin ( void ) { return Concepts.begin(); } |
| 320 |
|
| 321 |
c_iterator c_end ( void ) { return Concepts.end(); } |
| 322 |
|
| 323 |
|
| 324 |
i_iterator i_begin ( void ) { return Individuals.begin(); } |
| 325 |
|
| 326 |
i_iterator i_end ( void ) { return Individuals.end(); } |
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
static TConcept* toConcept ( TNamedEntry* id ) { return static_cast<TConcept*>(id); } |
| 334 |
|
| 335 |
static const TConcept* toConcept ( const TNamedEntry* id ) { return static_cast<const TConcept*>(id); } |
| 336 |
|
| 337 |
static TIndividual* toIndividual ( TNamedEntry* id ) { return static_cast<TIndividual*>(id); } |
| 338 |
|
| 339 |
static const TIndividual* toIndividual ( const TNamedEntry* id ) { return static_cast<const TIndividual*>(id); } |
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
void setBPforConcept ( BipolarPointer bp, TConcept* p ) |
| 347 |
{ |
| 348 |
DLHeap[bp].setConcept(p); |
| 349 |
p->pName = bp; |
| 350 |
} |
| 351 |
|
| 352 |
|
| 353 |
TDataEntry* getDataEntryByBP ( BipolarPointer bp ) |
| 354 |
{ |
| 355 |
TDataEntry* p = static_cast<TDataEntry*>(DLHeap[bp].getConcept()); |
| 356 |
fpp_assert ( p != nullptr ); |
| 357 |
return p; |
| 358 |
} |
| 359 |
|
| 360 |
const TDataEntry* getDataEntryByBP ( BipolarPointer bp ) const |
| 361 |
{ |
| 362 |
const TDataEntry* p = static_cast<const TDataEntry*>(DLHeap[bp].getConcept()); |
| 363 |
fpp_assert ( p != nullptr ); |
| 364 |
return p; |
| 365 |
} |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
void checkEarlySynonym ( TConcept* C ) |
| 374 |
{ |
| 375 |
if ( C->isSynonym() ) |
| 376 |
return; |
| 377 |
if ( C->isPrimitive() ) |
| 378 |
return; |
| 379 |
if ( !isCN(C->Description) ) |
| 380 |
return; |
| 381 |
|
| 382 |
C->setSynonym(getCI(C->Description)); |
| 383 |
C->initToldSubsumers(); |
| 384 |
} |
| 385 |
|
| 386 |
DLTree* makeNonPrimitive ( TConcept* C, DLTree* desc ) |
| 387 |
{ |
| 388 |
DLTree* ret = C->makeNonPrimitive(desc); |
| 389 |
checkEarlySynonym(C); |
| 390 |
return ret; |
| 391 |
} |
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
template <typename Iterator> |
| 399 |
DLTree* buildDisjAux ( Iterator beg, Iterator end ) |
| 400 |
{ |
| 401 |
DLTree* t = createTop(); |
| 402 |
for ( Iterator i = beg; i < end; ++i ) |
| 403 |
t = createSNFAnd ( t, createSNFNot(clone(*i)) ); |
| 404 |
return t; |
| 405 |
} |
| 406 |
|
| 407 |
template <typename Iterator> |
| 408 |
void processDisjoint ( Iterator beg, Iterator end ) |
| 409 |
{ |
| 410 |
for ( Iterator i = beg; i < end; ++i ) |
| 411 |
addSubsumeAxiom ( *i, buildDisjAux ( i+1, end ) ); |
| 412 |
} |
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
void buildDAG ( void ); |
| 419 |
|
| 420 |
|
| 421 |
void addConceptToHeap ( TConcept* p ); |
| 422 |
|
| 423 |
BipolarPointer addDataExprToHeap ( TDataEntry* p ); |
| 424 |
|
| 425 |
BipolarPointer tree2dag ( const DLTree* ); |
| 426 |
|
| 427 |
BipolarPointer forall2dag ( const TRole* R, BipolarPointer C ); |
| 428 |
|
| 429 |
BipolarPointer atmost2dag ( unsigned int n, const TRole* R, BipolarPointer C ); |
| 430 |
|
| 431 |
BipolarPointer reflexive2dag ( const TRole* R ) |
| 432 |
{ |
| 433 |
|
| 434 |
if ( !R->isSimple() ) |
| 435 |
throw EFPPNonSimpleRole(R->getName()); |
| 436 |
return inverse ( DLHeap.add ( new DLVertex ( dtIrr, R ) ) ); |
| 437 |
} |
| 438 |
|
| 439 |
BipolarPointer and2dag ( const DLTree* t ); |
| 440 |
|
| 441 |
bool fillANDVertex ( DLVertex* v, const DLTree* t ); |
| 442 |
|
| 443 |
BipolarPointer dataForall2dag ( const TRole* R, BipolarPointer C ) |
| 444 |
{ return DLHeap.add ( new DLVertex ( dtForall, 0, R, C ) ); } |
| 445 |
|
| 446 |
BipolarPointer dataAtMost2dag ( unsigned int n, const TRole* R, BipolarPointer C ) |
| 447 |
{ return DLHeap.add ( new DLVertex ( dtLE, n, R, C ) ); } |
| 448 |
|
| 449 |
BipolarPointer concept2dag ( TConcept* p ) |
| 450 |
{ |
| 451 |
if ( p == nullptr ) |
| 452 |
return bpINVALID; |
| 453 |
if ( !isValid(p->pName) ) |
| 454 |
addConceptToHeap(p); |
| 455 |
return p->resolveId(); |
| 456 |
} |
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
bool setForbidUndefinedNames ( bool val ) |
| 464 |
{ |
| 465 |
ORM.setUndefinedNames(!val); |
| 466 |
DRM.setUndefinedNames(!val); |
| 467 |
Individuals.setLocked(val); |
| 468 |
return Concepts.setLocked(val); |
| 469 |
} |
| 470 |
|
| 471 |
DLTree* applyAxiomCToCN ( DLTree* C, DLTree* CN ); |
| 472 |
|
| 473 |
DLTree* applyAxiomCNToC ( DLTree* CN, DLTree* C ); |
| 474 |
|
| 475 |
bool addNonprimitiveDefinition ( TConcept* C, DLTree* rhs ); |
| 476 |
|
| 477 |
bool switchToNonprimitive ( TConcept* C, DLTree* rhs ); |
| 478 |
|
| 479 |
|
| 480 |
void makeDefinitionPrimitive ( TConcept* C, DLTree* E, DLTree* D ) |
| 481 |
{ |
| 482 |
C->setPrimitive(); |
| 483 |
C->addDesc(E); |
| 484 |
C->initToldSubsumers(); |
| 485 |
|
| 486 |
addSubsumeAxiom ( D, getTree(C) ); |
| 487 |
} |
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
void processGCI ( DLTree* C, DLTree* D ) { Axioms.addAxiom ( C, D ); } |
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
bool axiomToRangeDomain ( DLTree* l, DLTree* r ); |
| 496 |
|
| 497 |
|
| 498 |
bool isNamedConcept ( BipolarPointer bp ) const |
| 499 |
{ |
| 500 |
DagTag tag = DLHeap[bp].Type(); |
| 501 |
return isCNameTag(tag) || tag == dtDataType || tag == dtDataValue; |
| 502 |
} |
| 503 |
|
| 504 |
|
| 505 |
TConcept* getRCCache ( const DLTree* C ) const |
| 506 |
{ |
| 507 |
for ( TRCCache::const_iterator p = RCCache.begin(), p_end = RCCache.end(); p < p_end; ++p ) |
| 508 |
if ( equalTrees ( C, p->first ) ) |
| 509 |
return p->second; |
| 510 |
return nullptr; |
| 511 |
} |
| 512 |
|
| 513 |
void setRCCache ( DLTree* C, TConcept* CN ) { RCCache.push_back(std::make_pair(C,CN)); } |
| 514 |
|
| 515 |
|
| 516 |
bool isGalenLikeTBox ( void ) const { return isLikeGALEN; } |
| 517 |
|
| 518 |
bool isWineLikeTBox ( void ) const { return isLikeWINE; } |
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
void Preprocess ( void ); |
| 526 |
|
| 527 |
void TransformExtraSubsumptions ( void ); |
| 528 |
|
| 529 |
void AbsorbAxioms ( void ) |
| 530 |
{ |
| 531 |
unsigned int nSynonyms = countSynonyms(); |
| 532 |
Axioms.absorb(); |
| 533 |
if ( countSynonyms() > nSynonyms ) |
| 534 |
replaceAllSynonyms(); |
| 535 |
if ( Axioms.wasRoleAbsorptionApplied() ) |
| 536 |
initToldSubsumers(); |
| 537 |
} |
| 538 |
|
| 539 |
|
| 540 |
void preprocessRelated ( void ); |
| 541 |
|
| 542 |
void determineSorts ( void ); |
| 543 |
|
| 544 |
|
| 545 |
void CalculateStatistic ( void ); |
| 546 |
|
| 547 |
void RemoveExtraDescriptions ( void ); |
| 548 |
|
| 549 |
|
| 550 |
void initRangeDomain ( RoleMaster& RM ); |
| 551 |
|
| 552 |
|
| 553 |
void initToldSubsumers ( void ) |
| 554 |
{ |
| 555 |
for ( c_iterator pc = c_begin(); pc != c_end(); ++pc ) |
| 556 |
if ( !(*pc)->isSynonym() ) |
| 557 |
(*pc)->initToldSubsumers(); |
| 558 |
for ( i_iterator pi = i_begin(); pi != i_end(); ++pi ) |
| 559 |
if ( !(*pi)->isSynonym() ) |
| 560 |
(*pi)->initToldSubsumers(); |
| 561 |
} |
| 562 |
|
| 563 |
void setToldTop ( void ) |
| 564 |
{ |
| 565 |
for ( c_iterator pc = c_begin(); pc != c_end(); ++pc ) |
| 566 |
(*pc)->setToldTop(pTop); |
| 567 |
for ( i_iterator pi = i_begin(); pi != i_end(); ++pi ) |
| 568 |
(*pi)->setToldTop(pTop); |
| 569 |
} |
| 570 |
|
| 571 |
void calculateTSDepth ( void ) |
| 572 |
{ |
| 573 |
for ( c_iterator pc = c_begin(); pc != c_end(); ++pc ) |
| 574 |
(*pc)->calculateTSDepth(); |
| 575 |
for ( i_iterator pi = i_begin(); pi != i_end(); ++pi ) |
| 576 |
(*pi)->calculateTSDepth(); |
| 577 |
} |
| 578 |
|
| 579 |
|
| 580 |
void transformToldCycles ( void ); |
| 581 |
|
| 582 |
|
| 583 |
TConcept* checkToldCycle ( TConcept* p ); |
| 584 |
|
| 585 |
void transformSingletonHierarchy ( void ); |
| 586 |
|
| 587 |
TIndividual* transformSingletonWithSP ( TConcept* p ); |
| 588 |
|
| 589 |
TIndividual* getSPForConcept ( TConcept* p ); |
| 590 |
|
| 591 |
|
| 592 |
bool isReferenced ( TConcept* C, DLTree* tree, ConceptSet& processed ) const; |
| 593 |
|
| 594 |
bool isReferenced ( TConcept* C, TConcept* D, ConceptSet& processed ) const |
| 595 |
{ |
| 596 |
|
| 597 |
processed.insert(D); |
| 598 |
|
| 599 |
if ( D->Description == nullptr ) |
| 600 |
return false; |
| 601 |
if ( isReferenced ( C, D->Description, processed ) ) |
| 602 |
return true; |
| 603 |
|
| 604 |
if ( D->isPrimitive() ) |
| 605 |
return false; |
| 606 |
|
| 607 |
auto p = ExtraConceptDefs.find(D); |
| 608 |
if ( p != ExtraConceptDefs.end() ) |
| 609 |
return isReferenced ( C, p->second, processed ); |
| 610 |
return false; |
| 611 |
} |
| 612 |
|
| 613 |
|
| 614 |
unsigned int countSynonyms ( void ) const |
| 615 |
{ |
| 616 |
unsigned int nSynonyms = 0; |
| 617 |
for ( c_const_iterator pc = c_begin(); pc != c_end(); ++pc ) |
| 618 |
if ( (*pc)->isSynonym() ) |
| 619 |
++nSynonyms; |
| 620 |
|
| 621 |
for ( i_const_iterator pi = i_begin(); pi != i_end(); ++pi ) |
| 622 |
if ( (*pi)->isSynonym() ) |
| 623 |
++nSynonyms; |
| 624 |
return nSynonyms; |
| 625 |
} |
| 626 |
|
| 627 |
void replaceAllSynonyms ( void ); |
| 628 |
|
| 629 |
|
| 630 |
inline void |
| 631 |
initRuleFields ( const ConceptVector& v, size_t index ) const |
| 632 |
{ |
| 633 |
for ( ConceptVector::const_iterator q = v.begin(), q_end = v.end(); q < q_end; ++q ) |
| 634 |
(*q)->addExtraRule(index); |
| 635 |
} |
| 636 |
|
| 637 |
void fillsClassificationTag ( void ) |
| 638 |
{ |
| 639 |
for ( c_const_iterator pc = c_begin(); pc != c_end(); ++pc ) |
| 640 |
(*pc)->getClassTag(); |
| 641 |
for ( i_const_iterator pi = i_begin(); pi != i_end(); ++pi ) |
| 642 |
(*pi)->getClassTag(); |
| 643 |
} |
| 644 |
|
| 645 |
void setConceptIndex ( TConcept* C ) |
| 646 |
{ |
| 647 |
C->setIndex(nC); |
| 648 |
ConceptMap.push_back(C); |
| 649 |
++nC; |
| 650 |
} |
| 651 |
|
| 652 |
void setAllIndexes ( void ); |
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
bool reasonersInited ( void ) const { return stdReasoner != nullptr; } |
| 660 |
|
| 661 |
DlSatTester* getReasoner ( void ) |
| 662 |
{ |
| 663 |
fpp_assert ( curFeature != nullptr ); |
| 664 |
if ( curFeature->hasSingletons() ) |
| 665 |
return nomReasoner; |
| 666 |
else |
| 667 |
return stdReasoner; |
| 668 |
} |
| 669 |
|
| 670 |
const DlSatTester* getReasoner ( void ) const |
| 671 |
{ |
| 672 |
fpp_assert ( curFeature != nullptr ); |
| 673 |
if ( curFeature->hasSingletons() ) |
| 674 |
return nomReasoner; |
| 675 |
else |
| 676 |
return stdReasoner; |
| 677 |
} |
| 678 |
|
| 679 |
bool performConsistencyCheck ( void ); |
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
void initReasoner ( void ); |
| 687 |
|
| 688 |
void initTaxonomy ( void ); |
| 689 |
|
| 690 |
void setNameSigMap ( NameSigMap* p ) { pName2Sig = p; } |
| 691 |
|
| 692 |
void createTaxonomy ( bool needIndividuals ); |
| 693 |
|
| 694 |
template <typename Iterator> |
| 695 |
unsigned int fillArrays ( Iterator begin, Iterator end ) |
| 696 |
{ |
| 697 |
unsigned int n = 0; |
| 698 |
for ( Iterator p = begin; p < end; ++p ) |
| 699 |
{ |
| 700 |
if ( (*p)->isNonClassifiable() ) |
| 701 |
continue; |
| 702 |
++n; |
| 703 |
switch ( (*p)->getClassTag() ) |
| 704 |
{ |
| 705 |
case cttTrueCompletelyDefined: |
| 706 |
arrayCD.push_back(*p); |
| 707 |
break; |
| 708 |
default: |
| 709 |
arrayNoCD.push_back(*p); |
| 710 |
break; |
| 711 |
case cttNonPrimitive: |
| 712 |
case cttHasNonPrimitiveTS: |
| 713 |
arrayNP.push_back(*p); |
| 714 |
break; |
| 715 |
} |
| 716 |
} |
| 717 |
|
| 718 |
return n; |
| 719 |
} |
| 720 |
|
| 721 |
void classifyConcepts ( const ConceptVector& collection, bool curCompletelyDefined, const char* type ); |
| 722 |
|
| 723 |
void classifyEntry ( TConcept* entry ); |
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
void initConstCache ( BipolarPointer p ) { DLHeap.setCache ( p, createConstCache(p) ); } |
| 731 |
|
| 732 |
void initSingletonCache ( const TConcept* p, bool pos ) |
| 733 |
{ DLHeap.setCache ( createBiPointer(p->pName,pos), new modelCacheSingleton(createBiPointer(p->index(),pos)) ); } |
| 734 |
|
| 735 |
void buildSimpleCache ( void ); |
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
void PrintDagEntry ( std::ostream& o, BipolarPointer p ) const; |
| 742 |
|
| 743 |
void PrintConcept ( std::ostream& o, const TConcept* p ) const; |
| 744 |
|
| 745 |
void PrintConcepts ( std::ostream& o ) const |
| 746 |
{ |
| 747 |
if ( Concepts.size() == 0 ) |
| 748 |
return; |
| 749 |
o << "Concepts (" << Concepts.size() << "):\n"; |
| 750 |
for ( c_const_iterator pc = c_begin(); pc != c_end(); ++pc ) |
| 751 |
PrintConcept(o,*pc); |
| 752 |
} |
| 753 |
|
| 754 |
void PrintIndividuals ( std::ostream& o ) const |
| 755 |
{ |
| 756 |
if ( Individuals.size() == 0 ) |
| 757 |
return; |
| 758 |
o << "Individuals (" << Individuals.size() << "):\n"; |
| 759 |
for ( i_const_iterator pi = i_begin(); pi != i_end(); ++pi ) |
| 760 |
PrintConcept(o,*pi); |
| 761 |
} |
| 762 |
void PrintSimpleRules ( std::ostream& o ) const |
| 763 |
{ |
| 764 |
if ( SimpleRules.empty() ) |
| 765 |
return; |
| 766 |
o << "Simple rules (" << SimpleRules.size() << "):\n"; |
| 767 |
for ( TSimpleRules::const_iterator p = SimpleRules.begin(); p < SimpleRules.end(); ++p ) |
| 768 |
{ |
| 769 |
ConceptVector::const_iterator q = (*p)->Body.begin(), q_end = (*p)->Body.end(); |
| 770 |
o << "(" << (*q)->getName(); |
| 771 |
while ( ++q < q_end ) |
| 772 |
o << ", " << (*q)->getName(); |
| 773 |
o << ") => " << (*p)->tHead << "\n"; |
| 774 |
} |
| 775 |
} |
| 776 |
void PrintAxioms ( std::ostream& o ) const |
| 777 |
{ |
| 778 |
if ( T_G == bpTOP ) |
| 779 |
return; |
| 780 |
o << "Axioms:\nT [="; |
| 781 |
PrintDagEntry ( o, T_G ); |
| 782 |
} |
| 783 |
|
| 784 |
void printFeatures ( void ) const; |
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
bool isRelevant ( const TConcept* p ) const { return p->isRelevant(relevance); } |
| 795 |
|
| 796 |
void setRelevant1 ( TConcept* p ); |
| 797 |
|
| 798 |
void setRelevant ( TConcept* p ) { if ( !isRelevant(p) ) setRelevant1(p); } |
| 799 |
|
| 800 |
|
| 801 |
bool isRelevant ( const TRole* p ) const { return p->isRelevant(relevance); } |
| 802 |
|
| 803 |
void setRelevant1 ( TRole* p ); |
| 804 |
|
| 805 |
void setRelevant ( TRole* p ) |
| 806 |
{ |
| 807 |
if ( ( likely(p->getId() != 0) || p->isTop() ) && !isRelevant(p) ) |
| 808 |
setRelevant1(p); |
| 809 |
} |
| 810 |
|
| 811 |
|
| 812 |
void setRelevant ( BipolarPointer p ); |
| 813 |
|
| 814 |
|
| 815 |
void collectLogicFeature ( const TConcept* p ) const |
| 816 |
{ |
| 817 |
if ( curFeature ) |
| 818 |
curFeature->fillConceptData(p); |
| 819 |
} |
| 820 |
|
| 821 |
void collectLogicFeature ( const TRole* p ) const |
| 822 |
{ |
| 823 |
if ( curFeature ) |
| 824 |
curFeature->fillRoleData ( p, isRelevant(p->inverse()) ); |
| 825 |
} |
| 826 |
|
| 827 |
void collectLogicFeature ( const DLVertex& v, bool pos ) const |
| 828 |
{ |
| 829 |
if ( curFeature ) |
| 830 |
curFeature->fillDAGData ( v, pos ); |
| 831 |
} |
| 832 |
|
| 833 |
void markGCIsRelevant ( void ) { setRelevant(T_G); } |
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
|
| 838 |
|
| 839 |
void markAllRelevant ( void ) |
| 840 |
{ |
| 841 |
for ( c_iterator pc = c_begin(); pc != c_end(); ++pc ) |
| 842 |
setRelevant(*pc); |
| 843 |
for ( i_iterator pi = i_begin(); pi != i_end(); ++pi ) |
| 844 |
setRelevant(*pi); |
| 845 |
|
| 846 |
markGCIsRelevant(); |
| 847 |
} |
| 848 |
|
| 849 |
void calculateRelevant ( TConcept* p, TConcept* q ) |
| 850 |
{ |
| 851 |
setRelevant(p); |
| 852 |
if ( q != nullptr ) |
| 853 |
setRelevant(q); |
| 854 |
markGCIsRelevant(); |
| 855 |
} |
| 856 |
|
| 857 |
void clearRelevanceInfo ( void ) { relevance.newLabel(); } |
| 858 |
|
| 859 |
void gatherRelevanceInfo ( void ); |
| 860 |
|
| 861 |
void setConceptRelevant ( TConcept* p ) |
| 862 |
{ |
| 863 |
curFeature = &p->posFeatures; |
| 864 |
setRelevant(p->pBody); |
| 865 |
KBFeatures |= p->posFeatures; |
| 866 |
collectLogicFeature(p); |
| 867 |
clearRelevanceInfo(); |
| 868 |
|
| 869 |
|
| 870 |
if ( p->isPrimitive() ) |
| 871 |
return; |
| 872 |
|
| 873 |
curFeature = &p->negFeatures; |
| 874 |
setRelevant(inverse(p->pBody)); |
| 875 |
KBFeatures |= p->negFeatures; |
| 876 |
clearRelevanceInfo(); |
| 877 |
} |
| 878 |
|
| 879 |
void updateAuxFeatures ( const LogicFeatures& lf ) |
| 880 |
{ |
| 881 |
if ( !lf.empty() ) |
| 882 |
{ |
| 883 |
auxFeatures |= lf; |
| 884 |
auxFeatures.mergeRoles(); |
| 885 |
} |
| 886 |
} |
| 887 |
|
| 888 |
void prepareFeatures ( const TConcept* pConcept, const TConcept* qConcept ); |
| 889 |
|
| 890 |
void clearFeatures ( void ) { curFeature = nullptr; } |
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
void dumpConcept ( dumpInterface* dump, const TConcept* p ) const; |
| 897 |
|
| 898 |
void dumpRole ( dumpInterface* dump, const TRole* p ) const; |
| 899 |
|
| 900 |
void dumpExpression ( dumpInterface* dump, BipolarPointer p ) const; |
| 901 |
|
| 902 |
void dumpAllRoles ( dumpInterface* dump ) const; |
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
void initPointerMaps ( SaveLoadManager& m ) const; |
| 910 |
|
| 911 |
public: |
| 912 |
|
| 913 |
TBox ( const ifOptionSet* Options, |
| 914 |
const std::string& TopORoleName, |
| 915 |
const std::string& BotORoleName, |
| 916 |
const std::string& TopDRoleName, |
| 917 |
const std::string& BotDRoleName ); |
| 918 |
|
| 919 |
TBox ( const TBox& ) = delete; |
| 920 |
|
| 921 |
TBox& operator = ( const TBox& ) = delete; |
| 922 |
|
| 923 |
~TBox(); |
| 924 |
|
| 925 |
|
| 926 |
RoleMaster& getORM ( void ) { return ORM; } |
| 927 |
|
| 928 |
const RoleMaster& getORM ( void ) const { return ORM; } |
| 929 |
|
| 930 |
RoleMaster& getDRM ( void ) { return DRM; } |
| 931 |
|
| 932 |
const RoleMaster& getDRM ( void ) const { return DRM; } |
| 933 |
|
| 934 |
RoleMaster& getRM ( const TRole* R ) { return R->isDataRole() ? getDRM() : getORM(); } |
| 935 |
|
| 936 |
const RoleMaster& getRM ( const TRole* R ) const { return R->isDataRole() ? getDRM() : getORM(); } |
| 937 |
|
| 938 |
DataTypeCenter& getDataTypeCenter ( void ) { return DTCenter; } |
| 939 |
|
| 940 |
const DataTypeCenter& getDataTypeCenter ( void ) const { return DTCenter; } |
| 941 |
|
| 942 |
const DLDag& getDag ( void ) const { return DLHeap; } |
| 943 |
|
| 944 |
|
| 945 |
void setTestTimeout ( unsigned long value ) { testTimeout = value; } |
| 946 |
|
| 947 |
void setUseUndefinedNames ( bool value ) { Concepts.setAllowFresh(value); } |
| 948 |
|
| 949 |
void setUseNodeCache ( bool val ) { useNodeCache = val; } |
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
TConcept* getConcept ( const std::string& name ) { return Concepts.get(name); } |
| 957 |
|
| 958 |
TIndividual* getIndividual ( const std::string& name ) { return Individuals.get(name); } |
| 959 |
|
| 960 |
|
| 961 |
bool isIndividual ( const std::string& name ) const { return Individuals.isRegistered(name); } |
| 962 |
|
| 963 |
bool isIndividual ( const TNamedEntry* entry ) const { return isIndividual(entry->getName()); } |
| 964 |
|
| 965 |
bool isIndividual ( const DLTree* tree ) const |
| 966 |
{ return (tree->Element().getToken() == INAME && isIndividual(tree->Element().getNE())); } |
| 967 |
|
| 968 |
static bool isDataValue ( const DLTree* entry ) |
| 969 |
{ |
| 970 |
return entry->Element().getToken() == DATAEXPR && |
| 971 |
static_cast<const TDataEntry*>(entry->Element().getNE())->isDataValue(); |
| 972 |
} |
| 973 |
|
| 974 |
|
| 975 |
TConcept* getCI ( const DLTree* name ) |
| 976 |
{ |
| 977 |
if ( name->Element() == TOP ) |
| 978 |
return pTop; |
| 979 |
if ( name->Element() == BOTTOM ) |
| 980 |
return pBottom; |
| 981 |
|
| 982 |
if ( !isName(name) ) |
| 983 |
return nullptr; |
| 984 |
|
| 985 |
if ( name->Element().getToken() == CNAME ) |
| 986 |
return toConcept(name->Element().getNE()); |
| 987 |
else |
| 988 |
return toIndividual(name->Element().getNE()); |
| 989 |
} |
| 990 |
|
| 991 |
DLTree* getTree ( TConcept* C ) const |
| 992 |
{ |
| 993 |
if ( C == nullptr ) |
| 994 |
return nullptr; |
| 995 |
if ( C == pTop ) |
| 996 |
return createTop(); |
| 997 |
if ( C == pBottom ) |
| 998 |
return createBottom(); |
| 999 |
return createEntry ( isIndividual(C) ? INAME : CNAME, C ); |
| 1000 |
} |
| 1001 |
|
| 1002 |
DLTree* getFreshConcept ( void ) const { return createEntry ( CNAME, pTemp ); } |
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
TConcept* getAuxConcept ( DLTree* desc = nullptr ); |
| 1008 |
|
| 1009 |
TConcept* replaceForall ( DLTree* RC ); |
| 1010 |
|
| 1011 |
bool isCyclic ( TConcept* C ) const |
| 1012 |
{ |
| 1013 |
ConceptSet processed; |
| 1014 |
return isReferenced ( C, C, processed ); |
| 1015 |
} |
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
void RegisterIndividualRelation ( TNamedEntry* a, TNamedEntry* R, TNamedEntry* b ) |
| 1023 |
{ |
| 1024 |
if ( !isIndividual(a) || !isIndividual(b) ) |
| 1025 |
throw EFaCTPlusPlus("Individual expected in related()"); |
| 1026 |
RelatedI.push_back ( new |
| 1027 |
TRelated ( toIndividual(a), |
| 1028 |
toIndividual(b), |
| 1029 |
static_cast<TRole*>(R) ) ); |
| 1030 |
RelatedI.push_back ( new |
| 1031 |
TRelated ( toIndividual(b), |
| 1032 |
toIndividual(a), |
| 1033 |
static_cast<TRole*>(R)->inverse() ) ); |
| 1034 |
} |
| 1035 |
|
| 1036 |
|
| 1037 |
void addSubsumeAxiom ( DLTree* C, DLTree* D ); |
| 1038 |
|
| 1039 |
void addSubsumeAxiom ( TConcept* C, DLTree* D ) { addSubsumeAxiom ( getTree(C), D ); } |
| 1040 |
|
| 1041 |
void addSubsumeForDefined ( TConcept* C, DLTree* E ); |
| 1042 |
|
| 1043 |
void addEqualityAxiom ( DLTree* lhs, DLTree* rhs ); |
| 1044 |
|
| 1045 |
|
| 1046 |
inline |
| 1047 |
void addSimpleRule ( TSimpleRule* Rule ) |
| 1048 |
{ |
| 1049 |
initRuleFields ( Rule->Body, SimpleRules.size() ); |
| 1050 |
SimpleRules.push_back(Rule); |
| 1051 |
} |
| 1052 |
|
| 1053 |
void addBSimpleRule ( TConcept* C0, TConcept* C1, DLTree* H ) |
| 1054 |
{ |
| 1055 |
ConceptVector v; |
| 1056 |
v.push_back(C0); |
| 1057 |
v.push_back(C1); |
| 1058 |
addSimpleRule ( new TSimpleRule ( v, H ) ); |
| 1059 |
} |
| 1060 |
|
| 1061 |
|
| 1062 |
void processEquivalentC ( ea_iterator beg, ea_iterator end ); |
| 1063 |
void processDisjointC ( ea_iterator beg, ea_iterator end ); |
| 1064 |
void processEquivalentR ( ea_iterator beg, ea_iterator end ); |
| 1065 |
void processDisjointR ( ea_iterator beg, ea_iterator end ); |
| 1066 |
void processSame ( ea_iterator beg, ea_iterator end ); |
| 1067 |
void processDifferent ( ea_iterator beg, ea_iterator end ); |
| 1068 |
|
| 1069 |
|
| 1070 |
void finishLoading ( void ) { setForbidUndefinedNames(true); } |
| 1071 |
|
| 1072 |
bool hasFC ( void ) const { return !Fairness.empty(); } |
| 1073 |
|
| 1074 |
void setFairnessConstraint ( ea_iterator beg, ea_iterator end ) |
| 1075 |
{ |
| 1076 |
for ( ; beg < end; ++beg ) |
| 1077 |
if ( isName(*beg) ) |
| 1078 |
{ |
| 1079 |
Fairness.push_back(getCI(*beg)); |
| 1080 |
deleteTree(*beg); |
| 1081 |
} |
| 1082 |
else |
| 1083 |
{ |
| 1084 |
|
| 1085 |
TConcept* fc = getAuxConcept(); |
| 1086 |
Fairness.push_back(fc); |
| 1087 |
|
| 1088 |
addEqualityAxiom ( getTree(fc), *beg ); |
| 1089 |
} |
| 1090 |
|
| 1091 |
if ( useAnywhereBlocking && hasFC() ) |
| 1092 |
{ |
| 1093 |
useAnywhereBlocking = false; |
| 1094 |
if ( LLM.isWritable(llAlways) ) |
| 1095 |
LL << "\nFairness constraints: set useAnywhereBlocking = 0"; |
| 1096 |
} |
| 1097 |
} |
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
BipolarPointer getTG ( void ) const { return T_G; } |
| 1105 |
|
| 1106 |
const TSimpleRule* getSimpleRule ( size_t index ) const { return SimpleRules[index]; } |
| 1107 |
|
| 1108 |
|
| 1109 |
bool isIRinQuery ( void ) const |
| 1110 |
{ |
| 1111 |
if ( curFeature != nullptr ) |
| 1112 |
return curFeature->hasInverseRole(); |
| 1113 |
else |
| 1114 |
return KBFeatures.hasInverseRole(); |
| 1115 |
} |
| 1116 |
|
| 1117 |
bool isNRinQuery ( void ) const |
| 1118 |
{ |
| 1119 |
const LogicFeatures* p = curFeature ? curFeature : &KBFeatures; |
| 1120 |
return p->hasFunctionalRestriction() || p->hasNumberRestriction() || p->hasQNumberRestriction(); |
| 1121 |
} |
| 1122 |
|
| 1123 |
bool testHasNominals ( void ) const |
| 1124 |
{ |
| 1125 |
if ( curFeature != nullptr ) |
| 1126 |
return curFeature->hasSingletons(); |
| 1127 |
else |
| 1128 |
return KBFeatures.hasSingletons(); |
| 1129 |
} |
| 1130 |
|
| 1131 |
bool testHasTopRole ( void ) const |
| 1132 |
{ |
| 1133 |
if ( curFeature != nullptr ) |
| 1134 |
return curFeature->hasTopRole(); |
| 1135 |
else |
| 1136 |
return KBFeatures.hasTopRole(); |
| 1137 |
} |
| 1138 |
|
| 1139 |
bool canUseSortedReasoning ( void ) const |
| 1140 |
{ return useSortedReasoning && !GCIs.isGCI() && !GCIs.isReflexive(); } |
| 1141 |
|
| 1142 |
|
| 1143 |
bool isBlockedInd ( TConcept* C ) const { return SameI.find(C) != SameI.end(); } |
| 1144 |
|
| 1145 |
TIndividual* getBlockingInd ( TConcept* C ) const { return SameI.find(C)->second.first; } |
| 1146 |
|
| 1147 |
bool isBlockingDet ( TConcept* C ) const { return SameI.find(C)->second.second; } |
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
c_const_iterator c_begin ( void ) const { return Concepts.begin(); } |
| 1155 |
|
| 1156 |
c_const_iterator c_end ( void ) const { return Concepts.end(); } |
| 1157 |
|
| 1158 |
|
| 1159 |
i_const_iterator i_begin ( void ) const { return Individuals.begin(); } |
| 1160 |
|
| 1161 |
i_const_iterator i_end ( void ) const { return Individuals.end(); } |
| 1162 |
|
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
void prepareReasoning ( void ); |
| 1168 |
|
| 1169 |
void performClassification ( void ) { createTaxonomy ( false ); } |
| 1170 |
|
| 1171 |
void performRealisation ( void ) { createTaxonomy ( true ); } |
| 1172 |
|
| 1173 |
void reclassify ( const std::set<const TNamedEntity*>& MPlus, const std::set<const TNamedEntity*>& MMinus ); |
| 1174 |
|
| 1175 |
|
| 1176 |
Taxonomy* getTaxonomy ( void ) { return pTax; } |
| 1177 |
|
| 1178 |
|
| 1179 |
void setProgressMonitor ( TProgressMonitor* pMon ) { pMonitor = pMon; } |
| 1180 |
|
| 1181 |
bool isCancelled ( void ) const { return pMonitor != nullptr && pMonitor->isCancelled(); } |
| 1182 |
|
| 1183 |
void setVerboseOutput ( bool value ) { verboseOutput = value; } |
| 1184 |
|
| 1185 |
|
| 1186 |
TConcept* createQueryConcept ( const DLTree* query ); |
| 1187 |
|
| 1188 |
void preprocessQueryConcept ( TConcept* query ); |
| 1189 |
|
| 1190 |
void classifyQueryConcept ( void ); |
| 1191 |
|
| 1192 |
void clearQueryConcept ( void ) { DLHeap.removeQuery(); } |
| 1193 |
|
| 1194 |
bool isComplexQuery ( const TConcept* queryConcept ) const { return queryConcept == pQuery; } |
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
|
| 1199 |
|
| 1200 |
|
| 1201 |
KBStatus getStatus ( void ) const { return Status; } |
| 1202 |
|
| 1203 |
void setConsistency ( bool val ) |
| 1204 |
{ |
| 1205 |
Status = kbCChecked; |
| 1206 |
Consistent = val; |
| 1207 |
} |
| 1208 |
|
| 1209 |
bool isConsistent ( void ) |
| 1210 |
{ |
| 1211 |
if ( Status < kbCChecked ) |
| 1212 |
{ |
| 1213 |
prepareReasoning(); |
| 1214 |
if ( Status < kbCChecked && Consistent ) |
| 1215 |
setConsistency(performConsistencyCheck()); |
| 1216 |
} |
| 1217 |
return Consistent; |
| 1218 |
} |
| 1219 |
|
| 1220 |
bool isSubHolds ( const TConcept* C, const TConcept* D ); |
| 1221 |
|
| 1222 |
bool isSatisfiable ( const TConcept* C ); |
| 1223 |
|
| 1224 |
bool isSameIndividuals ( const TIndividual* a, const TIndividual* b ); |
| 1225 |
|
| 1226 |
bool isDisjointRoles ( const TRole* R, const TRole* S ); |
| 1227 |
|
| 1228 |
bool isIrreflexive ( const TRole* R ); |
| 1229 |
|
| 1230 |
|
| 1231 |
const modelCacheInterface* initCache ( const TConcept* pConcept, bool sub = false ); |
| 1232 |
|
| 1233 |
|
| 1234 |
const DlCompletionTree* buildCompletionTree ( const TConcept* C ); |
| 1235 |
|
| 1236 |
|
| 1237 |
enum modelCacheState testCachedNonSubsumption ( const TConcept* p, const TConcept* q ); |
| 1238 |
|
| 1239 |
bool testSortedNonSubsumption ( const TConcept* p, const TConcept* q ) |
| 1240 |
{ |
| 1241 |
|
| 1242 |
if ( !canUseSortedReasoning() ) |
| 1243 |
return false; |
| 1244 |
|
| 1245 |
if ( q == nullptr ) |
| 1246 |
return false; |
| 1247 |
return !DLHeap.haveSameSort ( p->pName, q->pName ); |
| 1248 |
} |
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
void writeReasoningResult ( std::ostream& o, float time ) const; |
| 1255 |
|
| 1256 |
void Print ( std::ostream& o ) const |
| 1257 |
{ |
| 1258 |
DLHeap.PrintStat(o); |
| 1259 |
ORM.Print ( o, "Object" ); |
| 1260 |
DRM.Print ( o, "Data" ); |
| 1261 |
PrintConcepts(o); |
| 1262 |
PrintIndividuals(o); |
| 1263 |
PrintSimpleRules(o); |
| 1264 |
PrintAxioms(o); |
| 1265 |
DLHeap.Print(o); |
| 1266 |
} |
| 1267 |
|
| 1268 |
|
| 1269 |
void dump ( dumpInterface* dump ) const; |
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
|
| 1274 |
|
| 1275 |
|
| 1276 |
void Save ( SaveLoadManager& m ); |
| 1277 |
|
| 1278 |
void Load ( SaveLoadManager& m, KBStatus status ); |
| 1279 |
|
| 1280 |
void SaveTaxonomy ( SaveLoadManager& m, const std::set<const TNamedEntry*>& excluded ); |
| 1281 |
|
| 1282 |
void LoadTaxonomy ( SaveLoadManager& m ); |
| 1283 |
}; |
| 1284 |
|
| 1285 |
#endif |