| 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 "LogicFeature.h"cxx . . $ `<file>/Kernel/LogicFeature.h`/ |
| 21 | #include "logging.h"cxx . . $ `<file>/Kernel/logging.h`/ |
| 22 | #include "dlVertex.h"cxx . . $ `<file>/Kernel/dlVertex.h`/ |
| 23 | #include "tConcept.h"cxx . . $ `<file>/Kernel/tConcept.h`/ |
| 24 | #include "tRole.h"cxx . . $ `<file>/Kernel/tRole.h`/ |
| 25 | |
| 26 | void LogicFeaturescxx . . $ LogicFeatures# :: fillConceptDatacxx . . $ LogicFeatures#fillConceptData(49c8796e4511ff9d). ( const TConceptcxx . . $ TConcept#* p ) |
| 27 | { |
| 28 | if ( p->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() ) |
| 29 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfSingletoncxx . . $ LogicFeatures#lfSingleton.); |
| 30 | } |
| 31 | |
| 32 | void LogicFeaturescxx . . $ LogicFeatures# :: fillRoleDatacxx . . $ LogicFeatures#fillRoleData(b2320954eb62eea2). ( const TRolecxx . . $ TRole#* p, bool both ) |
| 33 | { |
| 34 | if ( unlikelycxx . . $ `Kernel/globaldef.h:29:10`!(p->isTop()) ) |
| 35 | { |
| 36 | if ( !p->isDataRolecxx . . $ TRole#isDataRole(50ce9a9e25b4a850).() ) |
| 37 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfTopRolecxx . . $ LogicFeatures#lfTopRole.); |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | if ( p->getIdcxx . . $ TNamedEntry#getId(455f465bc33b4cdf).() > 0 ) // direct role |
| 42 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfDirectRolescxx . . $ LogicFeatures#lfDirectRoles.); |
| 43 | else |
| 44 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfInverseRolescxx . . $ LogicFeatures#lfInverseRoles.); |
| 45 | |
| 46 | // inverse roles check |
| 47 | if ( both ) |
| 48 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfBothRolescxx . . $ LogicFeatures#lfBothRoles.); |
| 49 | |
| 50 | // transitivity check |
| 51 | if ( p->isTransitivecxx . . $ TRole#isTransitive(50ce9a9e25b4a850).() ) |
| 52 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfTransitiveRolescxx . . $ LogicFeatures#lfTransitiveRoles.); |
| 53 | |
| 54 | // subsumption check |
| 55 | if ( p->hasToldSubsumerscxx . . $ ClassifiableEntry#hasToldSubsumers(50ce9a9e25b4a850).() ) |
| 56 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfRolesSubsumptioncxx . . $ LogicFeatures#lfRolesSubsumption.); |
| 57 | |
| 58 | // functionality check |
| 59 | if ( p->isFunctionalcxx . . $ TRole#isFunctional(50ce9a9e25b4a850).() ) |
| 60 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfFunctionalRolescxx . . $ LogicFeatures#lfFunctionalRoles.); |
| 61 | |
| 62 | // R&D check |
| 63 | if ( p->getBPDomaincxx . . $ TRole#getBPDomain(455f465bc33b4cdf).() != bpTOPcxx . . $ bpTOP. || p->getBPRangecxx . . $ TRole#getBPRange(455f465bc33b4cdf).() != bpTOPcxx . . $ bpTOP. ) |
| 64 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfRangeAndDomaincxx . . $ LogicFeatures#lfRangeAndDomain.); |
| 65 | } |
| 66 | |
| 67 | void LogicFeaturescxx . . $ LogicFeatures# :: fillDAGDatacxx . . $ LogicFeatures#fillDAGData(6a493ba1542d2d3b). ( const DLVertexcxx . . $ DLVertex#& v, bool ) |
| 68 | { |
| 69 | switch ( v.Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8). () ) |
| 70 | { |
| 71 | case dtForallcxx . . $ dtForall.: |
| 72 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfSomeConstructorcxx . . $ LogicFeatures#lfSomeConstructor.); |
| 73 | break; |
| 74 | |
| 75 | case dtLEcxx . . $ dtLE.: |
| 76 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfNConstructorcxx . . $ LogicFeatures#lfNConstructor.); |
| 77 | if ( v.getCcxx . . $ DLVertex#getC(455f465bc33b4cdf).() != bpTOPcxx . . $ bpTOP. ) |
| 78 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfQConstructorcxx . . $ LogicFeatures#lfQConstructor.); |
| 79 | |
| 80 | break; |
| 81 | |
| 82 | case dtPSingletoncxx . . $ dtPSingleton.: |
| 83 | case dtNSingletoncxx . . $ dtNSingleton.: |
| 84 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfSingletoncxx . . $ LogicFeatures#lfSingleton.); |
| 85 | break; |
| 86 | |
| 87 | case dtIrrcxx . . $ dtIrr.: |
| 88 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfSelfRefcxx . . $ LogicFeatures#lfSelfRef.); |
| 89 | break; |
| 90 | |
| 91 | default: // any other vertex -- nothing to do |
| 92 | break; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | void LogicFeaturescxx . . $ LogicFeatures# :: writeStatecxx . . $ LogicFeatures#writeState(83f5f38750778ac8). ( void ) const |
| 97 | { |
| 98 | CHECK_LL_RETURNcxx . . $ `Kernel/LeveLogger.h:60:9`!(llAlways); |
| 99 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\nLoaded KB used DL with following features:\nKB contains "; |
| 100 | if ( !hasInverseRolecxx . . $ LogicFeatures#hasInverseRole(50ce9a9e25b4a850). () ) |
| 101 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "NO "; |
| 102 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "inverse role(s)\nKB contains "; |
| 103 | if ( !hasRoleHierarchycxx . . $ LogicFeatures#hasRoleHierarchy(50ce9a9e25b4a850). () ) |
| 104 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "NO "; |
| 105 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "role hierarchy\nKB contains "; |
| 106 | if ( !hasTransitiveRolecxx . . $ LogicFeatures#hasTransitiveRole(50ce9a9e25b4a850). () ) |
| 107 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "NO "; |
| 108 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "transitive role(s)\nKB contains "; |
| 109 | if ( !hasTopRolecxx . . $ LogicFeatures#hasTopRole(50ce9a9e25b4a850). () ) |
| 110 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "NO "; |
| 111 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "top role expressions\nKB contains "; |
| 112 | if ( !hasSomeAllcxx . . $ LogicFeatures#hasSomeAll(50ce9a9e25b4a850). () ) |
| 113 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "NO "; |
| 114 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "quantifier(s)\nKB contains "; |
| 115 | if ( !hasFunctionalRestrictioncxx . . $ LogicFeatures#hasFunctionalRestriction(50ce9a9e25b4a850). () ) |
| 116 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "NO "; |
| 117 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "functional restriction(s)\nKB contains "; |
| 118 | if ( !hasNumberRestrictioncxx . . $ LogicFeatures#hasNumberRestriction(50ce9a9e25b4a850). () ) |
| 119 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "NO "; |
| 120 | else if ( hasQNumberRestrictioncxx . . $ LogicFeatures#hasQNumberRestriction(50ce9a9e25b4a850). () ) |
| 121 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "qualified "; |
| 122 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "number restriction(s)\nKB contains "; |
| 123 | if ( !hasSingletonscxx . . $ LogicFeatures#hasSingletons(50ce9a9e25b4a850).() ) |
| 124 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "NO "; |
| 125 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "nominal(s)\n"; |
| 126 | } |