Debian Codegraph @

Kernel/AtomicDecomposer.h

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
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_H
22
23 #include "tOntologyAtom.h"
24 #include "tSignature.h"
25 #include "Modularity.h"
26
27 class ProgressIndicatorInterface;
28
29 /// atomic ontology structure
30 class AOStructure
31 {
32 public: // types
33 /// vector of atoms as a type
34 typedef std::vector<TOntologyAtom*> AtomVec;
35 /// RW iterator of it
36 typedef AtomVec::iterator iterator;
37
38 protected: // members
39 /// all the atoms
40 AtomVec Atoms;
41
42 public: // interface
43 /// d'tor: delete all atoms
44 ~AOStructure()
45 {
46 for ( TOntologyAtom* atom : Atoms )
47 delete atom;
48 }
49
50 /// create a new atom and get a pointer to it
51 TOntologyAtom* newAtom ( void )
52 {
53 TOntologyAtom* ret = new TOntologyAtom();
54 ret->setId(Atoms.size());
55 Atoms.push_back(ret);
56 return ret;
57 }
58 /// reduce graph of the atoms in the structure
59 void reduceGraph ( void )
60 {
61 TOntologyAtom::AtomSet checked;
62 for ( TOntologyAtom* atom : Atoms )
63 atom->getAllDepAtoms(checked);
64 }
65
66 /// RW iterator begin
67 iterator begin ( void ) { return Atoms.begin(); }
68 /// RW iterator end
69 iterator end ( void ) { return Atoms.end(); }
70 /// get RW atom by its index
71 TOntologyAtom* operator[] ( unsigned int index ) { return Atoms[index]; }
72 /// get RO atom by its index
73 const TOntologyAtom* operator[] ( unsigned int index ) const { return Atoms[index]; }
74 /// size of the structure
75 size_t size ( void ) const { return Atoms.size(); }
76 }; // AOStructure
77
78 /// atomic decomposer of the ontology
79 class AtomicDecomposer
80 {
81 protected: // members
82 /// atomic structure to build
83 AOStructure* AOS = nullptr;
84 /// modularizer to build modules
85 TModularizer* pModularizer = nullptr;
86 /// tautologies of the ontology
87 AxiomVec Tautologies;
88 /// progress indicator
89 ProgressIndicatorInterface* PI = nullptr;
90 /// fake atom that represents the whole ontology
91 TOntologyAtom* rootAtom = nullptr;
92 /// module type for current AOS creation
93 ModuleType type;
94
95 protected: // methods
96 /// remove tautologies (axioms that are always local) from the ontology temporarily
97 void removeTautologies ( TOntology* O );
98 /// restore all tautologies back
99 void restoreTautologies ( void )
100 {
101 for ( TDLAxiom* axiom : Tautologies )
102 axiom->setUsed(true);
103 }
104 /// build a module for given signature SIG; use parent atom's module as a base for the module search
105 TOntologyAtom* buildModule ( const TSignature& sig, TOntologyAtom* parent );
106 /// create atom for given axiom AX; use parent atom's module as a base for the module search
107 TOntologyAtom* createAtom ( TDLAxiom* ax, TOntologyAtom* parent );
108
109 public: // interface
110 /// init c'tor; M would NOT be deleted in d'tor
111 explicit AtomicDecomposer ( TModularizer* m ) : pModularizer(m) {}
112 /// d'tor
113 ~AtomicDecomposer();
114
115 /// get the atomic structure for given module type TYPE
116 AOStructure* getAOS ( TOntology* O, ModuleType type );
117 /// get already created atomic structure
118 const AOStructure* getAOS ( void ) const { return AOS; }
119
120 /// set progress indicator to be PI
121 void setProgressIndicator ( ProgressIndicatorInterface* pi ) { PI = pi; }
122 /// get number of performed locality checks
123 unsigned long long getLocCheckNumber(void) const { return pModularizer->getNChecks(); }
124 }; // AtomicDecomposer
125
126 #endif