Debian Codegraph @

Kernel/BuildDAG.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 // This file contains methods for creating DAG representation of KB
21
22 #include "dlTBox.h"cxx . . $ `<file>/Kernel/dlTBox.h`/
23
24 void TBoxcxx . . $ TBox# :: buildDAGcxx . . $ TBox#buildDAG(49f6e7a06ebc5aa8). ( void )
25 {
26 nNominalReferencescxx . . $ TBox#nNominalReferences. = 0;
27
28 // init concept indexing
29 nCcxx . . $ TBox#nC. = 1; // start with 1 to make index 0 an indicator of "not processed"
30 ConceptMapcxx . . $ TBox#ConceptMap..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(nullptr);
31
32 // make fresh concept and datatype
33 concept2dagcxx . . $ TBox#concept2dag(2f4043ddf2093eae).(pTempcxx . . $ TBox#pTemp.);
34 DLTreecxx . . $ DLTree#* freshDT = DTCentercxx . . $ TBox#DTCenter..getFreshDataTypecxx . . $ DataTypeCenter#getFreshDataType(7ba0ba2d2b26f6a8).();
35 addDataExprToHeapcxx . . $ TBox#addDataExprToHeap(7391a4cac9a59a30). ( static_cast<TDataEntrycxx . . $ TDataEntry#*>(freshDT->Elementcxx . . $ TsTTree#Element(19b2b6f17af048b).().getNEcxx . . $ TLexeme#getNE(28c03b9fd3c689f8).()) );
36 deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(freshDT);
37
38 for ( c_const_iteratorcxx . . $ TBox#c_const_iterator# pc = c_begincxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0).(); pc !=cxx . . $ __gnu_cxx/`operator!=`(9b2ee563b24e7156). c_endcxx . . $ TBox#c_end(23ec1c5bda99ac5d).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).pc )
39 concept2dagcxx . . $ TBox#concept2dag(2f4043ddf2093eae).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).pc);
40 for ( i_const_iteratorcxx . . $ TBox#i_const_iterator# pi = i_begincxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0).(); pi !=cxx . . $ __gnu_cxx/`operator!=`(9b2ee563b24e7156). i_endcxx . . $ TBox#i_end(78b5d4d1a9fb506d).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).pi )
41 concept2dagcxx . . $ TBox#concept2dag(2f4043ddf2093eae).(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).pi);
42
43 // init heads of simple rules
44 for ( TSimpleRulescxx . . $ TBox#TSimpleRules#::iteratorcxx . . $ std/vector#iterator# q = SimpleRulescxx . . $ TBox#SimpleRules..begincxx . . $ std/vector#begin(33b10a496a38335b).(), q_end = SimpleRulescxx . . $ TBox#SimpleRules..endcxx . . $ std/vector#end(33b10a496a38335b).(); q <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). q_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).q )
45 (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q)->bpHeadcxx . . $ TBox#TSimpleRule#bpHead. = tree2dagcxx . . $ TBox#tree2dag(9508c6a8f13d6e3b).((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q)->tHeadcxx . . $ TBox#TSimpleRule#tHead.);
46
47 // builds Roles range and domain
48 initRangeDomaincxx . . $ TBox#initRangeDomain(c1024d870f8578d8).(ORMcxx . . $ TBox#ORM.);
49 initRangeDomaincxx . . $ TBox#initRangeDomain(c1024d870f8578d8).(DRMcxx . . $ TBox#DRM.);
50
51 RoleMastercxx . . $ RoleMaster#::iteratorcxx . . $ RoleMaster#iterator# pcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(49f6e7a06ebc5aa8)., p_endcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(49f6e7a06ebc5aa8).;
52
53 // build all GCIs
54 DLTreecxx . . $ DLTree#* GCI = Axiomscxx . . $ TBox#Axioms..getGCIcxx . . $ TAxiomSet#getGCI(7ba0ba2d2b26f6a8).();
55
56 // add special domains to the GCIs
57 if ( likelycxx . . $ `Kernel/globaldef.h:28:10`!(useSpecialDomains) )
58 for ( p =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(632e63ee1b1acbca). ORMcxx . . $ TBox#ORM..begincxx . . $ RoleMaster#begin(f6b8bc1058fc1c99).(), p_end =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(632e63ee1b1acbca). ORMcxx . . $ TBox#ORM..endcxx . . $ RoleMaster#end(f6b8bc1058fc1c99).(); p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
59 if ( !(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->hasSpecialDomaincxx . . $ TRole#hasSpecialDomain(50ce9a9e25b4a850).() )
60 GCI = createSNFAndcxx . . $ createSNFAnd(f2877343b7b69ea7). ( GCI, clonecxx . . $ clone(ec41a33c52a5614b).((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->getTSpecialDomaincxx . . $ TRole#getTSpecialDomain(aa22cc08b69ae2ef).()) );
61
62 // take chains that lead to Bot role into account
63 if ( !ORMcxx . . $ TBox#ORM..getBotRolecxx . . $ RoleMaster#getBotRole(6cda9dc08d29302e).()->isSimplecxx . . $ TRole#isSimple(50ce9a9e25b4a850).() )
64 GCI = createSNFAndcxx . . $ createSNFAnd(f2877343b7b69ea7). ( GCI,
65 new DLTreecxx . . $ DLTree# ( TLexemecxx . . $ TLexeme#(FORALLcxx . . $ FORALL.), createRolecxx . . $ createRole(6ab896d6f1aa3781).(ORMcxx . . $ TBox#ORM..getBotRolecxx . . $ RoleMaster#getBotRole(6cda9dc08d29302e).()), createBottomcxx . . $ createBottom(aa22cc08b69ae2ef).() ) );
66
67 T_Gcxx . . $ TBox#T_G. = tree2dagcxx . . $ TBox#tree2dag(9508c6a8f13d6e3b).(GCI);
68 deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(GCI);
69
70 // mark GCI flags
71 GCIscxx . . $ TBox#GCIs..setGCIcxx . . $ TKBFlags#setGCI(b45ddcbc8423892c).(T_Gcxx . . $ TBox#T_G. != bpTOPcxx . . $ bpTOP.);
72 GCIscxx . . $ TBox#GCIs..setReflexivecxx . . $ TKBFlags#setReflexive(b45ddcbc8423892c).(ORMcxx . . $ TBox#ORM..hasReflexiveRolescxx . . $ RoleMaster#hasReflexiveRoles(50ce9a9e25b4a850).());
73
74 // builds functional labels for roles
75 for ( p =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(632e63ee1b1acbca). ORMcxx . . $ TBox#ORM..begincxx . . $ RoleMaster#begin(f6b8bc1058fc1c99).(), p_end =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(632e63ee1b1acbca). ORMcxx . . $ TBox#ORM..endcxx . . $ RoleMaster#end(f6b8bc1058fc1c99).(); p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
76 if ( !(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isTopFunccxx . . $ TRole#isTopFunc(50ce9a9e25b4a850).() )
77 (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->setFunctionalcxx . . $ TRole#setFunctional(d4f767463ce0a6b3). ( atmost2dagcxx . . $ TBox#atmost2dag(eddf04e77472431f). ( 1, *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p, bpTOPcxx . . $ bpTOP. ) );
78 for ( p =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(632e63ee1b1acbca). DRMcxx . . $ TBox#DRM..begincxx . . $ RoleMaster#begin(f6b8bc1058fc1c99).(), p_end =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(632e63ee1b1acbca). DRMcxx . . $ TBox#DRM..endcxx . . $ RoleMaster#end(f6b8bc1058fc1c99).(); p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p )
79 if ( !(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isTopFunccxx . . $ TRole#isTopFunc(50ce9a9e25b4a850).() )
80 (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->setFunctionalcxx . . $ TRole#setFunctional(d4f767463ce0a6b3). ( atmost2dagcxx . . $ TBox#atmost2dag(eddf04e77472431f). ( 1, *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p, bpTOPcxx . . $ bpTOP. ) );
81
82 // check the type of the ontology
83 if ( nNominalReferencescxx . . $ TBox#nNominalReferences. > 0 )
84 {
85 unsigned int nInd = (unsigned int) (i_endcxx . . $ TBox#i_end(78b5d4d1a9fb506d).() -cxx . . $ __gnu_cxx/operator-(a40477c209547c13). i_begincxx . . $ TBox#i_begin(78b5d4d1a9fb506d).());
86 if ( nInd > 100 && nNominalReferencescxx . . $ TBox#nNominalReferences. > nInd )
87 isLikeWINEcxx . . $ TBox#isLikeWINE. = true;
88 }
89
90 // here DAG is complete; set its final size
91 DLHeapcxx . . $ TBox#DLHeap..setFinalSizecxx . . $ DLDag#setFinalSize(49f6e7a06ebc5aa8).();
92 }
93
94 void TBoxcxx . . $ TBox# :: initRangeDomaincxx . . $ TBox#initRangeDomain(c1024d870f8578d8). ( RoleMastercxx . . $ RoleMaster#& RM )
95 {
96 for ( auto& R: RM )
97 if ( !R->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() )
98 {
99 // add R&D from super-roles (do it AFTER axioms are transformed into R&D)
100 if ( RKG_UPDATE_RND_FROM_SUPERROLEScxx . . $ `Kernel/globaldef.h:57:10`! )
101 R->collectDomainFromSuperscxx . . $ TRole#collectDomainFromSupers(49f6e7a06ebc5aa8).();
102
103 DLTreecxx . . $ DLTree#* dom = R->getTDomaincxx . . $ TRole#getTDomain(7ba0ba2d2b26f6a8).();
104 BipolarPointercxx . . $ BipolarPointer# bp = bpTOPcxx . . $ bpTOP.;
105 if ( dom )
106 {
107 bp = tree2dagcxx . . $ TBox#tree2dag(9508c6a8f13d6e3b).(dom);
108 GCIscxx . . $ TBox#GCIs..setRnDcxx . . $ TKBFlags#setRnD(49f6e7a06ebc5aa8).();
109 }
110
111 R->setBPDomaincxx . . $ TRole#setBPDomain(d4f767463ce0a6b3).(bp);
112
113 // special domain for R is AR.Range
114 R->initSpecialDomaincxx . . $ TRole#initSpecialDomain(49f6e7a06ebc5aa8).();
115 if ( R->hasSpecialDomaincxx . . $ TRole#hasSpecialDomain(50ce9a9e25b4a850).() )
116 R->setSpecialDomaincxx . . $ TRole#setSpecialDomain(d4f767463ce0a6b3).(tree2dagcxx . . $ TBox#tree2dag(9508c6a8f13d6e3b).(R->getTSpecialDomaincxx . . $ TRole#getTSpecialDomain(aa22cc08b69ae2ef).()));
117 }
118 }
119
120 /// register data expression in the DAG
121 BipolarPointercxx . . $ BipolarPointer# TBoxcxx . . $ TBox# :: addDataExprToHeapcxx . . $ TBox#addDataExprToHeap(7391a4cac9a59a30). ( TDataEntrycxx . . $ TDataEntry#* p )
122 {
123 if ( isValidcxx . . $ isValid(83c267b20bac841a).(p->getBPcxx . . $ TDataEntry#getBP(455f465bc33b4cdf).()) ) // already registered value
124 return p->getBPcxx . . $ TDataEntry#getBP(455f465bc33b4cdf).();
125
126 // determine the type of an entry
127 DagTagcxx . . $ DagTag# dt = p->isBasicDataTypecxx . . $ TDataEntry#isBasicDataType(50ce9a9e25b4a850).() ? dtDataTypecxx . . $ dtDataType. : p->isDataValuecxx . . $ TDataEntry#isDataValue(50ce9a9e25b4a850).() ? dtDataValuecxx . . $ dtDataValue. : dtDataExprcxx . . $ dtDataExpr.;
128 BipolarPointercxx . . $ BipolarPointer# hostBP = bpTOPcxx . . $ bpTOP.;
129
130 // register host type first (if any)
131 if ( p->getTypecxx . . $ TDataEntry#getType(bcfda270e2d2df96).() != nullptr )
132 hostBP = addDataExprToHeapcxx . . $ TBox#addDataExprToHeap(7391a4cac9a59a30).(const_cast<TDataEntrycxx . . $ TDataEntry#*>(p->getTypecxx . . $ TDataEntry#getType(bcfda270e2d2df96).()));
133
134 // create new DAG entry for the data value
135 DLVertexcxx . . $ DLVertex#* ver = new DLVertexcxx . . $ DLVertex# ( dt, hostBP );
136 ver->setConceptcxx . . $ DLVertex#setConcept(69d9f70ea506b4a4).(p);
137 p->setBPcxx . . $ TDataEntry#setBP(d4f767463ce0a6b3).(DLHeapcxx . . $ TBox#DLHeap..directAddcxx . . $ DLDag#directAdd(b86a49c684080b5d).(ver));
138
139 return p->getBPcxx . . $ TDataEntry#getBP(455f465bc33b4cdf).();
140 }
141
142 void TBoxcxx . . $ TBox# :: addConceptToHeapcxx . . $ TBox#addConceptToHeap(3f0281ca3ae282d4). ( TConceptcxx . . $ TConcept#* pConcept )
143 {
144 // choose proper tag by concept
145 DagTagcxx . . $ DagTag# tag = pConcept->isPrimitivecxx . . $ TConcept#isPrimitive(50ce9a9e25b4a850).() ?
146 (pConcept->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() ? dtPSingletoncxx . . $ dtPSingleton. : dtPConceptcxx . . $ dtPConcept.):
147 (pConcept->isSingletoncxx . . $ TConcept#isSingleton(50ce9a9e25b4a850).() ? dtNSingletoncxx . . $ dtNSingleton. : dtNConceptcxx . . $ dtNConcept.);
148
149 // NSingleton is a nominal
150 if ( tag == dtNSingletoncxx . . $ dtNSingleton. && !pConcept->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() )
151 static_cast<TIndividualcxx . . $ TIndividual#*>(pConcept)->setNominalcxx . . $ TConcept#setNominal(49f6e7a06ebc5aa8).();
152
153 // new concept's addition
154 DLVertexcxx . . $ DLVertex#* ver = new DLVertexcxx . . $ DLVertex#(tag);
155 ver->setConceptcxx . . $ DLVertex#setConcept(69d9f70ea506b4a4).(pConcept);
156 pConcept->pNamecxx . . $ TConcept#pName. = DLHeapcxx . . $ TBox#DLHeap..directAddcxx . . $ DLDag#directAdd(b86a49c684080b5d).(ver);
157
158 BipolarPointercxx . . $ BipolarPointer# desc = bpTOPcxx . . $ bpTOP.;
159
160 // translate body of a concept
161 if ( pConcept->Descriptioncxx . . $ TConcept#Description. != nullptr ) // complex concept
162 desc = tree2dagcxx . . $ TBox#tree2dag(9508c6a8f13d6e3b).(pConcept->Descriptioncxx . . $ TConcept#Description.);
163 else // only primitive concepts here
164 fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( pConcept->isPrimitive() );
165
166 // update concept's entry
167 pConcept->pBodycxx . . $ TConcept#pBody. = desc;
168 ver->setChildcxx . . $ DLVertex#setChild(d4f767463ce0a6b3).(desc);
169 if ( !pConcept->isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850).() && pConcept->indexcxx . . $ ClassifiableEntry#index(ddd8539a2fcdd4ce).() == 0 )
170 setConceptIndexcxx . . $ TBox#setConceptIndex(3f0281ca3ae282d4).(pConcept);
171 }
172
173 BipolarPointercxx . . $ BipolarPointer# TBoxcxx . . $ TBox# :: tree2dagcxx . . $ TBox#tree2dag(9508c6a8f13d6e3b). ( const DLTreecxx . . $ DLTree#* t )
174 {
175 if ( t == nullptr )
176 return bpINVALIDcxx . . $ bpINVALID.; // invalid value
177
178 const TLexemecxx . . $ TLexeme#& cur = t->Elementcxx . . $ TsTTree#Element(ea465e50d690edfe).();
179 BipolarPointercxx . . $ BipolarPointer# ret = bpINVALIDcxx . . $ bpINVALID.;
180
181 switch ( cur.getTokencxx . . $ TLexeme#getToken(d71a1020745f3953).() )
182 {
183 case BOTTOMcxx . . $ BOTTOM.: // it is just !top
184 ret = bpBOTTOMcxx . . $ bpBOTTOM.;
185 break;
186 case TOPcxx . . $ TOP.: // the 1st node
187 ret = bpTOPcxx . . $ bpTOP.;
188 break;
189 case DATAEXPRcxx . . $ DATAEXPR.: // data-related expression
190 ret = addDataExprToHeapcxx . . $ TBox#addDataExprToHeap(7391a4cac9a59a30). ( static_cast<TDataEntrycxx . . $ TDataEntry#*>(cur.getNEcxx . . $ TLexeme#getNE(28c03b9fd3c689f8).()) );
191 break;
192 case CNAMEcxx . . $ CNAME.: // concept name
193 ret = concept2dagcxx . . $ TBox#concept2dag(2f4043ddf2093eae).(toConceptcxx . . $ TBox#toConcept(45d7b14406cbd318).(cur.getNEcxx . . $ TLexeme#getNE(28c03b9fd3c689f8).()));
194 break;
195 case INAMEcxx . . $ INAME.: // individual name
196 {
197 ++nNominalReferencescxx . . $ TBox#nNominalReferences.; // definitely a nominal
198 TIndividualcxx . . $ TIndividual#* ind = toIndividualcxx . . $ TBox#toIndividual(1199bc9a67399c68).(cur.getNEcxx . . $ TLexeme#getNE(28c03b9fd3c689f8).());
199 ind->setNominalcxx . . $ TConcept#setNominal(49f6e7a06ebc5aa8).();
200 ret = concept2dagcxx . . $ TBox#concept2dag(2f4043ddf2093eae).(ind);
201 break;
202 }
203
204 case NOTcxx . . $ NOT.:
205 ret = inversecxx . . $ inverse(7864480464b09eea). ( tree2dagcxx . . $ TBox#tree2dag(9508c6a8f13d6e3b). ( t->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).() ) );
206 break;
207 case ANDcxx . . $ AND.:
208 ret = and2dagcxx . . $ TBox#and2dag(9508c6a8f13d6e3b).(t);
209 break;
210 case FORALLcxx . . $ FORALL.:
211 ret = forall2dagcxx . . $ TBox#forall2dag(53bf71045b2bebcc). ( resolveRolecxx . . $ resolveRole(c256d257f6e22050).(t->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).()), tree2dagcxx . . $ TBox#tree2dag(9508c6a8f13d6e3b).(t->Rightcxx . . $ TsTTree#Right(f4b2f47551fb31d7).()) );
212 break;
213 case SELFcxx . . $ SELF.:
214 ret = reflexive2dagcxx . . $ TBox#reflexive2dag(67a8b55b30a79916).(resolveRolecxx . . $ resolveRole(c256d257f6e22050).(t->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).()));
215 break;
216 case LEcxx . . $ LE.:
217 ret = atmost2dagcxx . . $ TBox#atmost2dag(eddf04e77472431f). ( cur.getDatacxx . . $ TLexeme#getData(ddd8539a2fcdd4ce).(), resolveRolecxx . . $ resolveRole(c256d257f6e22050).(t->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).()), tree2dagcxx . . $ TBox#tree2dag(9508c6a8f13d6e3b).(t->Rightcxx . . $ TsTTree#Right(f4b2f47551fb31d7).()) );
218 break;
219 case PROJFROMcxx . . $ PROJFROM.: // note: no PROJINTO as already unified
220 ret = DLHeapcxx . . $ TBox#DLHeap..directAddcxx . . $ DLDag#directAdd(b86a49c684080b5d). ( new DLVertexcxx . . $ DLVertex# ( resolveRolecxx . . $ resolveRole(c256d257f6e22050).(t->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).()), tree2dagcxx . . $ TBox#tree2dag(9508c6a8f13d6e3b).(t->Rightcxx . . $ TsTTree#Right(f4b2f47551fb31d7).()->Rightcxx . . $ TsTTree#Right(f4b2f47551fb31d7).()), resolveRolecxx . . $ resolveRole(c256d257f6e22050).(t->Rightcxx . . $ TsTTree#Right(f4b2f47551fb31d7).()->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).()) ) );
221 break;
222 default:
223 fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( isSNF(t) ); // safety check
224 fpp_unreachablecxx . . $ `Kernel/fpp_assert.h:49:9`!(); // extra safety check ;)
225 }
226
227 return ret;
228 }
229
230 /// fills AND-like vertex V with an AND-like expression T; process result
231 BipolarPointercxx . . $ BipolarPointer#
232 TBoxcxx . . $ TBox# :: and2dagcxx . . $ TBox#and2dag(9508c6a8f13d6e3b). ( const DLTreecxx . . $ DLTree#* t )
233 {
234 BipolarPointercxx . . $ BipolarPointer# ret = bpBOTTOMcxx . . $ bpBOTTOM.;
235 DLVertexcxx . . $ DLVertex#* v = new DLVertexcxx . . $ DLVertex#(dtAndcxx . . $ dtAnd.);
236
237 if ( fillANDVertexcxx . . $ TBox#fillANDVertex(764b05170664e007). ( v, t ) ) // clash found
238 delete v;
239 else // AND vertex
240 switch ( v->endcxx . . $ DLVertex#end(d2502ee2ca3b883a).() -cxx . . $ __gnu_cxx/operator-(a40477c209547c13). v->begincxx . . $ DLVertex#begin(d2502ee2ca3b883a).() )
241 {
242 case 0: // and(TOP) = TOP
243 delete v;
244 return bpTOPcxx . . $ bpTOP.;
245 case 1: // and(C) = C
246 ret = *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).v->begincxx . . $ DLVertex#begin(d2502ee2ca3b883a).();
247 delete v;
248 break;
249 default:
250 ret = DLHeapcxx . . $ TBox#DLHeap..addcxx . . $ DLDag#add(b86a49c684080b5d).(v);
251 break;
252 }
253
254 return ret;
255 }
256
257 BipolarPointercxx . . $ BipolarPointer# TBoxcxx . . $ TBox# :: forall2dagcxx . . $ TBox#forall2dag(53bf71045b2bebcc). ( const TRolecxx . . $ TRole#* R, BipolarPointercxx . . $ BipolarPointer# C )
258 {
259 if ( R->isDataRolecxx . . $ TRole#isDataRole(50ce9a9e25b4a850).() )
260 return dataForall2dagcxx . . $ TBox#dataForall2dag(53bf71045b2bebcc).(R,C);
261
262 // create \all R.C == \all R{0}.C
263 BipolarPointercxx . . $ BipolarPointer# ret = DLHeapcxx . . $ TBox#DLHeap..addcxx . . $ DLDag#add(b86a49c684080b5d). ( new DLVertexcxx . . $ DLVertex# ( dtForallcxx . . $ dtForall., 0, R, C ) );
264
265 if ( R->isSimplecxx . . $ TRole#isSimple(50ce9a9e25b4a850).() ) // don't care about the rest
266 return ret;
267
268 // check if the concept is not last
269 if ( !DLHeapcxx . . $ TBox#DLHeap..isLastcxx . . $ DLDag#isLast(4a668f6de69bf818).(ret) )
270 return ret; // all sub-roles were added before
271
272 // have appropriate concepts for all the automaton states
273 for ( unsigned int i = 1; i < R->getAutomatoncxx . . $ TRole#getAutomaton(63b0d77ccf579a4).().sizecxx . . $ RoleAutomaton#size(fe4d2d262d4164a8).(); ++i )
274 DLHeapcxx . . $ TBox#DLHeap..directAddAndCachecxx . . $ DLDag#directAddAndCache(b86a49c684080b5d). ( new DLVertexcxx . . $ DLVertex# ( dtForallcxx . . $ dtForall., i, R, C ) );
275
276 return ret;
277 }
278
279 BipolarPointercxx . . $ BipolarPointer# TBoxcxx . . $ TBox# :: atmost2dagcxx . . $ TBox#atmost2dag(eddf04e77472431f). ( unsigned int n, const TRolecxx . . $ TRole#* R, BipolarPointercxx . . $ BipolarPointer# C )
280 {
281 // input check: only simple roles are allowed in the (non-trivial) NR
282 if ( !R->isSimplecxx . . $ TRole#isSimple(50ce9a9e25b4a850).() )
283 throw EFPPNonSimpleRolecxx . . $ EFPPNonSimpleRole#(Rcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).->getNamecxx . . $ TNamedEntry#getName(a9f41ea0e82d88cf).());
284
285 if ( R->isDataRolecxx . . $ TRole#isDataRole(50ce9a9e25b4a850).() )
286 return dataAtMost2dagcxx . . $ TBox#dataAtMost2dag(eddf04e77472431f).(n,R,C);
287
288 if ( unlikelycxx . . $ `Kernel/globaldef.h:29:10`! ( C == bpBOTTOM ) ) // can happen as A & ~A
289 return bpTOPcxx . . $ bpTOP.;
290
291 BipolarPointercxx . . $ BipolarPointer# ret = DLHeapcxx . . $ TBox#DLHeap..addcxx . . $ DLDag#add(b86a49c684080b5d). ( new DLVertexcxx . . $ DLVertex# ( dtLEcxx . . $ dtLE., n, R, C ) );
292
293 // check if the concept is not last
294 if ( !DLHeapcxx . . $ TBox#DLHeap..isLastcxx . . $ DLDag#isLast(4a668f6de69bf818).(ret) )
295 return ret; // all elements were added before
296
297 // create entries for the transitive sub-roles
298 for ( unsigned int m = n-1; m > 0; --m )
299 DLHeapcxx . . $ TBox#DLHeap..directAddAndCachecxx . . $ DLDag#directAddAndCache(b86a49c684080b5d). ( new DLVertexcxx . . $ DLVertex# ( dtLEcxx . . $ dtLE., m, R, C ) );
300
301 // create a blocker for the NN-rule
302 DLHeapcxx . . $ TBox#DLHeap..directAddAndCachecxx . . $ DLDag#directAddAndCache(b86a49c684080b5d).(new DLVertexcxx . . $ DLVertex#(dtNNcxx . . $ dtNN.));
303
304 return ret;
305 }
306
307 bool TBoxcxx . . $ TBox# :: fillANDVertexcxx . . $ TBox#fillANDVertex(764b05170664e007). ( DLVertexcxx . . $ DLVertex#* v, const DLTreecxx . . $ DLTree#* t )
308 {
309 if ( t->Elementcxx . . $ TsTTree#Element(ea465e50d690edfe).().getTokencxx . . $ TLexeme#getToken(d71a1020745f3953).() == ANDcxx . . $ AND. )
310 return fillANDVertexcxx . . $ TBox#fillANDVertex(764b05170664e007). ( v, t->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).() ) || fillANDVertexcxx . . $ TBox#fillANDVertex(764b05170664e007). ( v, t->Rightcxx . . $ TsTTree#Right(f4b2f47551fb31d7).() );
311 else
312 return v->addChildcxx . . $ DLVertex#addChild(83c267b20bac841a). ( tree2dagcxx . . $ TBox#tree2dag(9508c6a8f13d6e3b).(t) );
313 }