Debian Codegraph @

Source/Reasoner/Preprocess/CTriggeredImplicationGCIAbsorberPreProcess.h

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #ifndef KONCLUDE_REASONER_PREPROCESS_CTRIGGEREDIMPLICATIONGCIABSORBERPREPROCESS_H
22 #define KONCLUDE_REASONER_PREPROCESS_CTRIGGEREDIMPLICATIONGCIABSORBERPREPROCESS_H
23
24 // Libraries includes
25 #include <QSet>
26
27 // Namespace includes
28 #include "CConcreteOntologyPreProcess.h"
29 #include "CConceptRoleIndividualLocator.h"
30
31
32 // Other includes
33 #include "Utilities/CDynamicExpandingMemoryManager.hpp"
34 #include "Utilities/CSortedNegLinker.hpp"
35
36 #include "Config/CConfigDataReader.h"
37
38 #include "Reasoner/Generator/CConcreteOntologyInverseRoleBuilder.h"
39
40 #include "Reasoner/Ontology/CConceptTextFormater.h"
41
42 // Logger includes
43 #include "Logger/CLogger.h"
44
45
46
47 namespace Konclude {
48
49 using namespace Config;
50
51 namespace Reasoner {
52
53 using namespace Generator;
54 using namespace Ontology;
55
56 namespace Preprocess {
57
58 /*!
59 *
60 * \class CTriggeredImplicationGCIAbsorberPreProcess
61 * \author Andreas Steigmiller
62 * \version 0.1
63 * \brief TODO
64 *
65 */
66 class CTriggeredImplicationGCIAbsorberPreProcess : public CConcreteOntologyPreProcess {
67 // public methods
68 public:
69 //! Constructor
70 CTriggeredImplicationGCIAbsorberPreProcess();
71
72 //! Destructor
73 virtual ~CTriggeredImplicationGCIAbsorberPreProcess();
74
75 virtual CConcreteOntology *preprocess(CConcreteOntology *ontology, CPreProcessContext* context);
76
77 // protected methods
78 protected:
79 bool addConceptToImplied(CConcept* impliedConcept, CConcept* concept, bool negated);
80 bool addSubClassConcept(CConcept* subclassConcept, CConcept* addedConcept, bool negated);
81 bool addRoleDomainConcept(CRole* role, CConcept* addedConcept, bool negated);
82 CConcept* createImpliedConcept();
83 CConcept* createImplicationConcept(CConcept* impliedConcept, bool negated);
84 CConcept* createImplicationTriggerConcept(CConcept* impConcept, bool negated);
85 bool addImplicationTrigger(CConcept* implConcept, CConcept* triggerConcept, bool negated);
86 CConcept* createTriggerPropagationConcept(CConcept* destConcept, CRole* backwardPropRole);
87
88 bool isEquivalenceConceptTriggeredImplicationAbsorbable(CConcept* orConcept, bool negated, cint64* notAbsorbableOperandsCount = nullptr);
89 bool isGCIConceptTriggeredImplicationAbsorbable(CConcept* orConcept, bool negated, cint64* notAbsorbableOperandsCount = nullptr);
90 bool isConceptImplicationTriggerable(CConcept* concept, bool negated);
91 bool isConceptSimpleImplicationTriggerable(CConcept* concept, bool negated);
92 CConcept* createEquivalenceAbsorbedTriggeredImplication(CConcept* eqConcept, bool negated);
93 CConcept* createDisjunctionAbsorbedTriggeredImplication(CConcept* orConcept, bool negated);
94
95
96 cint64 createImplicationAddedToTrigger(CConcept* implicationConcept, CConcept* triggerConcept, CConcept* concept, bool negated);
97 cint64 createTrigger(CConcept* implicationConcept, CConcept* triggerConcept, CConcept* concept, bool negated, cint64* impAddTriggerCount, CConcept** impAddTrigger);
98
99
100 CRole* getInverseRole(CRole* role);
101
102 bool isDisjunctionConceptTriggeredImplicationAbsorbable(CConcept* orConcept, bool negated);
103 bool isDisjunctionConceptSimpleTriggeredImplicationAbsorbable(CConcept* orConcept, bool negated);
104
105 bool isConceptPartialImplicationTriggerable(CConcept* concept, bool negated);
106
107
108
109 bool absorbGCIConceptsToTriggeredImplications(CConcept* orConcept, bool negated);
110
111 CConcept* createGCIAbsorbedTriggeredImplication(CConcept* orConcept, bool negated, QList< QPair<CConcept*,bool> >& absorbList, QList< QPair<CConcept*,bool> >& candList);
112
113
114 cint64 createPartialImplicationAddedToTrigger(CConcept* implicationConcept, CConcept* triggerConcept, CConcept* concept, bool negated);
115 cint64 createPartialTrigger(CConcept* implicationConcept, CConcept* triggerConcept, CConcept* concept, bool negated, cint64* impAddTriggerCount, CConcept** impAddTrigger);
116
117 bool absorbPartialGCIConceptsToTriggeredImplications(CConcept* orConcept, bool negated);
118 CConcept* createGCIPartialAbsorbedTriggeredImplication(CConcept* orConcept, bool negated, const QList< QPair<CConcept*,bool> >& absorbList);
119 CConcept* createPartialExtendedGCIAbsorbedTriggeredImplication(CConcept* implicationConcept, const QList< QPair<CConcept*,bool> >& absorbList);
120
121 bool addAbsorbableDisjunctCandidates(CConcept* orConcept, bool negated, QList< QPair<CConcept*,bool> >& list);
122 QList< QPair<CConcept*,bool> > splitAbsorbableDisjuncts(QList< QPair<CConcept*,bool> >& list);
123 QList< QPair<CConcept*,bool> > getPartialAbsorbableDisjuncts(QList< QPair<CConcept*,bool> >& list);
124
125
126 QString generateDebugGCIConceptString(CConcept* concept, bool conceptNegation);
127 QString generateDebugGeneratedAbsorbedImplicationString(cint64 minNewConceptTag, cint64 lastNewConceptTag);
128
129 // protected variables
130 protected:
131 CMemoryAllocationManager* mMemMan;
132 QHash< QPair<CConcept*,bool> ,CConcept*> mConceptTriggerHash;
133 QHash<CConcept*,cint64> mTriggerCountHash;
134 CConceptVector* mConceptVec;
135 CConcept* mBottomConcept;
136 CConcreteOntology* mOnto;
137
138 CBOXHASH<CConcept*,CConcept*>* mTriggerImplHash;
139
140 bool mConfRequiresExistingInverseRole;
141 bool mConfAbsorbEqClassDefinitions;
142 bool mConfPartialGCIAbsorption;
143 bool mConfAbsorbDisjunctions;
144 bool mConfAbsorbSimpleDisjunctions;
145
146 cint64 mStatInvRolesGenerated;
147 cint64 mStatGCIAbsorbed;
148 cint64 mStatGCINormalAbsorbed;
149 cint64 mStatGCIPartialAbsorbed;
150 cint64 mStatGCIAbsorptionPartialExtended;
151 cint64 mStatGCITotal;
152 cint64 mStatEqAbsorbed;
153 cint64 mStatEqTotal;
154 cint64 mStatImplConceptsGenerated;
155
156 QString mDebugGCIString;
157 QString mDebugAbsorbedString;
158
159 QString mDebugLastGCIString;
160 QString mDebugLastAbsorbedGCIConceptString;
161 QString mDebugLastAbsorbedGCITechniqueString;
162 QString mDebugLastAbsorbedGCIString;
163 QString mDebugTotalAbsorbedGCIString;
164 cint64 mLastNewConceptTag;
165 cint64 mFirstNewConceptTag;
166
167 // private methods
168 private:
169
170 // private variables
171 private:
172
173
174 };
175
176 }; // end namespace Preprocess
177
178 }; // end namespace Reasoner
179
180 }; // end namespace Konclude
181
182 #endif // KONCLUDE_REASONER_PREPROCESS_CTRIGGEREDIMPLICATIONGCIABSORBERPREPROCESS_H