| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2003-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 | #include "dlTBox.h"cxx . . $ `<file>/Kernel/dlTBox.h`/ |
| 21 | |
| 22 | //----------------------------------------------------------------------------- |
| 23 | //-- Subsumption axioms and support |
| 24 | //----------------------------------------------------------------------------- |
| 25 | |
| 26 | // return true if undefined concept found |
| 27 | void TBoxcxx . . $ TBox# :: addSubsumeAxiomcxx . . $ TBox#addSubsumeAxiom(237c04ede5740138). ( DLTreecxx . . $ DLTree#* sub, DLTreecxx . . $ DLTree#* sup ) |
| 28 | { |
| 29 | // for C [= C: nothing to do |
| 30 | if ( equalTreescxx . . $ equalTrees(d3c03bdc42525896). ( sub, sup ) ) |
| 31 | { |
| 32 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(sub); |
| 33 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(sup); |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | // try to apply C [= CN |
| 38 | if ( isCNcxx . . $ isCN(937bda690ff1bb73).(sup) ) |
| 39 | { |
| 40 | sup = applyAxiomCToCNcxx . . $ TBox#applyAxiomCToCN(f2877343b7b69ea7). ( sub, sup ); |
| 41 | if ( sup == nullptr ) |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | // try to apply CN [= C |
| 46 | if ( isCNcxx . . $ isCN(937bda690ff1bb73).(sub) ) |
| 47 | { |
| 48 | sub = applyAxiomCNToCcxx . . $ TBox#applyAxiomCNToC(f2877343b7b69ea7). ( sub, sup ); |
| 49 | if ( sub == nullptr ) |
| 50 | return; |
| 51 | } |
| 52 | |
| 53 | // check if an axiom looks like T [= \AR.C |
| 54 | if ( axiomToRangeDomaincxx . . $ TBox#axiomToRangeDomain(2458d46d5fbf19d5). ( sub, sup ) ) |
| 55 | ; |
| 56 | else // general axiom |
| 57 | processGCIcxx . . $ TBox#processGCI(237c04ede5740138). ( sub, sup ); |
| 58 | } |
| 59 | |
| 60 | /// tries to apply axiom D [= CN; @return NULL if applicable or new CN |
| 61 | DLTreecxx . . $ DLTree#* |
| 62 | TBoxcxx . . $ TBox# :: applyAxiomCToCNcxx . . $ TBox#applyAxiomCToCN(f2877343b7b69ea7). ( DLTreecxx . . $ DLTree#* D, DLTreecxx . . $ DLTree#* CN ) |
| 63 | { |
| 64 | TConceptcxx . . $ TConcept#* C = resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(getCIcxx . . $ TBox#getCI(a9db10ac0cf504ba).(CN)); |
| 65 | if ( C == nullptr ) // not applicable |
| 66 | return CN; |
| 67 | |
| 68 | // D [= BOTTOM: transform later as GCI |
| 69 | if ( C == pBottomcxx . . $ TBox#pBottom. ) |
| 70 | { |
| 71 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(CN); |
| 72 | return createBottomcxx . . $ createBottom(aa22cc08b69ae2ef).(); |
| 73 | } |
| 74 | |
| 75 | // D [= TOP: nothing to do |
| 76 | if ( C == pTopcxx . . $ TBox#pTop. ) |
| 77 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(D); |
| 78 | // check for D [= CN with CN [= D already defined |
| 79 | // don't do this for D is a DN and C is an individual as cycle detection will do it better |
| 80 | else if ( equalTreescxx . . $ equalTrees(d3c03bdc42525896). ( C->Descriptioncxx . . $ TConcept#Description., D ) && !( C->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() && isNamecxx . . $ isName(937bda690ff1bb73).(D) ) ) |
| 81 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2). ( makeNonPrimitivecxx . . $ TBox#makeNonPrimitive(1e45738bba157392).(C,D) ); |
| 82 | else // n/a |
| 83 | return CN; |
| 84 | |
| 85 | // success |
| 86 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(CN); |
| 87 | return nullptr; |
| 88 | } |
| 89 | |
| 90 | /// tries to apply axiom CN [= D; @return NULL if applicable or new CN |
| 91 | DLTreecxx . . $ DLTree#* |
| 92 | TBoxcxx . . $ TBox# :: applyAxiomCNToCcxx . . $ TBox#applyAxiomCNToC(f2877343b7b69ea7). ( DLTreecxx . . $ DLTree#* CN, DLTreecxx . . $ DLTree#* D ) |
| 93 | { |
| 94 | TConceptcxx . . $ TConcept#* C = resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(getCIcxx . . $ TBox#getCI(a9db10ac0cf504ba).(CN)); |
| 95 | if ( C == nullptr ) // not applicable |
| 96 | return CN; |
| 97 | |
| 98 | // TOP [= D: transform later as GCI |
| 99 | if ( C == pTopcxx . . $ TBox#pTop. ) |
| 100 | { |
| 101 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(CN); |
| 102 | return createTopcxx . . $ createTop(aa22cc08b69ae2ef).(); |
| 103 | } |
| 104 | |
| 105 | // BOTTOM [= D: nothing to do |
| 106 | if ( C == pBottomcxx . . $ TBox#pBottom. ) |
| 107 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(D); |
| 108 | else if ( C->isPrimitivecxx . . $ TConcept#isPrimitive(50ce9a9e25b4a850).() ) |
| 109 | C->addDesccxx . . $ TConcept#addDesc(edf821a2fc5509f9).(D); |
| 110 | else // C is defined |
| 111 | addSubsumeForDefinedcxx . . $ TBox#addSubsumeForDefined(4128fa2c78139db0). ( C, D ); |
| 112 | |
| 113 | // success |
| 114 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(CN); |
| 115 | return nullptr; |
| 116 | } |
| 117 | |
| 118 | /// add an axiom CN [= E for defined CN (CN=D already in base) |
| 119 | void |
| 120 | TBoxcxx . . $ TBox# :: addSubsumeForDefinedcxx . . $ TBox#addSubsumeForDefined(4128fa2c78139db0). ( TConceptcxx . . $ TConcept#* C, DLTreecxx . . $ DLTree#* E ) |
| 121 | { |
| 122 | // if E is a syntactic sub-class of D, then nothing to do |
| 123 | if ( isSubTreecxx . . $ isSubTree(d3c03bdc42525896). ( E, C->Descriptioncxx . . $ TConcept#Description. ) ) |
| 124 | { |
| 125 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(E); |
| 126 | return; |
| 127 | } |
| 128 | |
| 129 | // try to see whether C contains a reference to itself at the top level |
| 130 | if ( C->hasSelfInDesccxx . . $ TConcept#hasSelfInDesc(50ce9a9e25b4a850).() ) |
| 131 | { |
| 132 | // remember the old description value |
| 133 | DLTreecxx . . $ DLTree#* D = clonecxx . . $ clone(ec41a33c52a5614b).(C->Descriptioncxx . . $ TConcept#Description.); |
| 134 | // remove C from the description |
| 135 | C->removeSelfFromDescriptioncxx . . $ TConcept#removeSelfFromDescription(49f6e7a06ebc5aa8).(); |
| 136 | // the trees should differ here |
| 137 | fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( !equalTrees ( D, C->Description ) ); |
| 138 | // note that we don't know exact semantics of C for now; |
| 139 | // we need to split it's definition and work via GCIs |
| 140 | makeDefinitionPrimitivecxx . . $ TBox#makeDefinitionPrimitive(12a9e5ce3420c48d). ( C, E, D ); |
| 141 | } |
| 142 | else // here we have the definition of C = D, and subsumption C [= E |
| 143 | { |
| 144 | if ( 1 ) // for now: it's not clear of what's going wrong |
| 145 | processGCIcxx . . $ TBox#processGCI(237c04ede5740138). ( getTreecxx . . $ TBox#getTree(8f1a6b264b733ed7).(C), E ); |
| 146 | else // here we leave the definition of C = D, and delay the processing of C [= E |
| 147 | { |
| 148 | ConceptDefMapcxx . . $ TBox#ConceptDefMap#::iteratorcxx . . $ std/map#iterator# p = ExtraConceptDefscxx . . $ TBox#ExtraConceptDefs..findcxx . . $ std/map#find(36f8d56706583706).(C); |
| 149 | if ( p ==cxx . . $ std/`operator==`(84f83906d8995b82). ExtraConceptDefscxx . . $ TBox#ExtraConceptDefs..endcxx . . $ std/map#end(fbe2f8c57595edf).() ) // no such entry |
| 150 | ExtraConceptDefscxx . . $ TBox#ExtraConceptDefs.[cxx . . $ std/map#`operator[]`(bbd415b616967878).C] = E; // save C [= E |
| 151 | else // we have C [= X; change to C [= (X and E) |
| 152 | p->cxx . . $ std/_Rb_tree_iterator#`operator->`(5a2a78a048fb49a8).secondcxx . . $ std/pair#second. = createSNFAndcxx . . $ createSNFAnd(f2877343b7b69ea7). ( p->cxx . . $ std/_Rb_tree_iterator#`operator->`(5a2a78a048fb49a8).secondcxx . . $ std/pair#second., E ); |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | bool TBoxcxx . . $ TBox# :: axiomToRangeDomaincxx . . $ TBox#axiomToRangeDomain(2458d46d5fbf19d5). ( DLTreecxx . . $ DLTree#* sub, DLTreecxx . . $ DLTree#* sup ) |
| 158 | { |
| 159 | // applicability check for T [= A R.C |
| 160 | if ( sub->Elementcxx . . $ TsTTree#Element(19b2b6f17af048b).() ==cxx . . $ TLexeme#`operator==`(b418e6031985303a). TOPcxx . . $ TOP. && sup->Elementcxx . . $ TsTTree#Element(19b2b6f17af048b). () ==cxx . . $ TLexeme#`operator==`(b418e6031985303a). FORALLcxx . . $ FORALL. ) |
| 161 | { |
| 162 | resolveRolecxx . . $ resolveRole(c256d257f6e22050).(sup->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).())->setRangecxx . . $ TRole#setRange(edf821a2fc5509f9).(clonecxx . . $ clone(ec41a33c52a5614b).(sup->Rightcxx . . $ TsTTree#Right(f4b2f47551fb31d7).())); |
| 163 | // free unused memory |
| 164 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(sub); |
| 165 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(sup); |
| 166 | return true; |
| 167 | } |
| 168 | // applicability check for E R.T [= D |
| 169 | if ( sub->Elementcxx . . $ TsTTree#Element(19b2b6f17af048b).() ==cxx . . $ TLexeme#`operator==`(b418e6031985303a). NOTcxx . . $ NOT. && sub->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).()->Elementcxx . . $ TsTTree#Element(19b2b6f17af048b).() ==cxx . . $ TLexeme#`operator==`(b418e6031985303a). FORALLcxx . . $ FORALL. && sub->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).()->Rightcxx . . $ TsTTree#Right(f4b2f47551fb31d7).()->Elementcxx . . $ TsTTree#Element(19b2b6f17af048b).() ==cxx . . $ TLexeme#`operator==`(b418e6031985303a). BOTTOMcxx . . $ BOTTOM. ) |
| 170 | { |
| 171 | resolveRolecxx . . $ resolveRole(c256d257f6e22050).(sub->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).()->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).())->setDomaincxx . . $ TRole#setDomain(edf821a2fc5509f9).(sup); |
| 172 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(sub); |
| 173 | return true; |
| 174 | } |
| 175 | return false; |
| 176 | } |
| 177 | |
| 178 | //----------------------------------------------------------------------------- |
| 179 | //-- Equality axioms and support |
| 180 | //----------------------------------------------------------------------------- |
| 181 | |
| 182 | /// process the definition LHS = RHS |
| 183 | void |
| 184 | TBoxcxx . . $ TBox# :: addEqualityAxiomcxx . . $ TBox#addEqualityAxiom(237c04ede5740138). ( DLTreecxx . . $ DLTree#* lhs, DLTreecxx . . $ DLTree#* rhs ) |
| 185 | { |
| 186 | // check whether LHS is a named concept |
| 187 | TConceptcxx . . $ TConcept#* C = resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(getCIcxx . . $ TBox#getCI(a9db10ac0cf504ba).(lhs)); |
| 188 | bool isNamedLHS = ( C && C != pTopcxx . . $ TBox#pTop. && C != pBottomcxx . . $ TBox#pBottom. ); |
| 189 | |
| 190 | // check whether RHS is a named concept |
| 191 | TConceptcxx . . $ TConcept#* D = resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(getCIcxx . . $ TBox#getCI(a9db10ac0cf504ba).(rhs)); |
| 192 | bool isNamedRHS = ( D && D != pTopcxx . . $ TBox#pTop. && D != pBottomcxx . . $ TBox#pBottom. ); |
| 193 | |
| 194 | // try to make a definition C = RHS for C with no definition |
| 195 | if ( isNamedLHS && addNonprimitiveDefinitioncxx . . $ TBox#addNonprimitiveDefinition(139e67a379f4bc6e). ( C, rhs ) ) |
| 196 | { |
| 197 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(lhs); |
| 198 | return; |
| 199 | } |
| 200 | |
| 201 | // try to make a definition RHS = LHS for RHS = C with no definition |
| 202 | if ( isNamedRHS && addNonprimitiveDefinitioncxx . . $ TBox#addNonprimitiveDefinition(139e67a379f4bc6e). ( D, lhs ) ) |
| 203 | { |
| 204 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(rhs); |
| 205 | return; |
| 206 | } |
| 207 | |
| 208 | // try to make a definition C = RHS for C [= D |
| 209 | if ( isNamedLHS && switchToNonprimitivecxx . . $ TBox#switchToNonprimitive(139e67a379f4bc6e). ( C, rhs ) ) |
| 210 | { |
| 211 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(lhs); |
| 212 | return; |
| 213 | } |
| 214 | |
| 215 | // try to make a definition RHS = LHS for RHS = C with C [= D |
| 216 | if ( isNamedRHS && switchToNonprimitivecxx . . $ TBox#switchToNonprimitive(139e67a379f4bc6e). ( D, lhs ) ) |
| 217 | { |
| 218 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(rhs); |
| 219 | return; |
| 220 | } |
| 221 | |
| 222 | // fail to make a concept definition; separate the definition |
| 223 | addSubsumeAxiomcxx . . $ TBox#addSubsumeAxiom(237c04ede5740138). ( clonecxx . . $ clone(ec41a33c52a5614b).(lhs), clonecxx . . $ clone(ec41a33c52a5614b).(rhs) ); |
| 224 | addSubsumeAxiomcxx . . $ TBox#addSubsumeAxiom(237c04ede5740138). ( rhs, lhs ); |
| 225 | } |
| 226 | |
| 227 | /// tries to add C = RHS for the concept C; @return true if OK |
| 228 | bool |
| 229 | TBoxcxx . . $ TBox# :: addNonprimitiveDefinitioncxx . . $ TBox#addNonprimitiveDefinition(139e67a379f4bc6e). ( TConceptcxx . . $ TConcept#* C, DLTreecxx . . $ DLTree#* rhs ) |
| 230 | { |
| 231 | // check whether the case is C=D for a (concept-like) D |
| 232 | TConceptcxx . . $ TConcept#* D = getCIcxx . . $ TBox#getCI(a9db10ac0cf504ba).(rhs); |
| 233 | |
| 234 | // nothing to do for the case C := D for named concepts C,D with D = C already |
| 235 | if ( D && resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(D) == C ) |
| 236 | { |
| 237 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(rhs); |
| 238 | return true; |
| 239 | } |
| 240 | |
| 241 | // can't have C=D where C is a nominal and D is a concept |
| 242 | if ( C->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() && D != nullptr && !D->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() ) |
| 243 | return false; |
| 244 | |
| 245 | // check the case whether C=RHS or C [= \top |
| 246 | if ( C->canInitNonPrimcxx . . $ TConcept#canInitNonPrim(38a18fab043f8799).(rhs) ) |
| 247 | { |
| 248 | // delete return value in case of (possibly) duplicated description |
| 249 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2). ( makeNonPrimitivecxx . . $ TBox#makeNonPrimitive(1e45738bba157392). ( C, rhs ) ); |
| 250 | return true; |
| 251 | } |
| 252 | |
| 253 | // can't make definition |
| 254 | return false; |
| 255 | } |
| 256 | |
| 257 | /// tries to add C = RHS for the concept C [= X; @return true if OK |
| 258 | bool |
| 259 | TBoxcxx . . $ TBox# :: switchToNonprimitivecxx . . $ TBox#switchToNonprimitive(139e67a379f4bc6e). ( TConceptcxx . . $ TConcept#* C, DLTreecxx . . $ DLTree#* rhs ) |
| 260 | { |
| 261 | // make sure that we avoid making an individual equals to something else |
| 262 | TConceptcxx . . $ TConcept#* D = resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(getCIcxx . . $ TBox#getCI(a9db10ac0cf504ba).(rhs)); |
| 263 | if ( C->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() && D && !D->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() ) |
| 264 | return false; |
| 265 | |
| 266 | // check whether we process C=D where C is defined as C[=E |
| 267 | if ( alwaysPreferEqualscxx . . $ TBox#alwaysPreferEquals. && C->isPrimitivecxx . . $ TConcept#isPrimitive(50ce9a9e25b4a850).() ) // change C to C=... with additional GCI C[=x |
| 268 | { |
| 269 | addSubsumeForDefinedcxx . . $ TBox#addSubsumeForDefined(4128fa2c78139db0). ( C, makeNonPrimitivecxx . . $ TBox#makeNonPrimitive(1e45738bba157392).(C,rhs) ); |
| 270 | return true; |
| 271 | } |
| 272 | |
| 273 | return false; |
| 274 | } |
| 275 | |
| 276 | //----------------------------------------------------------------------------- |
| 277 | //-- N-ary concept axioms |
| 278 | //----------------------------------------------------------------------------- |
| 279 | |
| 280 | void TBoxcxx . . $ TBox# :: processDisjointCcxx . . $ TBox#processDisjointC(117de6f0d8a75fcb). ( ea_iteratorcxx . . $ TBox#ea_iterator# beg, ea_iteratorcxx . . $ TBox#ea_iterator# end ) |
| 281 | { |
| 282 | ExpressionArraycxx . . $ TBox#ExpressionArray# primcxx . . $ std/vector#vector(49f6e7a06ebc5aa8)., restcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 283 | |
| 284 | for ( ; beg <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).beg ) |
| 285 | if ( isNamecxx . . $ isName(937bda690ff1bb73).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg) && |
| 286 | static_cast<const TConceptcxx . . $ TConcept#*>((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg)->Elementcxx . . $ TsTTree#Element(19b2b6f17af048b).().getNEcxx . . $ TLexeme#getNE(28c03b9fd3c689f8).())->isPrimitivecxx . . $ TConcept#isPrimitive(50ce9a9e25b4a850).() ) |
| 287 | prim.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg); |
| 288 | else |
| 289 | rest.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg); |
| 290 | |
| 291 | // both primitive concept and others are in DISJ statement |
| 292 | if ( !prim.emptycxx . . $ std/vector#empty(50ce9a9e25b4a850).() && !rest.emptycxx . . $ std/vector#empty(50ce9a9e25b4a850).() ) |
| 293 | { |
| 294 | DLTreecxx . . $ DLTree#* nrest = buildDisjAuxcxx . . $ TBox#buildDisjAux(3ad5232b67752138). ( rest.begincxx . . $ std/vector#begin(33b10a496a38335b).(), rest.endcxx . . $ std/vector#end(33b10a496a38335b).() ); |
| 295 | |
| 296 | for ( ea_iteratorcxx . . $ TBox#ea_iterator# q = primcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0)..begincxx . . $ std/vector#begin(33b10a496a38335b).(), q_end = primcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0)..endcxx . . $ std/vector#end(33b10a496a38335b).(); q <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). q_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).q ) |
| 297 | addSubsumeAxiomcxx . . $ TBox#addSubsumeAxiom(237c04ede5740138). ( clonecxx . . $ clone(ec41a33c52a5614b).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q), clonecxx . . $ clone(ec41a33c52a5614b).(nrest) ); |
| 298 | |
| 299 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(nrest); |
| 300 | } |
| 301 | |
| 302 | // no primitive concepts between DJ elements |
| 303 | |
| 304 | if ( !rest.emptycxx . . $ std/vector#empty(50ce9a9e25b4a850).() ) |
| 305 | processDisjointcxx . . $ TBox#processDisjoint(249673c20e2b8d5). ( rest.begincxx . . $ std/vector#begin(33b10a496a38335b).(), rest.endcxx . . $ std/vector#end(33b10a496a38335b).() ); |
| 306 | |
| 307 | // all non-PC are done; prim is non-empty |
| 308 | // FIXME!! do it in more optimal way later |
| 309 | if ( !prim.emptycxx . . $ std/vector#empty(50ce9a9e25b4a850).() ) |
| 310 | processDisjointcxx . . $ TBox#processDisjoint(249673c20e2b8d5). ( prim.begincxx . . $ std/vector#begin(33b10a496a38335b).(), prim.endcxx . . $ std/vector#end(33b10a496a38335b).() ); |
| 311 | } |
| 312 | |
| 313 | void TBoxcxx . . $ TBox# :: processEquivalentCcxx . . $ TBox#processEquivalentC(117de6f0d8a75fcb). ( ea_iteratorcxx . . $ TBox#ea_iterator# beg, ea_iteratorcxx . . $ TBox#ea_iterator# end ) |
| 314 | { |
| 315 | for ( ; beg+cxx . . $ __gnu_cxx/__normal_iterator#operator+(d0cb2d2ebd313f38).1 <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).beg ) |
| 316 | addEqualityAxiomcxx . . $ TBox#addEqualityAxiom(237c04ede5740138). ( *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg, clonecxx . . $ clone(ec41a33c52a5614b).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).(beg+cxx . . $ __gnu_cxx/__normal_iterator#operator+(d0cb2d2ebd313f38).1)) ); |
| 317 | // now beg+1 == end, so beg points to the last element |
| 318 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg); |
| 319 | } |
| 320 | |
| 321 | //----------------------------------------------------------------------------- |
| 322 | //-- N-ary individual axioms |
| 323 | //----------------------------------------------------------------------------- |
| 324 | |
| 325 | void TBoxcxx . . $ TBox# :: processDifferentcxx . . $ TBox#processDifferent(117de6f0d8a75fcb). ( ea_iteratorcxx . . $ TBox#ea_iterator# beg, ea_iteratorcxx . . $ TBox#ea_iterator# end ) |
| 326 | { |
| 327 | SingletonVectorcxx . . $ TBox#SingletonVector# acccxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 328 | for ( ; beg <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).beg ) |
| 329 | if ( isIndividualcxx . . $ TBox#isIndividual(4f9ee8c35ac4b1e6).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg) ) // only nominals in DIFFERENT command |
| 330 | { |
| 331 | acc.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(toIndividualcxx . . $ TBox#toIndividual(1199bc9a67399c68).((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg)->Elementcxx . . $ TsTTree#Element(19b2b6f17af048b).().getNEcxx . . $ TLexeme#getNE(28c03b9fd3c689f8).())); |
| 332 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg); |
| 333 | } |
| 334 | else |
| 335 | throw EFaCTPlusPluscxx . . $ EFaCTPlusPlus#("Only individuals allowed in processDifferent()"); |
| 336 | |
| 337 | // register vector of disjoint nominals in proper place |
| 338 | if ( acc.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).() > 1 ) |
| 339 | Differentcxx . . $ TBox#Different..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(acc); |
| 340 | } |
| 341 | |
| 342 | void TBoxcxx . . $ TBox# :: processSamecxx . . $ TBox#processSame(117de6f0d8a75fcb). ( ea_iteratorcxx . . $ TBox#ea_iterator# beg, ea_iteratorcxx . . $ TBox#ea_iterator# end ) |
| 343 | { |
| 344 | if ( beg ==cxx . . $ __gnu_cxx/`operator==`(ef3c5749062e825c). end ) |
| 345 | return; |
| 346 | |
| 347 | if ( !isIndividualcxx . . $ TBox#isIndividual(4f9ee8c35ac4b1e6).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg) ) // only nominals in SAME command |
| 348 | throw EFaCTPlusPluscxx . . $ EFaCTPlusPlus#("Only individuals allowed in processSame()"); |
| 349 | |
| 350 | for ( ; beg+cxx . . $ __gnu_cxx/__normal_iterator#operator+(d0cb2d2ebd313f38).1 <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).beg ) |
| 351 | { |
| 352 | if ( !isIndividualcxx . . $ TBox#isIndividual(4f9ee8c35ac4b1e6).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).(beg+cxx . . $ __gnu_cxx/__normal_iterator#operator+(d0cb2d2ebd313f38).1)) ) |
| 353 | throw EFaCTPlusPluscxx . . $ EFaCTPlusPlus#("Only individuals allowed in processSame()"); |
| 354 | addEqualityAxiomcxx . . $ TBox#addEqualityAxiom(237c04ede5740138). ( *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg, clonecxx . . $ clone(ec41a33c52a5614b).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).(beg+cxx . . $ __gnu_cxx/__normal_iterator#operator+(d0cb2d2ebd313f38).1)) ); |
| 355 | } |
| 356 | // now beg+1 == end, so beg points to the last element |
| 357 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg); |
| 358 | } |
| 359 | |
| 360 | //----------------------------------------------------------------------------- |
| 361 | //-- N-ary role axioms |
| 362 | //----------------------------------------------------------------------------- |
| 363 | |
| 364 | void TBoxcxx . . $ TBox# :: processDisjointRcxx . . $ TBox#processDisjointR(117de6f0d8a75fcb). ( ea_iteratorcxx . . $ TBox#ea_iterator# beg, ea_iteratorcxx . . $ TBox#ea_iterator# end ) |
| 365 | { |
| 366 | if ( beg ==cxx . . $ __gnu_cxx/`operator==`(ef3c5749062e825c). end ) |
| 367 | throw EFaCTPlusPluscxx . . $ EFaCTPlusPlus#("Empty disjoint role axiom"); |
| 368 | |
| 369 | ea_iteratorcxx . . $ TBox#ea_iterator# pcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(49f6e7a06ebc5aa8)., qcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(49f6e7a06ebc5aa8).; |
| 370 | |
| 371 | // check that all id's are correct role names |
| 372 | for ( p =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(45448e0a78ebe879). beg; p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 373 | if ( isTopRolecxx . . $ isTopRole(937bda690ff1bb73).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p) ) |
| 374 | throw EFaCTPlusPluscxx . . $ EFaCTPlusPlus#("Universal role in the disjoint roles axiom"); |
| 375 | |
| 376 | RoleMastercxx . . $ RoleMaster#& RM = getRMcxx . . $ TBox#getRM(d63bc69855fc8040).(resolveRolecxx . . $ resolveRole(c256d257f6e22050).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg)); |
| 377 | |
| 378 | // make a disjoint roles |
| 379 | for ( p =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(45448e0a78ebe879). beg; p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 380 | { |
| 381 | TRolecxx . . $ TRole#* r = resolveRolecxx . . $ resolveRole(c256d257f6e22050).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p); |
| 382 | |
| 383 | // FIXME: this could be done more optimal... |
| 384 | for ( q =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(385d6bbed7d39dab). p+cxx . . $ __gnu_cxx/__normal_iterator#operator+(d0cb2d2ebd313f38).1; q <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).q ) |
| 385 | RM.addDisjointRolescxx . . $ RoleMaster#addDisjointRoles(898137b4008d6b89). ( r, resolveRolecxx . . $ resolveRole(c256d257f6e22050).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q) ); |
| 386 | |
| 387 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p); |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | void TBoxcxx . . $ TBox# :: processEquivalentRcxx . . $ TBox#processEquivalentR(117de6f0d8a75fcb). ( ea_iteratorcxx . . $ TBox#ea_iterator# beg, ea_iteratorcxx . . $ TBox#ea_iterator# end ) |
| 392 | { |
| 393 | if ( beg !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). end ) |
| 394 | { |
| 395 | RoleMastercxx . . $ RoleMaster#& RM = getRMcxx . . $ TBox#getRM(d63bc69855fc8040).(resolveRolecxx . . $ resolveRole(c256d257f6e22050).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg)); |
| 396 | for ( ; beg !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). end-cxx . . $ __gnu_cxx/__normal_iterator#operator-(d0cb2d2ebd313f38).1; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).beg ) |
| 397 | { |
| 398 | RM.addRoleSynonymcxx . . $ RoleMaster#addRoleSynonym(46569ce1194069bb). ( resolveRolecxx . . $ resolveRole(c256d257f6e22050).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg), resolveRolecxx . . $ resolveRole(c256d257f6e22050).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).(beg+cxx . . $ __gnu_cxx/__normal_iterator#operator+(d0cb2d2ebd313f38).1)) ); |
| 399 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg); |
| 400 | } |
| 401 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).beg); |
| 402 | } |
| 403 | } |
| 404 |