Debian Codegraph @

Kernel/tAxiomSet.cpp

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 #include "tAxiomSet.h"cxx . . $ `<file>/Kernel/tAxiomSet.h`/
21
22 #include "logging.h"cxx . . $ `<file>/Kernel/logging.h`/
23 #include "dlTBox.h"cxx . . $ `<file>/Kernel/dlTBox.h`/
24
25 /// d'tor
26 TAxiomSetcxx . . $ TAxiomSet# :: ~cxx . . $ TAxiomSet#`~TAxiomSet`(49f6e7a06ebc5aa8).TAxiomSetcxx . . $ TAxiomSet#()
27 {
28 for ( auto& axiom: Accumcxx . . $ TAxiomSet#Accum. )
29 delete axiom;
30 }
31
32 bool
33 TAxiomSetcxx . . $ TAxiomSet# :: splitcxx . . $ TAxiomSet#split(3aa3f7904e349e06). ( const TAxiomcxx . . $ TAxiom#* p )
34 {
35 AxiomCollectioncxx . . $ TAxiomSet#AxiomCollection# Splittedcxx . . $ std/vector#vector(49f6e7a06ebc5aa8)., Keptcxx . . $ std/vector#vector(49f6e7a06ebc5aa8)., Unneededcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
36 if ( !p->splitcxx . . $ TAxiom#split(dd394394fea2dda9).(Splitted) ) // nothing to split
37 return false;
38
39 bool fail = false;
40 for ( auto& axiom: Splitted )
41 {
42 // axiom is a copy of a processed one: fail to do split
43 if ( axiom->isCycliccxx . . $ TAxiom#isCyclic(50ce9a9e25b4a850).() )
44 {
45 fail = true;
46 break;
47 }
48 // axiom is a copy of a new one: skip it
49 if ( copyOfExistingcxx . . $ TAxiomSet#copyOfExisting(9c8122c9b670e3df).(axiom) )
50 Unneeded.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(axiom);
51 else // new axiom: keep it
52 Kept.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(axiom);
53 }
54 // if fail to split: delete all the axioms
55 if ( fail )
56 {
57 for ( auto& axiom: Splitted )
58 delete axiom;
59 return false;
60 }
61 // no failure: delete all the unneeded axioms, add all kept ones
62 for ( auto& axiom: Unneeded )
63 delete axiom;
64 for ( auto& axiom: Kept )
65 insertGCIcxx . . $ TAxiomSet#insertGCI(534e8fc5d42bc54f).(axiom);
66 return true;
67 }
68
69 size_tcxx . . $ size_t# TAxiomSetcxx . . $ TAxiomSet# :: absorbcxx . . $ TAxiomSet#absorb(f708dce9a8856c70). ( void )
70 {
71 // absorbed- and unabsorbable GCIs
72 AxiomCollectioncxx . . $ TAxiomSet#AxiomCollection# Absorbedcxx . . $ std/vector#vector(49f6e7a06ebc5aa8)., GCIscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
73
74 // we will change Accum (via split rule), so indexing and compare with size
75 for ( size_tcxx . . $ size_t# curAxiom = 0; curAxiom < Accumcxx . . $ TAxiomSet#Accum..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); ++curAxiom )
76 {
77 # ifdef RKG_DEBUG_ABSORPTION
78 std::cout << "\nProcessing (" << curAxiom << "):";
79 # endif
80 TAxiomcxx . . $ TAxiom#* ax = Accumcxx . . $ TAxiomSet#Accum.[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).curAxiom];
81 if ( absorbGCIcxx . . $ TAxiomSet#absorbGCI(3aa3f7904e349e06).(ax) )
82 Absorbed.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(ax);
83 else
84 GCIs.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(ax);
85 }
86
87 // clear absorbed and remove them from Accum
88 for ( auto& axiom: Absorbed )
89 delete axiom;
90 Accumcxx . . $ TAxiomSet#Accum..swapcxx . . $ std/vector#swap(a8be04fc17cbdf49).(GCIs);
91
92 #ifdef RKG_DEBUG_ABSORPTION
93 std::cout << "\nAbsorption done with " << Accum.size() << " GCIs left\n";
94 #endif
95 PrintStatisticscxx . . $ TAxiomSet#PrintStatistics(83f5f38750778ac8).();
96 return sizecxx . . $ TAxiomSet#size(fe4d2d262d4164a8).();
97 }
98
99 bool TAxiomSetcxx . . $ TAxiomSet# :: absorbGCIcxx . . $ TAxiomSet#absorbGCI(3aa3f7904e349e06). ( const TAxiomcxx . . $ TAxiom#* p )
100 {
101 Statcxx . . $ Stat/::SAbsActioncxx . . $ Stat/SAbsAction#();
102
103 for ( const auto& action: ActionVectorcxx . . $ TAxiomSet#ActionVector. )
104 if ( (this->*action)(p) )
105 return true;
106
107 #ifdef RKG_DEBUG_ABSORPTION
108 std::cout << " keep as GCI";
109 #endif
110
111 return false;
112 }
113
114 bool TAxiomSetcxx . . $ TAxiomSet# :: initAbsorptionFlagscxx . . $ TAxiomSet#initAbsorptionFlags(7c222eea44a24d43). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& flags )
115 {
116 ActionVectorcxx . . $ TAxiomSet#ActionVector..clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).();
117 for ( const auto& ch: flags )
118 switch ( ch )
119 {
120 case 'B': ActionVectorcxx . . $ TAxiomSet#ActionVector..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(&TAxiomSetcxx . . $ TAxiomSet#::absorbIntoBottomcxx . . $ TAxiomSet#absorbIntoBottom(3aa3f7904e349e06).); break;
121 case 'T': ActionVectorcxx . . $ TAxiomSet#ActionVector..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(&TAxiomSetcxx . . $ TAxiomSet#::absorbIntoTopcxx . . $ TAxiomSet#absorbIntoTop(3aa3f7904e349e06).); break;
122 case 'E': ActionVectorcxx . . $ TAxiomSet#ActionVector..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(&TAxiomSetcxx . . $ TAxiomSet#::simplifyCNcxx . . $ TAxiomSet#simplifyCN(3aa3f7904e349e06).); break;
123 case 'C': ActionVectorcxx . . $ TAxiomSet#ActionVector..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(&TAxiomSetcxx . . $ TAxiomSet#::absorbIntoConceptcxx . . $ TAxiomSet#absorbIntoConcept(3aa3f7904e349e06).); break;
124 case 'N': ActionVectorcxx . . $ TAxiomSet#ActionVector..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(&TAxiomSetcxx . . $ TAxiomSet#::absorbIntoNegConceptcxx . . $ TAxiomSet#absorbIntoNegConcept(3aa3f7904e349e06).); break;
125 case 'f': ActionVectorcxx . . $ TAxiomSet#ActionVector..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(&TAxiomSetcxx . . $ TAxiomSet#::simplifySForallcxx . . $ TAxiomSet#simplifySForall(3aa3f7904e349e06).); break;
126 case 'F': ActionVectorcxx . . $ TAxiomSet#ActionVector..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(&TAxiomSetcxx . . $ TAxiomSet#::simplifyForallcxx . . $ TAxiomSet#simplifyForall(3aa3f7904e349e06).); break;
127 case 'R': ActionVectorcxx . . $ TAxiomSet#ActionVector..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(&TAxiomSetcxx . . $ TAxiomSet#::absorbIntoDomaincxx . . $ TAxiomSet#absorbIntoDomain(3aa3f7904e349e06).); break;
128 case 'S': ActionVectorcxx . . $ TAxiomSet#ActionVector..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(&TAxiomSetcxx . . $ TAxiomSet#::splitcxx . . $ TAxiomSet#split(3aa3f7904e349e06).); break;
129 default: return true;
130 }
131
132 if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llAlwayscxx . . $ llAlways.) )
133 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Init absorption order as " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). flags <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n";
134
135 return false;
136 }
137
138 void TAxiomSetcxx . . $ TAxiomSet# :: PrintStatisticscxx . . $ TAxiomSet#PrintStatistics(83f5f38750778ac8). ( void ) const
139 {
140 if ( Statcxx . . $ Stat/::SAbsActioncxx . . $ Stat/SAbsAction#::objects_createdcxx . . $ counter#objects_created. == 0 || !LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llAlwayscxx . . $ llAlways.) )
141 return;
142
143 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\nAbsorption dealt with "
144 <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Statcxx . . $ Stat/::SAbsInputcxx . . $ Stat/SAbsInput#::objects_createdcxx . . $ counter#objects_created. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " input axioms\nThere were made "
145 <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Statcxx . . $ Stat/::SAbsActioncxx . . $ Stat/SAbsAction#::objects_createdcxx . . $ counter#objects_created. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " absorption actions, of which:";
146 if ( Statcxx . . $ Stat/::SAbsRepCNcxx . . $ Stat/SAbsRepCN#::objects_createdcxx . . $ counter#objects_created. )
147 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n\t" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Statcxx . . $ Stat/::SAbsRepCNcxx . . $ Stat/SAbsRepCN#::objects_createdcxx . . $ counter#objects_created. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " concept name replacements";
148 if ( Statcxx . . $ Stat/::SAbsRepForallcxx . . $ Stat/SAbsRepForall#::objects_createdcxx . . $ counter#objects_created. )
149 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n\t" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Statcxx . . $ Stat/::SAbsRepForallcxx . . $ Stat/SAbsRepForall#::objects_createdcxx . . $ counter#objects_created. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " universals replacements";
150 if ( Statcxx . . $ Stat/::SAbsSplitcxx . . $ Stat/SAbsSplit#::objects_createdcxx . . $ counter#objects_created. )
151 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n\t" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Statcxx . . $ Stat/::SAbsSplitcxx . . $ Stat/SAbsSplit#::objects_createdcxx . . $ counter#objects_created. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " conjunction splits";
152 if ( Statcxx . . $ Stat/::SAbsBApplycxx . . $ Stat/SAbsBApply#::objects_createdcxx . . $ counter#objects_created. )
153 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n\t" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Statcxx . . $ Stat/::SAbsBApplycxx . . $ Stat/SAbsBApply#::objects_createdcxx . . $ counter#objects_created. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " BOTTOM absorptions";
154 if ( Statcxx . . $ Stat/::SAbsTApplycxx . . $ Stat/SAbsTApply#::objects_createdcxx . . $ counter#objects_created. )
155 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n\t" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Statcxx . . $ Stat/::SAbsTApplycxx . . $ Stat/SAbsTApply#::objects_createdcxx . . $ counter#objects_created. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " TOP absorptions";
156 if ( Statcxx . . $ Stat/::SAbsCApplycxx . . $ Stat/SAbsCApply#::objects_createdcxx . . $ counter#objects_created. )
157 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n\t" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Statcxx . . $ Stat/::SAbsCApplycxx . . $ Stat/SAbsCApply#::objects_createdcxx . . $ counter#objects_created. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " concept absorption with "
158 <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Statcxx . . $ Stat/::SAbsCAttemptcxx . . $ Stat/SAbsCAttempt#::objects_createdcxx . . $ counter#objects_created. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " possibilities";
159 if ( Statcxx . . $ Stat/::SAbsNApplycxx . . $ Stat/SAbsNApply#::objects_createdcxx . . $ counter#objects_created. )
160 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n\t" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Statcxx . . $ Stat/::SAbsNApplycxx . . $ Stat/SAbsNApply#::objects_createdcxx . . $ counter#objects_created. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " negated concept absorption with "
161 <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Statcxx . . $ Stat/::SAbsNAttemptcxx . . $ Stat/SAbsNAttempt#::objects_createdcxx . . $ counter#objects_created. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " possibilities";
162 if ( Statcxx . . $ Stat/::SAbsRApplycxx . . $ Stat/SAbsRApply#::objects_createdcxx . . $ counter#objects_created. )
163 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n\t" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Statcxx . . $ Stat/::SAbsRApplycxx . . $ Stat/SAbsRApply#::objects_createdcxx . . $ counter#objects_created. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " role domain absorption with "
164 <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Statcxx . . $ Stat/::SAbsRAttemptcxx . . $ Stat/SAbsRAttempt#::objects_createdcxx . . $ counter#objects_created. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " possibilities";
165 if ( !Accumcxx . . $ TAxiomSet#Accum..emptycxx . . $ std/vector#empty(50ce9a9e25b4a850).() )
166 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\nThere are " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). Accumcxx . . $ TAxiomSet#Accum..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " GCIs left";
167 }