| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2008-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 TDLAXIOM_H |
| 21 | #define TDLAXIOM_H |
| 22 | |
| 23 | #include "tDLExpression.h" |
| 24 | |
| 25 | // forward declaration for all axiom classes: necessary for the visitor pattern |
| 26 | class TDLAxiomDeclaration; |
| 27 | |
| 28 | class TDLAxiomEquivalentConcepts; |
| 29 | class TDLAxiomDisjointConcepts; |
| 30 | class TDLAxiomDisjointUnion; |
| 31 | class TDLAxiomEquivalentORoles; |
| 32 | class TDLAxiomEquivalentDRoles; |
| 33 | class TDLAxiomDisjointORoles; |
| 34 | class TDLAxiomDisjointDRoles; |
| 35 | class TDLAxiomSameIndividuals; |
| 36 | class TDLAxiomDifferentIndividuals; |
| 37 | class TDLAxiomFairnessConstraint; |
| 38 | |
| 39 | class TDLAxiomRoleInverse; |
| 40 | class TDLAxiomORoleSubsumption; |
| 41 | class TDLAxiomDRoleSubsumption; |
| 42 | class TDLAxiomORoleDomain; |
| 43 | class TDLAxiomDRoleDomain; |
| 44 | class TDLAxiomORoleRange; |
| 45 | class TDLAxiomDRoleRange; |
| 46 | class TDLAxiomRoleTransitive; |
| 47 | class TDLAxiomRoleReflexive; |
| 48 | class TDLAxiomRoleIrreflexive; |
| 49 | class TDLAxiomRoleSymmetric; |
| 50 | class TDLAxiomRoleAsymmetric; |
| 51 | class TDLAxiomORoleFunctional; |
| 52 | class TDLAxiomDRoleFunctional; |
| 53 | class TDLAxiomRoleInverseFunctional; |
| 54 | |
| 55 | class TDLAxiomConceptInclusion; |
| 56 | class TDLAxiomInstanceOf; |
| 57 | class TDLAxiomRelatedTo; |
| 58 | class TDLAxiomRelatedToNot; |
| 59 | class TDLAxiomValueOf; |
| 60 | class TDLAxiomValueOfNot; |
| 61 | |
| 62 | /// general visitor for DL axioms |
| 63 | class DLAxiomVisitor |
| 64 | { |
| 65 | public: // visitor interface |
| 66 | virtual void visit ( const TDLAxiomDeclaration& axiom ) = 0; |
| 67 | |
| 68 | virtual void visit ( const TDLAxiomEquivalentConcepts& axiom ) = 0; |
| 69 | virtual void visit ( const TDLAxiomDisjointConcepts& axiom ) = 0; |
| 70 | virtual void visit ( const TDLAxiomDisjointUnion& axiom ) = 0; |
| 71 | virtual void visit ( const TDLAxiomEquivalentORoles& axiom ) = 0; |
| 72 | virtual void visit ( const TDLAxiomEquivalentDRoles& axiom ) = 0; |
| 73 | virtual void visit ( const TDLAxiomDisjointORoles& axiom ) = 0; |
| 74 | virtual void visit ( const TDLAxiomDisjointDRoles& axiom ) = 0; |
| 75 | virtual void visit ( const TDLAxiomSameIndividuals& axiom ) = 0; |
| 76 | virtual void visit ( const TDLAxiomDifferentIndividuals& axiom ) = 0; |
| 77 | virtual void visit ( const TDLAxiomFairnessConstraint& axiom ) = 0; |
| 78 | |
| 79 | virtual void visit ( const TDLAxiomRoleInverse& axiom ) = 0; |
| 80 | virtual void visit ( const TDLAxiomORoleSubsumption& axiom ) = 0; |
| 81 | virtual void visit ( const TDLAxiomDRoleSubsumption& axiom ) = 0; |
| 82 | virtual void visit ( const TDLAxiomORoleDomain& axiom ) = 0; |
| 83 | virtual void visit ( const TDLAxiomDRoleDomain& axiom ) = 0; |
| 84 | virtual void visit ( const TDLAxiomORoleRange& axiom ) = 0; |
| 85 | virtual void visit ( const TDLAxiomDRoleRange& axiom ) = 0; |
| 86 | virtual void visit ( const TDLAxiomRoleTransitive& axiom ) = 0; |
| 87 | virtual void visit ( const TDLAxiomRoleReflexive& axiom ) = 0; |
| 88 | virtual void visit ( const TDLAxiomRoleIrreflexive& axiom ) = 0; |
| 89 | virtual void visit ( const TDLAxiomRoleSymmetric& axiom ) = 0; |
| 90 | virtual void visit ( const TDLAxiomRoleAsymmetric& axiom ) = 0; |
| 91 | virtual void visit ( const TDLAxiomORoleFunctional& axiom ) = 0; |
| 92 | virtual void visit ( const TDLAxiomDRoleFunctional& axiom ) = 0; |
| 93 | virtual void visit ( const TDLAxiomRoleInverseFunctional& axiom ) = 0; |
| 94 | |
| 95 | virtual void visit ( const TDLAxiomConceptInclusion& axiom ) = 0; |
| 96 | virtual void visit ( const TDLAxiomInstanceOf& axiom ) = 0; |
| 97 | virtual void visit ( const TDLAxiomRelatedTo& axiom ) = 0; |
| 98 | virtual void visit ( const TDLAxiomRelatedToNot& axiom ) = 0; |
| 99 | virtual void visit ( const TDLAxiomValueOf& axiom ) = 0; |
| 100 | virtual void visit ( const TDLAxiomValueOfNot& axiom ) = 0; |
| 101 | |
| 102 | virtual ~DLAxiomVisitor() = default; |
| 103 | }; // DLAxiomVisitor |
| 104 | |
| 105 | /// empty implementation of DL axioms visitor |
| 106 | class DLAxiomVisitorEmpty: public DLAxiomVisitor |
| 107 | { |
| 108 | public: // visitor interface |
| 109 | void visit ( const TDLAxiomDeclaration& ) override {} |
| 110 | |
| 111 | void visit ( const TDLAxiomEquivalentConcepts& ) override {} |
| 112 | void visit ( const TDLAxiomDisjointConcepts& ) override {} |
| 113 | void visit ( const TDLAxiomDisjointUnion& ) override {} |
| 114 | void visit ( const TDLAxiomEquivalentORoles& ) override {} |
| 115 | void visit ( const TDLAxiomEquivalentDRoles& ) override {} |
| 116 | void visit ( const TDLAxiomDisjointORoles& ) override {} |
| 117 | void visit ( const TDLAxiomDisjointDRoles& ) override {} |
| 118 | void visit ( const TDLAxiomSameIndividuals& ) override {} |
| 119 | void visit ( const TDLAxiomDifferentIndividuals& ) override {} |
| 120 | void visit ( const TDLAxiomFairnessConstraint& ) override {} |
| 121 | |
| 122 | void visit ( const TDLAxiomRoleInverse& ) override {} |
| 123 | void visit ( const TDLAxiomORoleSubsumption& ) override {} |
| 124 | void visit ( const TDLAxiomDRoleSubsumption& ) override {} |
| 125 | void visit ( const TDLAxiomORoleDomain& ) override {} |
| 126 | void visit ( const TDLAxiomDRoleDomain& ) override {} |
| 127 | void visit ( const TDLAxiomORoleRange& ) override {} |
| 128 | void visit ( const TDLAxiomDRoleRange& ) override {} |
| 129 | void visit ( const TDLAxiomRoleTransitive& ) override {} |
| 130 | void visit ( const TDLAxiomRoleReflexive& ) override {} |
| 131 | void visit ( const TDLAxiomRoleIrreflexive& ) override {} |
| 132 | void visit ( const TDLAxiomRoleSymmetric& ) override {} |
| 133 | void visit ( const TDLAxiomRoleAsymmetric& ) override {} |
| 134 | void visit ( const TDLAxiomORoleFunctional& ) override {} |
| 135 | void visit ( const TDLAxiomDRoleFunctional& ) override {} |
| 136 | void visit ( const TDLAxiomRoleInverseFunctional& ) override {} |
| 137 | |
| 138 | void visit ( const TDLAxiomConceptInclusion& ) override {} |
| 139 | void visit ( const TDLAxiomInstanceOf& ) override {} |
| 140 | void visit ( const TDLAxiomRelatedTo& ) override {} |
| 141 | void visit ( const TDLAxiomRelatedToNot& ) override {} |
| 142 | void visit ( const TDLAxiomValueOf& ) override {} |
| 143 | void visit ( const TDLAxiomValueOfNot& ) override {} |
| 144 | }; // DLAxiomVisitor |
| 145 | |
| 146 | /// signature of an axiom |
| 147 | class TSignature; |
| 148 | /// atom that the axiom belongs to |
| 149 | class TOntologyAtom; |
| 150 | |
| 151 | /// base class for the DL axiom, which include T-, A- and RBox ones |
| 152 | class TDLAxiom |
| 153 | { |
| 154 | protected: // members |
| 155 | /// id of the axiom |
| 156 | unsigned int id = 0; |
| 157 | /// signature (built lazily on demand) |
| 158 | TSignature* sig = nullptr; |
| 159 | /// atom of the ontology (build lazily on demand) |
| 160 | const TOntologyAtom* Atom = nullptr; |
| 161 | /// flag to show whether it is used (to support retraction) |
| 162 | bool used = true; |
| 163 | /// flag to show whether or not the axiom is in the module |
| 164 | bool inModule = false; |
| 165 | /// flag to show whether or not the axiom is in the search space for the optimised modularization algorithm |
| 166 | bool inSearchSpace = false; |
| 167 | |
| 168 | protected: // methods |
| 169 | /// build signature of an axiom |
| 170 | void buildSignature ( void ); |
| 171 | |
| 172 | public: // interface |
| 173 | /// empty c'tor |
| 174 | TDLAxiom() = default; |
| 175 | /// d'tor: delete signature if it was created |
| 176 | virtual ~TDLAxiom(); |
| 177 | |
| 178 | // id management |
| 179 | |
| 180 | /// set the id |
| 181 | void setId ( unsigned int Id ) { id = Id; } |
| 182 | /// get the id |
| 183 | unsigned int getId ( void ) const { return id; } |
| 184 | |
| 185 | // used management |
| 186 | |
| 187 | /// set the used flag |
| 188 | void setUsed ( bool Used ) { used = Used; } |
| 189 | /// get the value of the used flag |
| 190 | bool isUsed ( void ) const { return used; } |
| 191 | |
| 192 | // modularity management |
| 193 | |
| 194 | /// set the inModule flag |
| 195 | void setInModule ( bool flag ) { inModule = flag; } |
| 196 | /// get the value of the inModule flag |
| 197 | bool isInModule ( void ) const { return inModule; } |
| 198 | /// set the isSearchSpace flag |
| 199 | void setInSS ( bool flag ) { inSearchSpace = flag; } |
| 200 | /// get the value of the isSearchSpace flag |
| 201 | bool isInSS ( void ) const { return inSearchSpace; } |
| 202 | |
| 203 | // signature access |
| 204 | |
| 205 | const TSignature& getSignature ( void ) |
| 206 | { |
| 207 | if ( sig == nullptr ) // 1st access: build it |
| 208 | buildSignature(); |
| 209 | return *sig; |
| 210 | } |
| 211 | |
| 212 | // ontological atomic structure management |
| 213 | |
| 214 | /// set atom to which the axiom belongs |
| 215 | void setAtom ( const TOntologyAtom* atom ) { Atom = atom; } |
| 216 | /// get the atom an axiom belongs to |
| 217 | const TOntologyAtom* getAtom ( void ) const { return Atom; } |
| 218 | |
| 219 | // visitor interface |
| 220 | |
| 221 | /// accept method for the visitor pattern |
| 222 | virtual void accept ( DLAxiomVisitor& visitor ) const = 0; |
| 223 | }; // TDLAxiom |
| 224 | |
| 225 | //------------------------------------------------------------------ |
| 226 | /// globally visible axiom vector |
| 227 | //------------------------------------------------------------------ |
| 228 | typedef std::vector<TDLAxiom*> AxiomVec; |
| 229 | |
| 230 | //------------------------------------------------------------------ |
| 231 | /// general declaration axiom |
| 232 | //------------------------------------------------------------------ |
| 233 | class TDLAxiomDeclaration: public TDLAxiom |
| 234 | { |
| 235 | protected: // members |
| 236 | const TDLExpression* D; |
| 237 | |
| 238 | public: // interface |
| 239 | /// c'tor: create an axiom |
| 240 | explicit TDLAxiomDeclaration ( const TDLExpression* d ) : TDLAxiom(), D(d) {} |
| 241 | |
| 242 | /// access |
| 243 | const TDLExpression* getDeclaration ( void ) const { return D; } |
| 244 | /// accept method for the visitor pattern |
| 245 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 246 | }; // TDLAxiomIndividual |
| 247 | |
| 248 | //------------------------------------------------------------------ |
| 249 | // n-ary axioms |
| 250 | //------------------------------------------------------------------ |
| 251 | |
| 252 | //------------------------------------------------------------------ |
| 253 | /// Concept equivalence axiom |
| 254 | //------------------------------------------------------------------ |
| 255 | class TDLAxiomEquivalentConcepts: public TDLAxiom, public TDLNAryExpression<TDLConceptExpression> |
| 256 | { |
| 257 | public: // interface |
| 258 | /// c'tor: create an axiom for C1 = ... = Cn |
| 259 | explicit TDLAxiomEquivalentConcepts ( const ExpressionArray& v ) |
| 260 | : TDLAxiom() |
| 261 | , TDLNAryExpression<TDLConceptExpression>("concept expression","equivalent concepts") |
| 262 | { add(v); } |
| 263 | /// accept method for the visitor pattern |
| 264 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 265 | }; // TDLAxiomEquivalentConcepts |
| 266 | |
| 267 | //------------------------------------------------------------------ |
| 268 | /// Concept disjointness axiom |
| 269 | //------------------------------------------------------------------ |
| 270 | class TDLAxiomDisjointConcepts: public TDLAxiom, public TDLNAryExpression<TDLConceptExpression> |
| 271 | { |
| 272 | public: // interface |
| 273 | /// c'tor: create an axiom for C1 != ... != Cn |
| 274 | explicit TDLAxiomDisjointConcepts ( const ExpressionArray& v ) |
| 275 | : TDLAxiom() |
| 276 | , TDLNAryExpression<TDLConceptExpression>("concept expression","disjoint concepts") |
| 277 | { add(v); } |
| 278 | /// accept method for the visitor pattern |
| 279 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 280 | }; // TDLAxiomDisjointConcepts |
| 281 | |
| 282 | //------------------------------------------------------------------ |
| 283 | /// Disjoint Union axiom |
| 284 | //------------------------------------------------------------------ |
| 285 | class TDLAxiomDisjointUnion: public TDLAxiom, public TDLNAryExpression<TDLConceptExpression> |
| 286 | { |
| 287 | protected: // members |
| 288 | const TDLConceptExpression* C; |
| 289 | |
| 290 | public: // interface |
| 291 | /// c'tor: create an axiom |
| 292 | TDLAxiomDisjointUnion ( const TDLConceptExpression* c, const ExpressionArray& v ) |
| 293 | : TDLAxiom() |
| 294 | , TDLNAryExpression<TDLConceptExpression>("concept expression","disjoint union") |
| 295 | , C(c) |
| 296 | { add(v); } |
| 297 | /// accept method for the visitor pattern |
| 298 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 299 | |
| 300 | /// access |
| 301 | const TDLConceptExpression* getC ( void ) const { return C; } |
| 302 | }; // TDLAxiomInstanceOf |
| 303 | |
| 304 | //------------------------------------------------------------------ |
| 305 | /// Object Role equivalence axiom |
| 306 | //------------------------------------------------------------------ |
| 307 | class TDLAxiomEquivalentORoles: public TDLAxiom, public TDLNAryExpression<TDLObjectRoleExpression> |
| 308 | { |
| 309 | public: // interface |
| 310 | /// c'tor: create an axiom for OR1 = ... = ORn |
| 311 | explicit TDLAxiomEquivalentORoles ( const ExpressionArray& v ) |
| 312 | : TDLAxiom() |
| 313 | , TDLNAryExpression<TDLObjectRoleExpression>("object role expression","equivalent roles") |
| 314 | { add(v); } |
| 315 | /// accept method for the visitor pattern |
| 316 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 317 | }; // TDLAxiomEquivalentORoles |
| 318 | |
| 319 | //------------------------------------------------------------------ |
| 320 | /// Data Role equivalence axiom |
| 321 | //------------------------------------------------------------------ |
| 322 | class TDLAxiomEquivalentDRoles: public TDLAxiom, public TDLNAryExpression<TDLDataRoleExpression> |
| 323 | { |
| 324 | public: // interface |
| 325 | /// c'tor: create an axiom for DR1 = ... = DRn |
| 326 | explicit TDLAxiomEquivalentDRoles ( const ExpressionArray& v ) |
| 327 | : TDLAxiom() |
| 328 | , TDLNAryExpression<TDLDataRoleExpression>("data role expression","equivalent roles") |
| 329 | { add(v); } |
| 330 | /// accept method for the visitor pattern |
| 331 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 332 | }; // TDLAxiomEquivalentDRoles |
| 333 | |
| 334 | //------------------------------------------------------------------ |
| 335 | /// Object Role disjointness axiom |
| 336 | //------------------------------------------------------------------ |
| 337 | class TDLAxiomDisjointORoles: public TDLAxiom, public TDLNAryExpression<TDLObjectRoleExpression> |
| 338 | { |
| 339 | public: // interface |
| 340 | /// c'tor: create an axiom for OR1 != ... != ORn |
| 341 | explicit TDLAxiomDisjointORoles ( const ExpressionArray& v ) |
| 342 | : TDLAxiom() |
| 343 | , TDLNAryExpression<TDLObjectRoleExpression>("object role expression","disjoint roles") |
| 344 | { add(v); } |
| 345 | /// accept method for the visitor pattern |
| 346 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 347 | }; // TDLAxiomDisjointORoles |
| 348 | |
| 349 | //------------------------------------------------------------------ |
| 350 | /// Data Role disjointness axiom |
| 351 | //------------------------------------------------------------------ |
| 352 | class TDLAxiomDisjointDRoles: public TDLAxiom, public TDLNAryExpression<TDLDataRoleExpression> |
| 353 | { |
| 354 | public: // interface |
| 355 | /// c'tor: create an axiom for DR1 != ... != DRn |
| 356 | explicit TDLAxiomDisjointDRoles ( const ExpressionArray& v ) |
| 357 | : TDLAxiom() |
| 358 | , TDLNAryExpression<TDLDataRoleExpression>("data role expression","disjoint roles") |
| 359 | { add(v); } |
| 360 | /// accept method for the visitor pattern |
| 361 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 362 | }; // TDLAxiomDisjointDRoles |
| 363 | |
| 364 | //------------------------------------------------------------------ |
| 365 | /// Same individuals axiom |
| 366 | //------------------------------------------------------------------ |
| 367 | class TDLAxiomSameIndividuals: public TDLAxiom, public TDLNAryExpression<TDLIndividualExpression> |
| 368 | { |
| 369 | public: // interface |
| 370 | /// c'tor: create an axiom for i1 = ... = in |
| 371 | explicit TDLAxiomSameIndividuals ( const ExpressionArray& v ) |
| 372 | : TDLAxiom() |
| 373 | , TDLNAryExpression<TDLIndividualExpression>("individual expression","same individuals") |
| 374 | { add(v); } |
| 375 | /// accept method for the visitor pattern |
| 376 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 377 | }; // TDLAxiomSameIndividuals |
| 378 | |
| 379 | //------------------------------------------------------------------ |
| 380 | /// Different individuals axiom |
| 381 | //------------------------------------------------------------------ |
| 382 | class TDLAxiomDifferentIndividuals: public TDLAxiom, public TDLNAryExpression<TDLIndividualExpression> |
| 383 | { |
| 384 | public: // interface |
| 385 | /// c'tor: create an axiom for i1 != ... != in |
| 386 | explicit TDLAxiomDifferentIndividuals ( const ExpressionArray& v ) |
| 387 | : TDLAxiom() |
| 388 | , TDLNAryExpression<TDLIndividualExpression>("individual expression","different individuals") |
| 389 | { add(v); } |
| 390 | /// accept method for the visitor pattern |
| 391 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 392 | }; // TDLAxiomDifferentIndividuals |
| 393 | |
| 394 | //------------------------------------------------------------------ |
| 395 | /// Fairness constraint axiom |
| 396 | //------------------------------------------------------------------ |
| 397 | class TDLAxiomFairnessConstraint: public TDLAxiom, public TDLNAryExpression<TDLConceptExpression> |
| 398 | { |
| 399 | public: // interface |
| 400 | /// c'tor: create an axiom for Fair(C1), ... Fair(Cn) constraints |
| 401 | explicit TDLAxiomFairnessConstraint ( const ExpressionArray& v ) |
| 402 | : TDLAxiom() |
| 403 | , TDLNAryExpression<TDLConceptExpression>("concept expression","fairness") |
| 404 | { add(v); } |
| 405 | /// accept method for the visitor pattern |
| 406 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 407 | }; // TDLAxiomFairnessConstraint |
| 408 | |
| 409 | //------------------------------------------------------------------ |
| 410 | // Role-related axiom |
| 411 | //------------------------------------------------------------------ |
| 412 | |
| 413 | //------------------------------------------------------------------ |
| 414 | /// General axiom that contains a single object role |
| 415 | //------------------------------------------------------------------ |
| 416 | class TDLAxiomSingleORole: public TDLAxiom |
| 417 | { |
| 418 | protected: // members |
| 419 | const TDLObjectRoleExpression* Role; |
| 420 | |
| 421 | public: // interface |
| 422 | /// c'tor: create an axiom |
| 423 | explicit TDLAxiomSingleORole ( const TDLObjectRoleExpression* role ) |
| 424 | : TDLAxiom() |
| 425 | , Role(role) |
| 426 | {} |
| 427 | |
| 428 | /// access to role |
| 429 | const TDLObjectRoleExpression* getRole ( void ) const { return Role; } |
| 430 | }; // TDLAxiomSingleORole |
| 431 | |
| 432 | //------------------------------------------------------------------ |
| 433 | /// General axiom that contains a single data role |
| 434 | //------------------------------------------------------------------ |
| 435 | class TDLAxiomSingleDRole: public TDLAxiom |
| 436 | { |
| 437 | protected: // members |
| 438 | const TDLDataRoleExpression* Role; |
| 439 | |
| 440 | public: // interface |
| 441 | /// c'tor: create an axiom |
| 442 | explicit TDLAxiomSingleDRole ( const TDLDataRoleExpression* role ) |
| 443 | : TDLAxiom() |
| 444 | , Role(role) |
| 445 | {} |
| 446 | |
| 447 | /// access to role |
| 448 | const TDLDataRoleExpression* getRole ( void ) const { return Role; } |
| 449 | }; // TDLAxiomSingleDRole |
| 450 | |
| 451 | //------------------------------------------------------------------ |
| 452 | /// Role inverse axiom |
| 453 | //------------------------------------------------------------------ |
| 454 | class TDLAxiomRoleInverse: public TDLAxiomSingleORole |
| 455 | { |
| 456 | protected: // members |
| 457 | const TDLObjectRoleExpression* InvRole; |
| 458 | |
| 459 | public: // interface |
| 460 | /// c'tor: create an axiom |
| 461 | TDLAxiomRoleInverse ( const TDLObjectRoleExpression* dirRole, const TDLObjectRoleExpression* invRole ) |
| 462 | : TDLAxiomSingleORole(dirRole) |
| 463 | , InvRole(invRole) |
| 464 | {} |
| 465 | /// accept method for the visitor pattern |
| 466 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 467 | |
| 468 | /// access to role |
| 469 | const TDLObjectRoleExpression* getInvRole ( void ) const { return InvRole; } |
| 470 | }; // TDLAxiomRoleInverse |
| 471 | |
| 472 | //------------------------------------------------------------------ |
| 473 | /// Object Role subsumption axiom |
| 474 | //------------------------------------------------------------------ |
| 475 | class TDLAxiomORoleSubsumption: public TDLAxiomSingleORole |
| 476 | { |
| 477 | protected: // members |
| 478 | const TDLObjectRoleComplexExpression* SubRole; |
| 479 | |
| 480 | public: // interface |
| 481 | /// c'tor: create an axiom |
| 482 | TDLAxiomORoleSubsumption ( const TDLObjectRoleComplexExpression* subRole, const TDLObjectRoleExpression* supRole ) |
| 483 | : TDLAxiomSingleORole(supRole) |
| 484 | , SubRole(subRole) |
| 485 | {} |
| 486 | /// accept method for the visitor pattern |
| 487 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 488 | |
| 489 | /// access to role |
| 490 | const TDLObjectRoleComplexExpression* getSubRole ( void ) const { return SubRole; } |
| 491 | }; // TDLAxiomORoleSubsumption |
| 492 | |
| 493 | //------------------------------------------------------------------ |
| 494 | /// Data Role subsumption axiom |
| 495 | //------------------------------------------------------------------ |
| 496 | class TDLAxiomDRoleSubsumption: public TDLAxiomSingleDRole |
| 497 | { |
| 498 | protected: // members |
| 499 | const TDLDataRoleExpression* SubRole; |
| 500 | |
| 501 | public: // interface |
| 502 | /// c'tor: create an axiom |
| 503 | TDLAxiomDRoleSubsumption ( const TDLDataRoleExpression* subRole, const TDLDataRoleExpression* supRole ) |
| 504 | : TDLAxiomSingleDRole(supRole) |
| 505 | , SubRole(subRole) |
| 506 | {} |
| 507 | /// accept method for the visitor pattern |
| 508 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 509 | |
| 510 | /// access to role |
| 511 | const TDLDataRoleExpression* getSubRole ( void ) const { return SubRole; } |
| 512 | }; // TDLAxiomDRoleSubsumption |
| 513 | |
| 514 | //------------------------------------------------------------------ |
| 515 | /// Object Role domain axiom |
| 516 | //------------------------------------------------------------------ |
| 517 | class TDLAxiomORoleDomain: public TDLAxiomSingleORole |
| 518 | { |
| 519 | protected: // members |
| 520 | const TDLConceptExpression* Domain; |
| 521 | |
| 522 | public: // interface |
| 523 | /// c'tor: create an axiom |
| 524 | TDLAxiomORoleDomain ( const TDLObjectRoleExpression* role, const TDLConceptExpression* domain ) |
| 525 | : TDLAxiomSingleORole(role) |
| 526 | , Domain(domain) |
| 527 | {} |
| 528 | /// accept method for the visitor pattern |
| 529 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 530 | |
| 531 | /// access |
| 532 | const TDLConceptExpression* getDomain ( void ) const { return Domain; } |
| 533 | }; // TDLAxiomORoleDomain |
| 534 | |
| 535 | //------------------------------------------------------------------ |
| 536 | /// Data Role domain axiom |
| 537 | //------------------------------------------------------------------ |
| 538 | class TDLAxiomDRoleDomain: public TDLAxiomSingleDRole |
| 539 | { |
| 540 | protected: // members |
| 541 | const TDLConceptExpression* Domain; |
| 542 | |
| 543 | public: // interface |
| 544 | /// c'tor: create an axiom |
| 545 | TDLAxiomDRoleDomain ( const TDLDataRoleExpression* role, const TDLConceptExpression* domain ) |
| 546 | : TDLAxiomSingleDRole(role) |
| 547 | , Domain(domain) |
| 548 | {} |
| 549 | /// accept method for the visitor pattern |
| 550 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 551 | |
| 552 | /// access |
| 553 | const TDLConceptExpression* getDomain ( void ) const { return Domain; } |
| 554 | }; // TDLAxiomDRoleDomain |
| 555 | |
| 556 | //------------------------------------------------------------------ |
| 557 | /// Object Role range axiom |
| 558 | //------------------------------------------------------------------ |
| 559 | class TDLAxiomORoleRange: public TDLAxiomSingleORole |
| 560 | { |
| 561 | protected: // members |
| 562 | const TDLConceptExpression* Range; |
| 563 | |
| 564 | public: // interface |
| 565 | /// c'tor: create an axiom |
| 566 | TDLAxiomORoleRange ( const TDLObjectRoleExpression* role, const TDLConceptExpression* range ) |
| 567 | : TDLAxiomSingleORole(role) |
| 568 | , Range(range) |
| 569 | {} |
| 570 | /// accept method for the visitor pattern |
| 571 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 572 | |
| 573 | /// access |
| 574 | const TDLConceptExpression* getRange ( void ) const { return Range; } |
| 575 | }; // TDLAxiomORoleRange |
| 576 | |
| 577 | //------------------------------------------------------------------ |
| 578 | /// Data Role range axiom |
| 579 | //------------------------------------------------------------------ |
| 580 | class TDLAxiomDRoleRange: public TDLAxiomSingleDRole |
| 581 | { |
| 582 | protected: // members |
| 583 | const TDLDataExpression* Range; |
| 584 | |
| 585 | public: // interface |
| 586 | /// c'tor: create an axiom |
| 587 | TDLAxiomDRoleRange ( const TDLDataRoleExpression* role, const TDLDataExpression* range ) |
| 588 | : TDLAxiomSingleDRole(role) |
| 589 | , Range(range) |
| 590 | {} |
| 591 | /// accept method for the visitor pattern |
| 592 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 593 | |
| 594 | /// access |
| 595 | const TDLDataExpression* getRange ( void ) const { return Range; } |
| 596 | }; // TDLAxiomDRoleRange |
| 597 | |
| 598 | //------------------------------------------------------------------ |
| 599 | /// Role transitivity axiom |
| 600 | //------------------------------------------------------------------ |
| 601 | class TDLAxiomRoleTransitive: public TDLAxiomSingleORole |
| 602 | { |
| 603 | public: // interface |
| 604 | /// c'tor: create an axiom |
| 605 | explicit TDLAxiomRoleTransitive ( const TDLObjectRoleExpression* role ) |
| 606 | : TDLAxiomSingleORole(role) |
| 607 | {} |
| 608 | /// accept method for the visitor pattern |
| 609 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 610 | }; // TDLAxiomRoleTransitive |
| 611 | |
| 612 | //------------------------------------------------------------------ |
| 613 | /// Role reflexivity axiom |
| 614 | //------------------------------------------------------------------ |
| 615 | class TDLAxiomRoleReflexive: public TDLAxiomSingleORole |
| 616 | { |
| 617 | public: // interface |
| 618 | /// c'tor: create an axiom |
| 619 | explicit TDLAxiomRoleReflexive ( const TDLObjectRoleExpression* role ) |
| 620 | : TDLAxiomSingleORole(role) |
| 621 | {} |
| 622 | /// accept method for the visitor pattern |
| 623 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 624 | }; // TDLAxiomRoleReflexive |
| 625 | |
| 626 | //------------------------------------------------------------------ |
| 627 | /// Role irreflexivity axiom |
| 628 | //------------------------------------------------------------------ |
| 629 | class TDLAxiomRoleIrreflexive: public TDLAxiomSingleORole |
| 630 | { |
| 631 | public: // interface |
| 632 | /// c'tor: create an axiom |
| 633 | explicit TDLAxiomRoleIrreflexive ( const TDLObjectRoleExpression* role ) |
| 634 | : TDLAxiomSingleORole(role) |
| 635 | {} |
| 636 | /// accept method for the visitor pattern |
| 637 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 638 | }; // TDLAxiomRoleIrreflexive |
| 639 | |
| 640 | //------------------------------------------------------------------ |
| 641 | /// Role symmetry axiom |
| 642 | //------------------------------------------------------------------ |
| 643 | class TDLAxiomRoleSymmetric: public TDLAxiomSingleORole |
| 644 | { |
| 645 | public: // interface |
| 646 | /// c'tor: create an axiom |
| 647 | explicit TDLAxiomRoleSymmetric ( const TDLObjectRoleExpression* role ) |
| 648 | : TDLAxiomSingleORole(role) |
| 649 | {} |
| 650 | /// accept method for the visitor pattern |
| 651 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 652 | }; // TDLAxiomRoleSymmetric |
| 653 | |
| 654 | //------------------------------------------------------------------ |
| 655 | /// Role asymmetry axiom |
| 656 | //------------------------------------------------------------------ |
| 657 | class TDLAxiomRoleAsymmetric: public TDLAxiomSingleORole |
| 658 | { |
| 659 | public: // interface |
| 660 | /// c'tor: create an axiom |
| 661 | explicit TDLAxiomRoleAsymmetric ( const TDLObjectRoleExpression* role ) |
| 662 | : TDLAxiomSingleORole(role) |
| 663 | {} |
| 664 | /// accept method for the visitor pattern |
| 665 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 666 | }; // TDLAxiomRoleAsymmetric |
| 667 | |
| 668 | //------------------------------------------------------------------ |
| 669 | /// Object Role functionality axiom |
| 670 | //------------------------------------------------------------------ |
| 671 | class TDLAxiomORoleFunctional: public TDLAxiomSingleORole |
| 672 | { |
| 673 | public: // interface |
| 674 | /// c'tor: create an axiom |
| 675 | explicit TDLAxiomORoleFunctional ( const TDLObjectRoleExpression* role ) |
| 676 | : TDLAxiomSingleORole(role) |
| 677 | {} |
| 678 | /// accept method for the visitor pattern |
| 679 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 680 | }; // TDLAxiomORoleFunctional |
| 681 | |
| 682 | //------------------------------------------------------------------ |
| 683 | /// Data Role functionality axiom |
| 684 | //------------------------------------------------------------------ |
| 685 | class TDLAxiomDRoleFunctional: public TDLAxiomSingleDRole |
| 686 | { |
| 687 | public: // interface |
| 688 | /// c'tor: create an axiom |
| 689 | explicit TDLAxiomDRoleFunctional ( const TDLDataRoleExpression* role ) |
| 690 | : TDLAxiomSingleDRole(role) |
| 691 | {} |
| 692 | /// accept method for the visitor pattern |
| 693 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 694 | }; // TDLAxiomDRoleFunctional |
| 695 | |
| 696 | //------------------------------------------------------------------ |
| 697 | /// Role inverse functionality axiom |
| 698 | //------------------------------------------------------------------ |
| 699 | class TDLAxiomRoleInverseFunctional: public TDLAxiomSingleORole |
| 700 | { |
| 701 | public: // interface |
| 702 | /// c'tor: create an axiom |
| 703 | explicit TDLAxiomRoleInverseFunctional ( const TDLObjectRoleExpression* role ) |
| 704 | : TDLAxiomSingleORole(role) |
| 705 | {} |
| 706 | /// accept method for the visitor pattern |
| 707 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 708 | }; // TDLAxiomRoleInverseFunctional |
| 709 | |
| 710 | |
| 711 | //------------------------------------------------------------------ |
| 712 | // Concept/individual axioms |
| 713 | //------------------------------------------------------------------ |
| 714 | |
| 715 | //------------------------------------------------------------------ |
| 716 | /// Concept inclusion axiom |
| 717 | //------------------------------------------------------------------ |
| 718 | class TDLAxiomConceptInclusion: public TDLAxiom |
| 719 | { |
| 720 | protected: // members |
| 721 | const TDLConceptExpression* Sub; |
| 722 | const TDLConceptExpression* Sup; |
| 723 | |
| 724 | public: // interface |
| 725 | /// c'tor: create an axiom |
| 726 | TDLAxiomConceptInclusion ( const TDLConceptExpression* sub, const TDLConceptExpression* sup ) : TDLAxiom(), Sub(sub), Sup(sup) {} |
| 727 | /// accept method for the visitor pattern |
| 728 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 729 | |
| 730 | /// access |
| 731 | const TDLConceptExpression* getSubC ( void ) const { return Sub; } |
| 732 | /// access |
| 733 | const TDLConceptExpression* getSupC ( void ) const { return Sup; } |
| 734 | }; // TDLAxiomConceptInclusion |
| 735 | |
| 736 | //------------------------------------------------------------------ |
| 737 | /// general individual-based axiom |
| 738 | //------------------------------------------------------------------ |
| 739 | class TDLAxiomIndividual: public TDLAxiom |
| 740 | { |
| 741 | protected: // members |
| 742 | const TDLIndividualExpression* I; |
| 743 | |
| 744 | public: // interface |
| 745 | /// c'tor: create an axiom |
| 746 | explicit TDLAxiomIndividual ( const TDLIndividualExpression* i ) : TDLAxiom(), I(i) {} |
| 747 | |
| 748 | /// access |
| 749 | const TDLIndividualExpression* getIndividual ( void ) const { return I; } |
| 750 | }; // TDLAxiomIndividual |
| 751 | |
| 752 | //------------------------------------------------------------------ |
| 753 | /// Instance axiom |
| 754 | //------------------------------------------------------------------ |
| 755 | class TDLAxiomInstanceOf: public TDLAxiomIndividual |
| 756 | { |
| 757 | protected: // members |
| 758 | const TDLConceptExpression* C; |
| 759 | |
| 760 | public: // interface |
| 761 | /// c'tor: create an axiom |
| 762 | TDLAxiomInstanceOf ( const TDLIndividualExpression* i, const TDLConceptExpression* c ) : TDLAxiomIndividual(i), C(c) {} |
| 763 | /// accept method for the visitor pattern |
| 764 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 765 | |
| 766 | /// access |
| 767 | const TDLConceptExpression* getC ( void ) const { return C; } |
| 768 | }; // TDLAxiomInstanceOf |
| 769 | |
| 770 | //------------------------------------------------------------------ |
| 771 | /// Related To axiom |
| 772 | //------------------------------------------------------------------ |
| 773 | class TDLAxiomRelatedTo: public TDLAxiomIndividual |
| 774 | { |
| 775 | protected: // members |
| 776 | const TDLObjectRoleExpression* R; |
| 777 | const TDLIndividualExpression* J; |
| 778 | |
| 779 | public: // interface |
| 780 | /// c'tor: create an axiom |
| 781 | TDLAxiomRelatedTo ( const TDLIndividualExpression* i, const TDLObjectRoleExpression* r, const TDLIndividualExpression* j ) |
| 782 | : TDLAxiomIndividual(i) |
| 783 | , R(r) |
| 784 | , J(j) |
| 785 | {} |
| 786 | /// accept method for the visitor pattern |
| 787 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 788 | |
| 789 | /// access |
| 790 | const TDLObjectRoleExpression* getRelation ( void ) const { return R; } |
| 791 | /// access |
| 792 | const TDLIndividualExpression* getRelatedIndividual ( void ) const { return J; } |
| 793 | }; // TDLAxiomRelatedTo |
| 794 | |
| 795 | //------------------------------------------------------------------ |
| 796 | /// Related To Not axiom |
| 797 | //------------------------------------------------------------------ |
| 798 | class TDLAxiomRelatedToNot: public TDLAxiomIndividual |
| 799 | { |
| 800 | protected: // members |
| 801 | const TDLObjectRoleExpression* R; |
| 802 | const TDLIndividualExpression* J; |
| 803 | |
| 804 | public: // interface |
| 805 | /// c'tor: create an axiom |
| 806 | TDLAxiomRelatedToNot ( const TDLIndividualExpression* i, const TDLObjectRoleExpression* r, const TDLIndividualExpression* j ) |
| 807 | : TDLAxiomIndividual(i) |
| 808 | , R(r) |
| 809 | , J(j) |
| 810 | {} |
| 811 | /// accept method for the visitor pattern |
| 812 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 813 | |
| 814 | /// access |
| 815 | const TDLObjectRoleExpression* getRelation ( void ) const { return R; } |
| 816 | /// access |
| 817 | const TDLIndividualExpression* getRelatedIndividual ( void ) const { return J; } |
| 818 | }; // TDLAxiomRelatedToNot |
| 819 | |
| 820 | //------------------------------------------------------------------ |
| 821 | /// Value Of axiom |
| 822 | //------------------------------------------------------------------ |
| 823 | class TDLAxiomValueOf: public TDLAxiomIndividual |
| 824 | { |
| 825 | protected: // members |
| 826 | const TDLDataRoleExpression* A; |
| 827 | const TDLDataValue* V; |
| 828 | |
| 829 | public: // interface |
| 830 | /// c'tor: create an axiom |
| 831 | TDLAxiomValueOf ( const TDLIndividualExpression* i, const TDLDataRoleExpression* a, const TDLDataValue* v ) |
| 832 | : TDLAxiomIndividual(i) |
| 833 | , A(a) |
| 834 | , V(v) |
| 835 | {} |
| 836 | /// accept method for the visitor pattern |
| 837 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 838 | |
| 839 | /// access to role |
| 840 | const TDLDataRoleExpression* getAttribute ( void ) const { return A; } |
| 841 | /// access to value |
| 842 | const TDLDataValue* getValue ( void ) const { return V; } |
| 843 | }; // TDLAxiomValueOf |
| 844 | |
| 845 | //------------------------------------------------------------------ |
| 846 | /// Related To Not axiom |
| 847 | //------------------------------------------------------------------ |
| 848 | class TDLAxiomValueOfNot: public TDLAxiomIndividual |
| 849 | { |
| 850 | protected: // members |
| 851 | const TDLDataRoleExpression* A; |
| 852 | const TDLDataValue* V; |
| 853 | |
| 854 | public: // interface |
| 855 | /// c'tor: create an axiom |
| 856 | TDLAxiomValueOfNot ( const TDLIndividualExpression* i, const TDLDataRoleExpression* a, const TDLDataValue* v ) |
| 857 | : TDLAxiomIndividual(i) |
| 858 | , A(a) |
| 859 | , V(v) |
| 860 | {} |
| 861 | /// accept method for the visitor pattern |
| 862 | void accept ( DLAxiomVisitor& visitor ) const override { visitor.visit(*this); } |
| 863 | |
| 864 | /// access to role |
| 865 | const TDLDataRoleExpression* getAttribute ( void ) const { return A; } |
| 866 | /// access to value |
| 867 | const TDLDataValue* getValue ( void ) const { return V; } |
| 868 | }; // TDLAxiomValueOfNot |
| 869 | |
| 870 | |
| 871 | #endif |