Debian Codegraph @

Kernel/tAxiomSet.h

raw symbols SCIP
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 #ifndef TAXIOMSET_H
21 #define TAXIOMSET_Hcxx . . $ `Kernel/tAxiomSet.h:21:9`!
22
23 #include "tAxiom.h"cxx . . $ `<file>/Kernel/tAxiom.h`/
24
25 class TBoxcxx . . $ TBox#;
26
27 namespace Statcxx . . $ Stat/
28 {
29 class SAbsInputcxx . . $ Stat/SAbsInput#: public countercxx . . $ counter#<SAbsInputcxx . . $ Stat/SAbsInput#> {};
30 class SAbsActioncxx . . $ Stat/SAbsAction#: public countercxx . . $ counter#<SAbsActioncxx . . $ Stat/SAbsAction#> {};
31 }
32
33 /// set of GCIs, absorbable and not
34 class TAxiomSetcxx . . $ TAxiomSet#
35 {
36 protected: // internal types
37 /// set of GCIs
38 typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<TAxiomcxx . . $ TAxiom#*> AxiomCollectioncxx . . $ TAxiomSet#AxiomCollection#;
39 /// method applying to the axiom
40 typedef bool (TAxiomSetcxx . . $ TAxiomSet#::*AbsMethodcxx . . $ TAxiomSet#AbsMethod#)(const TAxiomcxx . . $ TAxiom#*);
41 /// array of methods in application order
42 typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<AbsMethodcxx . . $ TAxiomSet#AbsMethod#> AbsActVectorcxx . . $ TAxiomSet#AbsActVector#;
43
44 protected: // members
45 /// host TBox that holds all concepts/etc
46 TBoxcxx . . $ TBox#& Hostcxx . . $ TAxiomSet#Host.;
47 /// set of axioms that accumulates incoming (and newly created) axioms;
48 AxiomCollectioncxx . . $ TAxiomSet#AxiomCollection# Accumcxx . . $ TAxiomSet#Accum.;
49 /// set of absorption action, in order
50 AbsActVectorcxx . . $ TAxiomSet#AbsActVector# ActionVectorcxx . . $ TAxiomSet#ActionVector.;
51
52 protected: // methods
53
54 /// add already built GCI p
55 void insertGCIcxx . . $ TAxiomSet#insertGCI(534e8fc5d42bc54f). ( TAxiomcxx . . $ TAxiom#* p )
56 {
57 # ifdef RKG_DEBUG_ABSORPTION
58 std::cout << "\n new axiom (" << Accum.size() << "):";
59 p->dump(std::cout);
60 # endif
61 Accumcxx . . $ TAxiomSet#Accum..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(p);
62 }
63 /// @return true iff axiom Q is a copy of already existing axiom
64 bool copyOfExistingcxx . . $ TAxiomSet#copyOfExisting(9c8122c9b670e3df). ( const TAxiomcxx . . $ TAxiom#* q ) const
65 {
66 for ( const TAxiomcxx . . $ TAxiom#* axiom : Accumcxx . . $ TAxiomSet#Accum. )
67 if ( *q ==cxx . . $ TAxiom#`operator==`(4685c79be7b49da1). *axiom )
68 {
69 # ifdef RKG_DEBUG_ABSORPTION
70 std::cout << " same as (" << p-Accum.begin() << "); skip";
71 # endif
72 return true;
73 }
74 return false;
75 }
76 /// absorb single GCI wrt absorption flags
77 bool absorbGCIcxx . . $ TAxiomSet#absorbGCI(3aa3f7904e349e06). ( const TAxiomcxx . . $ TAxiom#* p );
78 /// split given axiom
79 bool splitcxx . . $ TAxiomSet#split(3aa3f7904e349e06). ( const TAxiomcxx . . $ TAxiom#* p );
80 /// helper that inserts an axiom into Accum; @return bool if success
81 bool processNewAxiomcxx . . $ TAxiomSet#processNewAxiom(1643592822e5e2a6). ( TAxiomcxx . . $ TAxiom#* q )
82 {
83 // no input axiom -- nothing to add
84 if ( q == nullptr )
85 return false;
86 // if an axiom is a copy of already processed one -- fail to add (will result in a cycle)
87 if ( q->isCycliccxx . . $ TAxiom#isCyclic(50ce9a9e25b4a850).() )
88 {
89 delete q;
90 return false;
91 }
92 // if an axiom is a copy of a new one -- succeed but didn't really add anything
93 if ( copyOfExistingcxx . . $ TAxiomSet#copyOfExisting(9c8122c9b670e3df).(q) )
94 {
95 delete q;
96 return true;
97 }
98 // fresh axiom -- add it
99 insertGCIcxx . . $ TAxiomSet#insertGCI(534e8fc5d42bc54f).(q);
100 return true;
101 }
102 /// replace a defined concept with its description
103 bool simplifyCNcxx . . $ TAxiomSet#simplifyCN(3aa3f7904e349e06). ( const TAxiomcxx . . $ TAxiom#* p ) { return processNewAxiomcxx . . $ TAxiomSet#processNewAxiom(1643592822e5e2a6).(p->simplifyCNcxx . . $ TAxiom#simplifyCN(78ec7736a2556433).(Hostcxx . . $ TAxiomSet#Host.)); }
104 /// replace a universal restriction with a fresh concept
105 bool simplifyForallcxx . . $ TAxiomSet#simplifyForall(3aa3f7904e349e06). ( const TAxiomcxx . . $ TAxiom#* p ) { return processNewAxiomcxx . . $ TAxiomSet#processNewAxiom(1643592822e5e2a6).(p->simplifyForallcxx . . $ TAxiom#simplifyForall(78ec7736a2556433).(Hostcxx . . $ TAxiomSet#Host.)); }
106 /// replace a simple universal restriction with a fresh concept
107 bool simplifySForallcxx . . $ TAxiomSet#simplifySForall(3aa3f7904e349e06). ( const TAxiomcxx . . $ TAxiom#* p ) { return processNewAxiomcxx . . $ TAxiomSet#processNewAxiom(1643592822e5e2a6).(p->simplifySForallcxx . . $ TAxiom#simplifySForall(78ec7736a2556433).(Hostcxx . . $ TAxiomSet#Host.)); }
108
109 /// absorb single axiom AX into BOTTOM; @return true if succeed
110 bool absorbIntoBottomcxx . . $ TAxiomSet#absorbIntoBottom(3aa3f7904e349e06). ( const TAxiomcxx . . $ TAxiom#* ax ) { return ax->absorbIntoBottomcxx . . $ TAxiom#absorbIntoBottom(50ce9a9e25b4a850).(); }
111 /// absorb single axiom AX into TOP; @return true if succeed
112 bool absorbIntoTopcxx . . $ TAxiomSet#absorbIntoTop(3aa3f7904e349e06). ( const TAxiomcxx . . $ TAxiom#* ax ) { return ax->absorbIntoTopcxx . . $ TAxiom#absorbIntoTop(7e0306efbd9b1d86).(Hostcxx . . $ TAxiomSet#Host.); }
113 /// absorb single axiom AX into concept; @return true if succeed
114 bool absorbIntoConceptcxx . . $ TAxiomSet#absorbIntoConcept(3aa3f7904e349e06). ( const TAxiomcxx . . $ TAxiom#* ax ) { return ax->absorbIntoConceptcxx . . $ TAxiom#absorbIntoConcept(7e0306efbd9b1d86).(Hostcxx . . $ TAxiomSet#Host.); }
115 /// absorb single axiom AX into negated concept; @return true if succeed
116 bool absorbIntoNegConceptcxx . . $ TAxiomSet#absorbIntoNegConcept(3aa3f7904e349e06). ( const TAxiomcxx . . $ TAxiom#* ax ) { return ax->absorbIntoNegConceptcxx . . $ TAxiom#absorbIntoNegConcept(7e0306efbd9b1d86).(Hostcxx . . $ TAxiomSet#Host.); }
117 /// absorb single axiom AX into role domain; @return true if succeed
118 bool absorbIntoDomaincxx . . $ TAxiomSet#absorbIntoDomain(3aa3f7904e349e06). ( const TAxiomcxx . . $ TAxiom#* ax ) { return ax->absorbIntoDomaincxx . . $ TAxiom#absorbIntoDomain(50ce9a9e25b4a850).(); }
119
120 public: // interface
121 /// c'tor
122 explicit TAxiomSetcxx . . $ TAxiomSet#TAxiomSet(8683a8a7d2fb73f). ( TBoxcxx . . $ TBox#& host )
123 : Hostcxx . . $ TAxiomSet#Host.(host)
124 {}
125 /// d'tor
126 ~cxx . . $ TAxiomSet#`~TAxiomSet`(49f6e7a06ebc5aa8).TAxiomSetcxx . . $ TAxiomSet#();
127
128 /// init all absorption-related flags using given set of option
129 bool initAbsorptionFlagscxx . . $ TAxiomSet#initAbsorptionFlags(7c222eea44a24d43). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& flags );
130 /// add axiom for the GCI C [= D
131 void addAxiomcxx . . $ TAxiomSet#addAxiom(237c04ede5740138). ( DLTreecxx . . $ DLTree#* C, DLTreecxx . . $ DLTree#* D )
132 {
133 Statcxx . . $ Stat/::SAbsInputcxx . . $ Stat/SAbsInput#();
134 TAxiomcxx . . $ TAxiom#* p = new TAxiomcxx . . $ TAxiom#(nullptr);
135 p->addcxx . . $ TAxiom#add(edf821a2fc5509f9).(C);
136 p->addcxx . . $ TAxiom#add(edf821a2fc5509f9).(createSNFNotcxx . . $ createSNFNot(1bf715d485c1268).(D));
137 insertGCIcxx . . $ TAxiomSet#insertGCI(534e8fc5d42bc54f).(p);
138 }
139
140 /// absorb set of axioms; @return size of not absorbed set
141 size_tcxx . . $ size_t# absorbcxx . . $ TAxiomSet#absorb(f708dce9a8856c70). ( void );
142 /// get number of (not absorbed) GCIs
143 size_tcxx . . $ size_t# sizecxx . . $ TAxiomSet#size(fe4d2d262d4164a8). ( void ) const { return Accumcxx . . $ TAxiomSet#Accum..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); }
144 /// @return true if non-concept absorption were executed
145 bool wasRoleAbsorptionAppliedcxx . . $ TAxiomSet#wasRoleAbsorptionApplied(50ce9a9e25b4a850). ( void ) const { return Statcxx . . $ Stat/::SAbsRApplycxx . . $ Stat/SAbsRApply#::objects_createdcxx . . $ counter#objects_created. > 0; }
146 /// get GCI of all non-absorbed axioms
147 DLTreecxx . . $ DLTree#* getGCIcxx . . $ TAxiomSet#getGCI(7ba0ba2d2b26f6a8). ( void ) const
148 {
149 DLTreecxx . . $ DLTree#* ret = createTopcxx . . $ createTop(aa22cc08b69ae2ef).();
150 for ( const auto& axiom: Accumcxx . . $ TAxiomSet#Accum. )
151 ret = createSNFAndcxx . . $ createSNFAnd(f2877343b7b69ea7). ( ret, axiom->createAnAxiomcxx . . $ TAxiom#createAnAxiom(7ba0ba2d2b26f6a8).() );
152
153 return ret;
154 }
155
156 /// print absorption statistics
157 void PrintStatisticscxx . . $ TAxiomSet#PrintStatistics(83f5f38750778ac8). ( void ) const;
158 }; // TAxiomSet
159
160 #endif