| 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 "dlDag.h"cxx . . $ `<file>/Kernel/dlDag.h`/ |
| 21 | #include "dlCompletionGraph.h"cxx . . $ `<file>/Kernel/dlCompletionGraph.h`/ |
| 22 | #include "Reasoner.h"cxx . . $ `<file>/Kernel/Reasoner.h`/ |
| 23 | #include "logging.h"cxx . . $ `<file>/Kernel/logging.h`/ |
| 24 | |
| 25 | #ifdef USE_BLOCKING_STATISTICS |
| 26 | // statistic for calling blocking |
| 27 | unsigned long tries[6], fails[6], nSucc, failedRule; |
| 28 | |
| 29 | void printBlockingStat1 ( std::ostream& o ) |
| 30 | { |
| 31 | if ( *tries == 0 ) // nothing to inform |
| 32 | return; |
| 33 | |
| 34 | // else -- print precise statistics |
| 35 | o << "\nThere were made " << *tries << " blocking tests of which " |
| 36 | << nSucc << " successful.\nBlocking rules failure statistic:"; |
| 37 | for ( int i = 0; i < 6; ++i ) |
| 38 | { |
| 39 | if ( i != 0 ) |
| 40 | o << ","; |
| 41 | o << " " << fails[i] << "/" << tries[i]; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | void clearBlockingStat1 ( void ) |
| 46 | { |
| 47 | for ( int i = 5; i >= 0; --i ) |
| 48 | tries[i] = fails[i] = 0; |
| 49 | nSucc = failedRule = 0; |
| 50 | } |
| 51 | #endif |
| 52 | |
| 53 | // universal Blocked-By method |
| 54 | bool |
| 55 | DlCompletionGraphcxx . . $ DlCompletionGraph# :: isBlockedBycxx . . $ DlCompletionGraph#isBlockedBy(29f359e69572044c). ( const DlCompletionTreecxx . . $ DlCompletionTree#* node, const DlCompletionTreecxx . . $ DlCompletionTree#* blocker ) const |
| 56 | { |
| 57 | fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( !node->isNominalNode() ); |
| 58 | fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( !blocker->isNominalNode() ); |
| 59 | |
| 60 | // blocked node can't be blocked itself |
| 61 | if ( blocker->isBlockedcxx . . $ DlCompletionTree#isBlocked(50ce9a9e25b4a850).() ) |
| 62 | return false; |
| 63 | |
| 64 | // easy check: Init is not in the label if a blocker |
| 65 | if ( !blocker->canBlockInitcxx . . $ DlCompletionTree#canBlockInit(e2c3b6f64f9879b7).(node) ) |
| 66 | return false; |
| 67 | |
| 68 | bool ret; |
| 69 | if ( sessionHasInverseRolescxx . . $ DlCompletionGraph#sessionHasInverseRoles. ) // subset blocking |
| 70 | { |
| 71 | const DLDagcxx . . $ DLDag#& dag = pReasonercxx . . $ DlCompletionGraph#pReasoner.->getDAGcxx . . $ DlSatTester#getDAG(9e19445b34a9809a).(); |
| 72 | if ( sessionHasNumberRestrictionscxx . . $ DlCompletionGraph#sessionHasNumberRestrictions. ) // I+F -- optimised blocking |
| 73 | ret = node->isBlockedBy_SHIQcxx . . $ DlCompletionTree#isBlockedBy_SHIQ(f6b0d2269aa74b81). ( dag, blocker ); |
| 74 | else // just I -- equality blocking |
| 75 | ret = node->isBlockedBy_SHIcxx . . $ DlCompletionTree#isBlockedBy_SHI(f6b0d2269aa74b81). ( dag, blocker ); |
| 76 | } |
| 77 | else |
| 78 | ret = node->isBlockedBy_SHcxx . . $ DlCompletionTree#isBlockedBy_SH(e2c3b6f64f9879b7).(blocker); |
| 79 | |
| 80 | #ifdef USE_BLOCKING_STATISTICS |
| 81 | if ( ret ) |
| 82 | ++nSucc; |
| 83 | else |
| 84 | if ( LLM.isWritable(llGTA) ) |
| 85 | LL << " fb" << failedRule << "(" << node->getId() << "," << blocker->getId() << ")"; |
| 86 | #endif |
| 87 | |
| 88 | return ret; |
| 89 | } |
| 90 | |
| 91 | // Blocked-by implementation |
| 92 | |
| 93 | bool DlCompletionTreecxx . . $ DlCompletionTree# :: isCommonlyBlockedBycxx . . $ DlCompletionTree#isCommonlyBlockedBy(f6b0d2269aa74b81). ( const DLDagcxx . . $ DLDag#& dag, const DlCompletionTreecxx . . $ DlCompletionTree#* p ) const |
| 94 | { |
| 95 | // common B1: |
| 96 | if ( !B1cxx . . $ DlCompletionTree#B1(e2c3b6f64f9879b7).(p) ) |
| 97 | return false; |
| 98 | |
| 99 | for ( const_label_iteratorcxx . . $ DlCompletionTree#const_label_iterator# q = p->beginl_cccxx . . $ DlCompletionTree#beginl_cc(e55d760a93e9f197).(), q_end = p->endl_cccxx . . $ DlCompletionTree#endl_cc(e55d760a93e9f197).(); q <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). q_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).q ) |
| 100 | { |
| 101 | BipolarPointercxx . . $ BipolarPointer# bp = q->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).(); |
| 102 | const DLVertexcxx . . $ DLVertex#& v = dag[cxx . . $ DLDag#`operator[]`(5fe3b8e96045ba2c).bp]; |
| 103 | |
| 104 | if ( v.Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8).() == dtForallcxx . . $ dtForall. && isPositivecxx . . $ isPositive(83c267b20bac841a).(bp) ) |
| 105 | { // (all S C) \in L(w') |
| 106 | if ( !B2cxx . . $ DlCompletionTree#B2(7b1f20b7aec1dd78). ( v, bp ) ) |
| 107 | return false; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | return true; |
| 112 | } |
| 113 | |
| 114 | bool DlCompletionTreecxx . . $ DlCompletionTree# :: isABlockedBycxx . . $ DlCompletionTree#isABlockedBy(f6b0d2269aa74b81). ( const DLDagcxx . . $ DLDag#& dag, const DlCompletionTreecxx . . $ DlCompletionTree#* p ) const |
| 115 | { |
| 116 | // current = w; p = w'; parent = v |
| 117 | #ifdef ENABLE_CHECKING |
| 118 | fpp_assert ( hasParent() ); // there exists v |
| 119 | #endif |
| 120 | |
| 121 | // B3,B4 |
| 122 | for ( const_label_iteratorcxx . . $ DlCompletionTree#const_label_iterator# q = p->beginl_cccxx . . $ DlCompletionTree#beginl_cc(e55d760a93e9f197).(), q_end = p->endl_cccxx . . $ DlCompletionTree#endl_cc(e55d760a93e9f197).(); q <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). q_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).q ) |
| 123 | { |
| 124 | BipolarPointercxx . . $ BipolarPointer# bp = q->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).(); |
| 125 | const DLVertexcxx . . $ DLVertex#& v = dag[cxx . . $ DLDag#`operator[]`(5fe3b8e96045ba2c).bp]; |
| 126 | |
| 127 | if ( v.Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8).() == dtForallcxx . . $ dtForall. && isNegativecxx . . $ isNegative(83c267b20bac841a).(bp) ) |
| 128 | { // (some T E) \in L(w') |
| 129 | if ( !B4cxx . . $ DlCompletionTree#B4(443f159c0c2bf13b). ( p, 1, v.getRolecxx . . $ DLVertex#getRole(69f26110a94b259f).(), inversecxx . . $ inverse(7864480464b09eea).(v.getCcxx . . $ DLVertex#getC(455f465bc33b4cdf).()) ) ) |
| 130 | return false; |
| 131 | } |
| 132 | else if ( v.Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8).() == dtLEcxx . . $ dtLE. ) |
| 133 | { |
| 134 | if ( isPositivecxx . . $ isPositive(83c267b20bac841a).(bp) ) |
| 135 | { // (<= n S C) \in L(w') |
| 136 | if ( !B3cxx . . $ DlCompletionTree#B3(443f159c0c2bf13b). ( p, v.getNumberLEcxx . . $ DLVertex#getNumberLE(ddd8539a2fcdd4ce).(), v.getRolecxx . . $ DLVertex#getRole(69f26110a94b259f).(), v.getCcxx . . $ DLVertex#getC(455f465bc33b4cdf).() ) ) |
| 137 | return false; |
| 138 | } |
| 139 | else |
| 140 | { // (>= m T E) \in L(w') |
| 141 | if ( !B4cxx . . $ DlCompletionTree#B4(443f159c0c2bf13b). ( p, v.getNumberGEcxx . . $ DLVertex#getNumberGE(ddd8539a2fcdd4ce).(), v.getRolecxx . . $ DLVertex#getRole(69f26110a94b259f).(), v.getCcxx . . $ DLVertex#getC(455f465bc33b4cdf).() ) ) |
| 142 | return false; |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | // all other is OK -- done; |
| 148 | return true; |
| 149 | } |
| 150 | |
| 151 | bool DlCompletionTreecxx . . $ DlCompletionTree# :: isCBlockedBycxx . . $ DlCompletionTree#isCBlockedBy(f6b0d2269aa74b81). ( const DLDagcxx . . $ DLDag#& dag, const DlCompletionTreecxx . . $ DlCompletionTree#* p ) const |
| 152 | { |
| 153 | // current = w; p = w'; parent = v |
| 154 | #ifdef ENABLE_CHECKING |
| 155 | fpp_assert ( hasParent() ); // there exists v |
| 156 | #endif |
| 157 | |
| 158 | // B5 |
| 159 | const_label_iteratorcxx . . $ DlCompletionTree#const_label_iterator# qcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(49f6e7a06ebc5aa8)., q_endcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(49f6e7a06ebc5aa8).; |
| 160 | for ( q =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(8a166801ba8fe87b). p->beginl_cccxx . . $ DlCompletionTree#beginl_cc(e55d760a93e9f197).(), q_end =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(8a166801ba8fe87b). p->endl_cccxx . . $ DlCompletionTree#endl_cc(e55d760a93e9f197).(); q <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). q_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).q ) |
| 161 | { |
| 162 | BipolarPointercxx . . $ BipolarPointer# bp = q->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).(); |
| 163 | const DLVertexcxx . . $ DLVertex#& v = dag[cxx . . $ DLDag#`operator[]`(5fe3b8e96045ba2c).bp]; |
| 164 | |
| 165 | if ( v.Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8).() == dtLEcxx . . $ dtLE. && isPositivecxx . . $ isPositive(83c267b20bac841a).(bp) ) |
| 166 | { // (<= n T E) \in L(w') |
| 167 | if ( !B5cxx . . $ DlCompletionTree#B5(e3f7d912c5a8ce7d). ( v.getRolecxx . . $ DLVertex#getRole(69f26110a94b259f).(), v.getCcxx . . $ DLVertex#getC(455f465bc33b4cdf).() ) ) |
| 168 | return false; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | // B6 |
| 173 | const DlCompletionTreecxx . . $ DlCompletionTree#* par = getParentNodecxx . . $ DlCompletionTree#getParentNode(19e040716207bced).(); |
| 174 | for ( q =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(8a166801ba8fe87b). par->beginl_cccxx . . $ DlCompletionTree#beginl_cc(e55d760a93e9f197).(), q_end =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(8a166801ba8fe87b). par->endl_cccxx . . $ DlCompletionTree#endl_cc(e55d760a93e9f197).(); q <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). q_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).q ) |
| 175 | { |
| 176 | BipolarPointercxx . . $ BipolarPointer# bp = q->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).(); |
| 177 | const DLVertexcxx . . $ DLVertex#& v = dag[cxx . . $ DLDag#`operator[]`(5fe3b8e96045ba2c).bp]; |
| 178 | |
| 179 | if ( v.Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8).() == dtLEcxx . . $ dtLE. && isNegativecxx . . $ isNegative(83c267b20bac841a).(bp) ) |
| 180 | { // (>= m U F) \in L(v) |
| 181 | if ( !B6cxx . . $ DlCompletionTree#B6(e3f7d912c5a8ce7d). ( v.getRolecxx . . $ DLVertex#getRole(69f26110a94b259f).(), v.getCcxx . . $ DLVertex#getC(455f465bc33b4cdf).() ) ) |
| 182 | return false; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | return true; |
| 187 | } |
| 188 | |
| 189 | //---------------------------------------------------------------------- |
| 190 | //-- B1 to B6 conditions implementation |
| 191 | //-- WARNING!! 19-06-2005. All blockable nodes has the only parent |
| 192 | //-- (with probably several links to it). So we should check all of them |
| 193 | //---------------------------------------------------------------------- |
| 194 | |
| 195 | #ifdef USE_BLOCKING_STATISTICS |
| 196 | # define TRY_B(i) ++tries[i-1] |
| 197 | # define FAIL_B(i) failedRule = i, ++fails[i-1] |
| 198 | #else |
| 199 | # define TRY_Bcxx . . $ `Kernel/Blocking.cpp:199:10`!(i) (void)NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`! |
| 200 | # define FAIL_Bcxx . . $ `Kernel/Blocking.cpp:200:10`!(i) (void)NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`! |
| 201 | #endif |
| 202 | |
| 203 | /// check if B1 holds for a given vertex (p is a candidate for blocker) |
| 204 | bool DlCompletionTreecxx . . $ DlCompletionTree# :: B1cxx . . $ DlCompletionTree#B1(e2c3b6f64f9879b7). ( const DlCompletionTreecxx . . $ DlCompletionTree#* p ) const |
| 205 | { |
| 206 | TRY_Bcxx . . $ `Kernel/Blocking.cpp:199:10`!(1); |
| 207 | |
| 208 | if ( Labelcxx . . $ DlCompletionTree#Label. <=cxx . . $ CGLabel#`operator<=`(210e00e1c3e71bb8). p->Labelcxx . . $ DlCompletionTree#Label. ) |
| 209 | return true; |
| 210 | |
| 211 | FAIL_Bcxx . . $ `Kernel/Blocking.cpp:200:10`!(1); |
| 212 | return false; |
| 213 | } |
| 214 | |
| 215 | bool |
| 216 | DlCompletionTreecxx . . $ DlCompletionTree# :: B2Simplecxx . . $ DlCompletionTree#B2Simple(f5432516a9e7ed0a). ( const RAStateTransitionscxx . . $ RAStateTransitions#& RST, BipolarPointercxx . . $ BipolarPointer# C ) const |
| 217 | { |
| 218 | const DlCompletionTreecxx . . $ DlCompletionTree#* parent = getParentNodecxx . . $ DlCompletionTree#getParentNode(19e040716207bced).(); |
| 219 | const CGLabelcxx . . $ CGLabel#& parLab = parent->labelcxx . . $ DlCompletionTree#label(fdeef9563491d77a).(); |
| 220 | TRY_Bcxx . . $ `Kernel/Blocking.cpp:199:10`!(2); |
| 221 | |
| 222 | for ( const_edge_iteratorcxx . . $ DlCompletionTree#const_edge_iterator# p = begincxx . . $ DlCompletionTree#begin(d3473f034184ffc9).(), p_end = endcxx . . $ DlCompletionTree#end(d3473f034184ffc9).(); p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 223 | if ( !(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isIBlockedcxx . . $ DlCompletionTreeArc#isIBlocked(50ce9a9e25b4a850).() && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->getArcEndcxx . . $ DlCompletionTreeArc#getArcEnd(1b0634bb62d2788b).() == parent && RST.recognisecxx . . $ RAStateTransitions#recognise(81d69a9c8508a392).((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->getRolecxx . . $ DlCompletionTreeArc#getRole(69f26110a94b259f).()) ) |
| 224 | { |
| 225 | if ( !parLab.containscxx . . $ CGLabel#contains(4a668f6de69bf818).(C) ) |
| 226 | { |
| 227 | FAIL_Bcxx . . $ `Kernel/Blocking.cpp:200:10`!(2); |
| 228 | return false; |
| 229 | } |
| 230 | else |
| 231 | return true; |
| 232 | } |
| 233 | |
| 234 | return true; |
| 235 | } |
| 236 | |
| 237 | bool |
| 238 | DlCompletionTreecxx . . $ DlCompletionTree# :: B2Complexcxx . . $ DlCompletionTree#B2Complex(f5432516a9e7ed0a). ( const RAStateTransitionscxx . . $ RAStateTransitions#& RST, BipolarPointercxx . . $ BipolarPointer# C ) const |
| 239 | { |
| 240 | const DlCompletionTreecxx . . $ DlCompletionTree#* parent = getParentNodecxx . . $ DlCompletionTree#getParentNode(19e040716207bced).(); |
| 241 | const CGLabelcxx . . $ CGLabel#& parLab = parent->labelcxx . . $ DlCompletionTree#label(fdeef9563491d77a).(); |
| 242 | TRY_Bcxx . . $ `Kernel/Blocking.cpp:199:10`!(2); |
| 243 | |
| 244 | for ( const_edge_iteratorcxx . . $ DlCompletionTree#const_edge_iterator# p = begincxx . . $ DlCompletionTree#begin(d3473f034184ffc9).(), p_end = endcxx . . $ DlCompletionTree#end(d3473f034184ffc9).(); p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 245 | { |
| 246 | if ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->isIBlockedcxx . . $ DlCompletionTreeArc#isIBlocked(50ce9a9e25b4a850).() || (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->getArcEndcxx . . $ DlCompletionTreeArc#getArcEnd(1b0634bb62d2788b).() != parent ) |
| 247 | continue; |
| 248 | const TRolecxx . . $ TRole#* R = (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->getRolecxx . . $ DlCompletionTreeArc#getRole(69f26110a94b259f).(); |
| 249 | if ( !RST.recognisecxx . . $ RAStateTransitions#recognise(81d69a9c8508a392).(R) ) |
| 250 | continue; |
| 251 | |
| 252 | for ( const auto& trans: RST ) |
| 253 | if ( trans.applicablecxx . . $ RATransition#applicable(81d69a9c8508a392).(R) ) |
| 254 | { |
| 255 | BipolarPointercxx . . $ BipolarPointer# bpFinal = C + (BipolarPointercxx . . $ BipolarPointer#) trans.finalcxx . . $ RATransition#final(ddd8539a2fcdd4ce).(); |
| 256 | if ( !parLab.containsCCcxx . . $ CGLabel#containsCC(4a668f6de69bf818).(bpFinal) ) |
| 257 | { |
| 258 | FAIL_Bcxx . . $ `Kernel/Blocking.cpp:200:10`!(2); |
| 259 | return false; |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | return true; |
| 265 | } |
| 266 | |
| 267 | /// check if B3 holds for (<= n S.C)\in w' (p is a candidate for blocker) |
| 268 | bool DlCompletionTreecxx . . $ DlCompletionTree# :: B3cxx . . $ DlCompletionTree#B3(443f159c0c2bf13b). ( const DlCompletionTreecxx . . $ DlCompletionTree#* p, unsigned int n, const TRolecxx . . $ TRole#* S, BipolarPointercxx . . $ BipolarPointer# C ) const |
| 269 | { |
| 270 | #ifdef ENABLE_CHECKING |
| 271 | fpp_assert ( hasParent() ); // safety check |
| 272 | #endif |
| 273 | TRY_Bcxx . . $ `Kernel/Blocking.cpp:199:10`!(3); |
| 274 | |
| 275 | bool ret; |
| 276 | // if (<= n S C) \in L(w') then |
| 277 | // a) w is an inv(S)-succ of v or |
| 278 | if ( !isParentArcLabelledcxx . . $ DlCompletionTree#isParentArcLabelled(81d69a9c8508a392).(S) ) |
| 279 | ret = true; |
| 280 | // b) w is an inv(S) succ of v and ~C\in L(v) or |
| 281 | else if ( getParentNodecxx . . $ DlCompletionTree#getParentNode(19e040716207bced).()->isLabelledBycxx . . $ DlCompletionTree#isLabelledBy(4a668f6de69bf818).(inversecxx . . $ inverse(7864480464b09eea).(C)) ) |
| 282 | ret = true; |
| 283 | // c) w is an inv(S) succ of v and C\in L(v)... |
| 284 | else if ( !getParentNodecxx . . $ DlCompletionTree#getParentNode(19e040716207bced).()->isLabelledBycxx . . $ DlCompletionTree#isLabelledBy(4a668f6de69bf818).(C) ) |
| 285 | ret = false; |
| 286 | else |
| 287 | { // ...and <=n-1 S-succ. z with C\in L(z) |
| 288 | unsigned int m = 0; |
| 289 | for ( const_edge_iteratorcxx . . $ DlCompletionTree#const_edge_iterator# q = p->begincxx . . $ DlCompletionTree#begin(d3473f034184ffc9).(), q_end = p->endcxx . . $ DlCompletionTree#end(d3473f034184ffc9).(); q <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). q_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).q ) |
| 290 | if ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q)->isSuccEdgecxx . . $ DlCompletionTreeArc#isSuccEdge(50ce9a9e25b4a850).() && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q)->isNeighbourcxx . . $ DlCompletionTreeArc#isNeighbour(81d69a9c8508a392).(S) && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q)->getArcEndcxx . . $ DlCompletionTreeArc#getArcEnd(1b0634bb62d2788b).()->isLabelledBycxx . . $ DlCompletionTree#isLabelledBy(4a668f6de69bf818).(C) ) |
| 291 | ++m; |
| 292 | |
| 293 | ret = ( m < n ); |
| 294 | } |
| 295 | |
| 296 | if ( !ret ) |
| 297 | FAIL_Bcxx . . $ `Kernel/Blocking.cpp:200:10`!(3); |
| 298 | |
| 299 | return ret; |
| 300 | } |
| 301 | |
| 302 | /// check if B4 holds for (>= m T.E)\in w' (p is a candidate for blocker) |
| 303 | bool DlCompletionTreecxx . . $ DlCompletionTree# :: B4cxx . . $ DlCompletionTree#B4(443f159c0c2bf13b). ( const DlCompletionTreecxx . . $ DlCompletionTree#* p, unsigned int m, const TRolecxx . . $ TRole#* T, BipolarPointercxx . . $ BipolarPointer# E ) const |
| 304 | { |
| 305 | #ifdef ENABLE_CHECKING |
| 306 | fpp_assert ( hasParent() ); // safety check |
| 307 | #endif |
| 308 | TRY_Bcxx . . $ `Kernel/Blocking.cpp:199:10`!(4); |
| 309 | |
| 310 | // if (>= m T E) \in L(w') then |
| 311 | // b) w is an inv(T) succ of v and E\in L(v) and m == 1 or |
| 312 | if ( isParentArcLabelledcxx . . $ DlCompletionTree#isParentArcLabelled(81d69a9c8508a392).(T) && m == 1 && getParentNodecxx . . $ DlCompletionTree#getParentNode(19e040716207bced).()->isLabelledBycxx . . $ DlCompletionTree#isLabelledBy(4a668f6de69bf818).(E) ) |
| 313 | return true; |
| 314 | |
| 315 | // a) w' has at least m T-succ z with E\in L(z) |
| 316 | // check all sons |
| 317 | unsigned int n = 0; |
| 318 | for ( const_edge_iteratorcxx . . $ DlCompletionTree#const_edge_iterator# q = p->begincxx . . $ DlCompletionTree#begin(d3473f034184ffc9).(), q_end = p->endcxx . . $ DlCompletionTree#end(d3473f034184ffc9).(); q <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). q_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).q ) |
| 319 | if ( (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q)->isSuccEdgecxx . . $ DlCompletionTreeArc#isSuccEdge(50ce9a9e25b4a850).() && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q)->isNeighbourcxx . . $ DlCompletionTreeArc#isNeighbour(81d69a9c8508a392).(T) && (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q)->getArcEndcxx . . $ DlCompletionTreeArc#getArcEnd(1b0634bb62d2788b).()->isLabelledBycxx . . $ DlCompletionTree#isLabelledBy(4a668f6de69bf818).(E) ) |
| 320 | if ( ++n >= m ) // check if node has enough successors |
| 321 | return true; |
| 322 | |
| 323 | // rule check fails |
| 324 | FAIL_Bcxx . . $ `Kernel/Blocking.cpp:200:10`!(4); |
| 325 | return false; |
| 326 | } |
| 327 | |
| 328 | /// check if B5 holds for (<= n T.E)\in w' |
| 329 | bool DlCompletionTreecxx . . $ DlCompletionTree# :: B5cxx . . $ DlCompletionTree#B5(e3f7d912c5a8ce7d). ( const TRolecxx . . $ TRole#* T, BipolarPointercxx . . $ BipolarPointer# E ) const |
| 330 | { |
| 331 | #ifdef ENABLE_CHECKING |
| 332 | fpp_assert ( hasParent() ); // safety check |
| 333 | #endif |
| 334 | TRY_Bcxx . . $ `Kernel/Blocking.cpp:199:10`!(5); |
| 335 | |
| 336 | // if (<= n T E) \in L(w'), then |
| 337 | // either w is not an inv(T)-successor of v... |
| 338 | if ( !isParentArcLabelledcxx . . $ DlCompletionTree#isParentArcLabelled(81d69a9c8508a392).(T) ) |
| 339 | return true; |
| 340 | // or ~E \in L(v) |
| 341 | if ( getParentNodecxx . . $ DlCompletionTree#getParentNode(19e040716207bced).()->isLabelledBycxx . . $ DlCompletionTree#isLabelledBy(4a668f6de69bf818). ( inversecxx . . $ inverse(7864480464b09eea).(E) ) ) |
| 342 | return true; |
| 343 | |
| 344 | FAIL_Bcxx . . $ `Kernel/Blocking.cpp:200:10`!(5); |
| 345 | return false; |
| 346 | } |
| 347 | |
| 348 | /// check if B6 holds for (>= m U.F)\in v |
| 349 | bool DlCompletionTreecxx . . $ DlCompletionTree# :: B6cxx . . $ DlCompletionTree#B6(e3f7d912c5a8ce7d). ( const TRolecxx . . $ TRole#* U, BipolarPointercxx . . $ BipolarPointer# F ) const |
| 350 | { |
| 351 | #ifdef ENABLE_CHECKING |
| 352 | fpp_assert ( hasParent() ); // safety check |
| 353 | #endif |
| 354 | TRY_Bcxx . . $ `Kernel/Blocking.cpp:199:10`!(6); |
| 355 | |
| 356 | // if (>= m U F) \in L(v), and |
| 357 | // w is U-successor of v... |
| 358 | if ( !isParentArcLabelledcxx . . $ DlCompletionTree#isParentArcLabelled(81d69a9c8508a392).(U->inversecxx . . $ TRole#inverse(69f26110a94b259f).()) ) |
| 359 | return true; |
| 360 | // then ~F\in L(w) |
| 361 | if ( isLabelledBycxx . . $ DlCompletionTree#isLabelledBy(4a668f6de69bf818). ( inversecxx . . $ inverse(7864480464b09eea).(F) ) ) |
| 362 | return true; |
| 363 | |
| 364 | FAIL_Bcxx . . $ `Kernel/Blocking.cpp:200:10`!(6); |
| 365 | return false; |
| 366 | } |
| 367 | |
| 368 | #undef TRY_Bcxx . . $ `Kernel/Blocking.cpp:199:10`! |
| 369 | #undef FAIL_Bcxx . . $ `Kernel/Blocking.cpp:200:10`! |
| 370 | |
| 371 | //---------------------------------------------------------------------- |
| 372 | //-- changing blocked status |
| 373 | //---------------------------------------------------------------------- |
| 374 | |
| 375 | void DlCompletionGraphcxx . . $ DlCompletionGraph# :: detectBlockedStatuscxx . . $ DlCompletionGraph#detectBlockedStatus(3bf754c9a531d7e6). ( DlCompletionTreecxx . . $ DlCompletionTree#* node ) |
| 376 | { |
| 377 | DlCompletionTreecxx . . $ DlCompletionTree#* p = node; |
| 378 | bool wasBlocked = node->isBlockedcxx . . $ DlCompletionTree#isBlocked(50ce9a9e25b4a850).(); |
| 379 | bool wasDBlocked = node->isDBlockedcxx . . $ DlCompletionTree#isDBlocked(50ce9a9e25b4a850).(); |
| 380 | |
| 381 | // if we are here, then node *need* to be checked |
| 382 | // so this is to prevent from going out of the loop |
| 383 | node->setAffectedcxx . . $ DlCompletionTree#setAffected(49f6e7a06ebc5aa8).(); |
| 384 | |
| 385 | while ( p->hasParentcxx . . $ DlCompletionTree#hasParent(50ce9a9e25b4a850).() && p->isBlockableNodecxx . . $ DlCompletionTree#isBlockableNode(50ce9a9e25b4a850).() && p->isAffectedcxx . . $ DlCompletionTree#isAffected(50ce9a9e25b4a850).() ) |
| 386 | { |
| 387 | findDBlockercxx . . $ DlCompletionGraph#findDBlocker(3bf754c9a531d7e6).(p); |
| 388 | if ( p->isBlockedcxx . . $ DlCompletionTree#isBlocked(50ce9a9e25b4a850).() ) |
| 389 | return; |
| 390 | p = p->getParentNodecxx . . $ DlCompletionTree#getParentNode(8f504d760f19febe).(); |
| 391 | } |
| 392 | p->clearAffectedcxx . . $ DlCompletionTree#clearAffected(49f6e7a06ebc5aa8).(); |
| 393 | if ( wasBlocked && !node->isBlockedcxx . . $ DlCompletionTree#isBlocked(50ce9a9e25b4a850).() ) |
| 394 | unblockNodecxx . . $ DlCompletionGraph#unblockNode(b0d9ee120534554a). ( node, wasDBlocked ); |
| 395 | } |
| 396 | |
| 397 | void DlCompletionGraphcxx . . $ DlCompletionGraph# :: unblockNodecxx . . $ DlCompletionGraph#unblockNode(b0d9ee120534554a). ( DlCompletionTreecxx . . $ DlCompletionTree#* node, bool wasDBlocked ) |
| 398 | { |
| 399 | if ( node->isPBlockedcxx . . $ DlCompletionTree#isPBlocked(50ce9a9e25b4a850).() || !node->isBlockableNodecxx . . $ DlCompletionTree#isBlockableNode(50ce9a9e25b4a850).() ) |
| 400 | return; |
| 401 | if ( !wasDBlocked ) // if it was DBlocked -- findDBlocker() made it |
| 402 | saveRareCondcxx . . $ DlCompletionGraph#saveRareCond(1cbbef85a2ba1293).(node->setUBlockedcxx . . $ DlCompletionTree#setUBlocked(85c56efe7ce37b0e).()); |
| 403 | pReasonercxx . . $ DlCompletionGraph#pReasoner.->repeatUnblockedNodecxx . . $ DlSatTester#repeatUnblockedNode(b0d9ee120534554a).(node,wasDBlocked); |
| 404 | unblockNodeChildrencxx . . $ DlCompletionGraph#unblockNodeChildren(3bf754c9a531d7e6).(node); |
| 405 | } |
| 406 | |
| 407 | void DlCompletionGraphcxx . . $ DlCompletionGraph# :: findDAncestorBlockercxx . . $ DlCompletionGraph#findDAncestorBlocker(3bf754c9a531d7e6). ( DlCompletionTreecxx . . $ DlCompletionTree#* node ) |
| 408 | { |
| 409 | const DlCompletionTreecxx . . $ DlCompletionTree#* p = node; |
| 410 | |
| 411 | if ( RKG_USE_FAIRNESScxx . . $ `Kernel/globaldef.h:65:10`! && nSkipBeforeBlockcxx . . $ DlCompletionGraph#nSkipBeforeBlock. ) |
| 412 | for ( int n = nSkipBeforeBlockcxx . . $ DlCompletionGraph#nSkipBeforeBlock.-1; n >= 0 && p->hasParentcxx . . $ DlCompletionTree#hasParent(50ce9a9e25b4a850).() && p->isBlockableNodecxx . . $ DlCompletionTree#isBlockableNode(50ce9a9e25b4a850).(); --n ) |
| 413 | p = p->getParentNodecxx . . $ DlCompletionTree#getParentNode(19e040716207bced).(); |
| 414 | |
| 415 | while ( p->hasParentcxx . . $ DlCompletionTree#hasParent(50ce9a9e25b4a850).() ) |
| 416 | { |
| 417 | p = p->getParentNodecxx . . $ DlCompletionTree#getParentNode(19e040716207bced).(); |
| 418 | |
| 419 | if ( !p->isBlockableNodecxx . . $ DlCompletionTree#isBlockableNode(50ce9a9e25b4a850).() ) |
| 420 | return; |
| 421 | |
| 422 | if ( isBlockedBycxx . . $ DlCompletionGraph#isBlockedBy(29f359e69572044c). ( node, p ) ) |
| 423 | { |
| 424 | setNodeDBlockedcxx . . $ DlCompletionGraph#setNodeDBlocked(616fb35effd4bdc7). ( node, p ); |
| 425 | return; |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | void DlCompletionGraphcxx . . $ DlCompletionGraph# :: findDAnywhereBlockercxx . . $ DlCompletionGraph#findDAnywhereBlocker(3bf754c9a531d7e6). ( DlCompletionTreecxx . . $ DlCompletionTree#* node ) |
| 431 | { |
| 432 | for ( const_iteratorcxx . . $ DlCompletionGraph#const_iterator# q = begincxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0).(), q_end = endcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0).(); q <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). q_end && *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q != node; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).q ) |
| 433 | { |
| 434 | const DlCompletionTreecxx . . $ DlCompletionTree#* p = *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).q; |
| 435 | |
| 436 | // node was merge to the one with the larger ID or is cached or blocked itself |
| 437 | if ( p->isBlockedcxx . . $ DlCompletionTree#isBlocked(50ce9a9e25b4a850).() || p->isPBlockedcxx . . $ DlCompletionTree#isPBlocked(50ce9a9e25b4a850).() || p->isNominalNodecxx . . $ DlCompletionTree#isNominalNode(50ce9a9e25b4a850).() || p->isCachedcxx . . $ DlCompletionTree#isCached(50ce9a9e25b4a850).() ) |
| 438 | continue; |
| 439 | |
| 440 | if ( isBlockedBycxx . . $ DlCompletionGraph#isBlockedBy(29f359e69572044c). ( node, p ) ) |
| 441 | { |
| 442 | setNodeDBlockedcxx . . $ DlCompletionGraph#setNodeDBlocked(616fb35effd4bdc7). ( node, p ); |
| 443 | return; |
| 444 | } |
| 445 | } |
| 446 | } |