| 1 |
/* This file is part of the FaCT++ DL reasoner |
| 2 |
Copyright (C) 2011-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 ATOMICDECOMPOSER_H |
| 21 |
#define ATOMICDECOMPOSER_Hcxx . . $ `Kernel/AtomicDecomposer.h:21:9`! |
| 22 |
|
| •23 |
#include <ostream> |
| 24 |
|
| 25 |
#include "tOntologyAtom.h"cxx . . $ `<file>/Kernel/tOntologyAtom.h`/ |
| 26 |
#include "tSignature.h"cxx . . $ `<file>/Kernel/tSignature.h`/ |
| 27 |
#include "Modularity.h"cxx . . $ `<file>/Kernel/Modularity.h`/ |
| 28 |
|
| 29 |
class ProgressIndicatorInterfacecxx . . $ ProgressIndicatorInterface#; |
| 30 |
|
| 31 |
/// atomic ontology structure |
| 32 |
class AOStructurecxx . . $ AOStructure# |
| 33 |
{ |
| 34 |
public: // types |
| 35 |
/// vector of atoms as a type |
| 36 |
typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<TOntologyAtomcxx . . $ TOntologyAtom#*> AtomVeccxx . . $ AOStructure#AtomVec#; |
| 37 |
/// RW iterator of it |
| 38 |
typedef AtomVeccxx . . $ AOStructure#AtomVec#::iteratorcxx . . $ std/vector#iterator# iteratorcxx . . $ AOStructure#iterator#; |
| 39 |
|
| 40 |
protected: // members |
| 41 |
/// all the atoms |
| 42 |
AtomVeccxx . . $ AOStructure#AtomVec# Atomscxx . . $ AOStructure#Atoms.; |
| 43 |
|
| 44 |
public: // interface |
| 45 |
/// d'tor: delete all atoms |
| 46 |
~cxx . . $ AOStructure#`~AOStructure`(49f6e7a06ebc5aa8).AOStructurecxx . . $ AOStructure#() |
| 47 |
{ |
| 48 |
for ( TOntologyAtomcxx . . $ TOntologyAtom#* atom : Atomscxx . . $ AOStructure#Atoms. ) |
| 49 |
delete atom; |
| 50 |
} |
| 51 |
|
| 52 |
/// create a new atom and get a pointer to it |
| 53 |
TOntologyAtomcxx . . $ TOntologyAtom#* newAtomcxx . . $ AOStructure#newAtom(cdca29e2a9ec24ff). ( void ) |
| 54 |
{ |
| 55 |
TOntologyAtomcxx . . $ TOntologyAtom#* ret = new TOntologyAtomcxx . . $ TOntologyAtom#(); |
| 56 |
ret->setIdcxx . . $ TOntologyAtom#setId(2c44cd906ae4e829).(Atomscxx . . $ AOStructure#Atoms..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).()); |
| 57 |
Atomscxx . . $ AOStructure#Atoms..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(ret); |
| 58 |
return ret; |
| 59 |
} |
| 60 |
/// reduce graph of the atoms in the structure |
| 61 |
void reduceGraphcxx . . $ AOStructure#reduceGraph(49f6e7a06ebc5aa8). ( void ) |
| 62 |
{ |
| 63 |
TOntologyAtomcxx . . $ TOntologyAtom#::AtomSetcxx . . $ TOntologyAtom#AtomSet# checkedcxx . . $ std/set#set(49f6e7a06ebc5aa8).; |
| 64 |
for ( TOntologyAtomcxx . . $ TOntologyAtom#* atom : Atomscxx . . $ AOStructure#Atoms. ) |
| 65 |
atom->getAllDepAtomscxx . . $ TOntologyAtom#getAllDepAtoms(93250490d327d7e4).(checked); |
| 66 |
} |
| 67 |
|
| 68 |
/// RW iterator begin |
| 69 |
iteratorcxx . . $ AOStructure#iterator# begincxx . . $ AOStructure#begin(8e6f70e1dccd61fc). ( void ) { return Atomscxx . . $ AOStructure#Atoms..begincxx . . $ std/vector#begin(33b10a496a38335b).(); } |
| 70 |
/// RW iterator end |
| 71 |
iteratorcxx . . $ AOStructure#iterator# endcxx . . $ AOStructure#end(8e6f70e1dccd61fc). ( void ) { return Atomscxx . . $ AOStructure#Atoms..endcxx . . $ std/vector#end(33b10a496a38335b).(); } |
| 72 |
/// get RW atom by its index |
| 73 |
TOntologyAtomcxx . . $ TOntologyAtom#* operatorcxx . . $ AOStructure#`operator[]`(76bb7807cd8c0892).[] ( unsigned int index ) { return Atomscxx . . $ AOStructure#Atoms.[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).index]; } |
| 74 |
/// get RO atom by its index |
| 75 |
const TOntologyAtomcxx . . $ TOntologyAtom#* operatorcxx . . $ AOStructure#`operator[]`(9f94d59263fd233).[] ( unsigned int index ) const { return Atomscxx . . $ AOStructure#Atoms.[cxx . . $ std/vector#`operator[]`(b61e45a10b63f40a).index]; } |
| 76 |
/// size of the structure |
| 77 |
size_tcxx . . $ size_t# sizecxx . . $ AOStructure#size(fe4d2d262d4164a8). ( void ) const { return Atomscxx . . $ AOStructure#Atoms..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); } |
| 78 |
}; // AOStructure |
| 79 |
|
| 80 |
/// atomic decomposer of the ontology |
| 81 |
class AtomicDecomposercxx . . $ AtomicDecomposer# |
| 82 |
{ |
| 83 |
protected: // members |
| 84 |
/// atomic structure to build |
| 85 |
AOStructurecxx . . $ AOStructure#* AOScxx . . $ AtomicDecomposer#AOS. = nullptr; |
| 86 |
/// modularizer to build modules |
| 87 |
TModularizercxx . . $ TModularizer#* pModularizercxx . . $ AtomicDecomposer#pModularizer. = nullptr; |
| 88 |
/// tautologies of the ontology |
| 89 |
AxiomVeccxx . . $ AxiomVec# Tautologiescxx . . $ AtomicDecomposer#Tautologies.; |
| 90 |
/// progress indicator |
| 91 |
ProgressIndicatorInterfacecxx . . $ ProgressIndicatorInterface#* PIcxx . . $ AtomicDecomposer#PI. = nullptr; |
| 92 |
/// fake atom that represents the whole ontology |
| 93 |
TOntologyAtomcxx . . $ TOntologyAtom#* rootAtomcxx . . $ AtomicDecomposer#rootAtom. = nullptr; |
| 94 |
/// module type for current AOS creation |
| 95 |
ModuleTypecxx . . $ ModuleType# typecxx . . $ AtomicDecomposer#type.; |
| 96 |
|
| 97 |
protected: // methods |
| 98 |
/// remove tautologies (axioms that are always local) from the ontology temporarily |
| 99 |
void removeTautologiescxx . . $ AtomicDecomposer#removeTautologies(33fca0ffe8b07fe8). ( TOntologycxx . . $ TOntology#* O ); |
| 100 |
/// restore all tautologies back |
| 101 |
void restoreTautologiescxx . . $ AtomicDecomposer#restoreTautologies(49f6e7a06ebc5aa8). ( void ) |
| 102 |
{ |
| 103 |
for ( TDLAxiomcxx . . $ TDLAxiom#* axiom : Tautologiescxx . . $ AtomicDecomposer#Tautologies. ) |
| 104 |
axiom->setUsedcxx . . $ TDLAxiom#setUsed(b45ddcbc8423892c).(true); |
| 105 |
} |
| 106 |
/// build a module for given signature SIG; use parent atom's module as a base for the module search |
| 107 |
TOntologyAtomcxx . . $ TOntologyAtom#* buildModulecxx . . $ AtomicDecomposer#buildModule(7d21f2e6c4bdd0a1). ( const TSignaturecxx . . $ TSignature#& sig, TOntologyAtomcxx . . $ TOntologyAtom#* parent ); |
| 108 |
/// create atom for given axiom AX; use parent atom's module as a base for the module search |
| 109 |
TOntologyAtomcxx . . $ TOntologyAtom#* createAtomcxx . . $ AtomicDecomposer#createAtom(3f90616d3a2486ad). ( TDLAxiomcxx . . $ TDLAxiom#* ax, TOntologyAtomcxx . . $ TOntologyAtom#* parent ); |
| 110 |
|
| 111 |
public: // interface |
| 112 |
/// init c'tor; M would NOT be deleted in d'tor |
| 113 |
explicit AtomicDecomposercxx . . $ AtomicDecomposer#AtomicDecomposer(5046fcbd60ea34b7). ( TModularizercxx . . $ TModularizer#* m ) : pModularizercxx . . $ AtomicDecomposer#pModularizer.(m) {} |
| 114 |
/// d'tor |
| 115 |
~cxx . . $ AtomicDecomposer#`~AtomicDecomposer`(49f6e7a06ebc5aa8).AtomicDecomposercxx . . $ AtomicDecomposer#(); |
| 116 |
|
| 117 |
/// get the atomic structure for given module type TYPE |
| 118 |
AOStructurecxx . . $ AOStructure#* getAOScxx . . $ AtomicDecomposer#getAOS(54e527a6df0aab25). ( TOntologycxx . . $ TOntology#* O, ModuleTypecxx . . $ ModuleType# type ); |
| 119 |
/// get already created atomic structure |
| 120 |
const AOStructurecxx . . $ AOStructure#* getAOScxx . . $ AtomicDecomposer#getAOS(6b8dff3b29b7ab14). ( void ) const { return AOScxx . . $ AtomicDecomposer#AOS.; } |
| 121 |
|
| 122 |
/// set progress indicator to be PI |
| 123 |
void setProgressIndicatorcxx . . $ AtomicDecomposer#setProgressIndicator(db54dee042fd4fc2). ( ProgressIndicatorInterfacecxx . . $ ProgressIndicatorInterface#* pi ) { PIcxx . . $ AtomicDecomposer#PI. = pi; } |
| 124 |
/// get number of performed locality checks |
| 125 |
unsigned long long getLocCheckNumbercxx . . $ AtomicDecomposer#getLocCheckNumber(1c5fc1fd41a99ae7).(void) const { return pModularizercxx . . $ AtomicDecomposer#pModularizer.->getNCheckscxx . . $ TModularizer#getNChecks(1c5fc1fd41a99ae7).(); } |
| 126 |
}; // AtomicDecomposer |
| 127 |
|
| 128 |
#endif |