| 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 "CWDArray.h"cxx . . $ `<file>/Kernel/CWDArray.h`/ |
| 21 | #include "tRestorer.h"cxx . . $ `<file>/Kernel/tRestorer.h`/ |
| 22 | |
| 23 | /// restore dep-set of the duplicated label element of the merged node |
| 24 | class UnMergecxx . . $ UnMerge#: public TRestorercxx . . $ TRestorer# |
| 25 | { |
| 26 | protected: |
| 27 | CWDArraycxx . . $ CWDArray#& labelcxx . . $ UnMerge#label.; |
| 28 | int offsetcxx . . $ UnMerge#offset.; |
| 29 | DepSetcxx . . $ DepSet# depcxx . . $ UnMerge#dep.; |
| 30 | public: |
| 31 | UnMergecxx . . $ UnMerge#UnMerge(5187380755c85be7). ( CWDArraycxx . . $ CWDArray#& lab, CWDArraycxx . . $ CWDArray#::iteratorcxx . . $ CWDArray#iterator# p ) |
| 32 | : labelcxx . . $ UnMerge#label.(lab) |
| 33 | , offsetcxx . . $ UnMerge#offset.(int(p-cxx . . $ __gnu_cxx/operator-(2d2e98431344258).lab.begincxx . . $ CWDArray#begin(e55d760a93e9f197).())) |
| 34 | , depcxx . . $ UnMerge#dep.(p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).getDepcxx . . $ ConceptWDep#getDep(bce6462a16d96b29).()) |
| 35 | {} |
| 36 | void restorecxx . . $ UnMerge#restore(49f6e7a06ebc5aa8). ( void ) override |
| 37 | { |
| 38 | CWDArraycxx . . $ CWDArray#::iteratorcxx . . $ CWDArray#iterator# p = labelcxx . . $ UnMerge#label..Basecxx . . $ CWDArray#Base..begincxx . . $ std/vector#begin(33b10a496a38335b).() +cxx . . $ __gnu_cxx/__normal_iterator#operator+(d0cb2d2ebd313f38). offsetcxx . . $ UnMerge#offset.; |
| 39 | *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p =cxx . . $ ConceptWDep#`operator=`(53d048f7c804eb56). ConceptWDepcxx . . $ ConceptWDep#ConceptWDep(12a183a495b39f91).(p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).(),depcxx . . $ UnMerge#dep.); |
| 40 | } |
| 41 | }; // UnMerge |
| 42 | |
| 43 | TRestorercxx . . $ TRestorer#* |
| 44 | CWDArraycxx . . $ CWDArray# :: updateDepSetcxx . . $ CWDArray#updateDepSet(a14715da98a4ac7b). ( BipolarPointercxx . . $ BipolarPointer# bp, const DepSetcxx . . $ DepSet#& dep ) |
| 45 | { |
| 46 | if ( dep.emptycxx . . $ TDepSet#empty(50ce9a9e25b4a850).() ) |
| 47 | return nullptr; |
| 48 | |
| 49 | for ( iteratorcxx . . $ CWDArray#iterator# i = Basecxx . . $ CWDArray#Base..begincxx . . $ std/vector#begin(33b10a496a38335b).(), i_end = Basecxx . . $ CWDArray#Base..endcxx . . $ std/vector#end(33b10a496a38335b).(); i <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). i_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).i ) |
| 50 | if ( i->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).() == bp ) |
| 51 | { |
| 52 | TRestorercxx . . $ TRestorer#* ret = new UnMergecxx . . $ UnMerge#UnMerge(5187380755c85be7). ( *this, i ); |
| 53 | // DepSet odep(i->getDep()); |
| 54 | i->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).addDepcxx . . $ ConceptWDep#addDep(d0e32107376501c0).(dep); |
| 55 | /* if ( odep == i->getDep() ) |
| 56 | { |
| 57 | delete ret; |
| 58 | ret = nullptr; |
| 59 | }*/ |
| 60 | return ret; |
| 61 | } |
| 62 | return nullptr; |
| 63 | } |
| 64 | |
| 65 | /// restore label to given LEVEL using given SS |
| 66 | void |
| 67 | CWDArraycxx . . $ CWDArray# :: restorecxx . . $ CWDArray#restore(5b817809b2ca3f56). ( const SaveStatecxx . . $ CWDArray#SaveState#& ss, unsigned int level ATTR_UNUSEDcxx . . $ `Kernel/globaldef.h:27:10`! ) |
| 68 | { |
| 69 | if ( RKG_USE_DYNAMIC_BACKJUMPINGcxx . . $ `Kernel/globaldef.h:52:10`! ) |
| 70 | { |
| 71 | for ( size_tcxx . . $ size_t# j = ss.epcxx . . $ CWDArray#SaveState#ep.; j < Basecxx . . $ CWDArray#Base..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); ++j ) |
| 72 | if ( Basecxx . . $ CWDArray#Base.[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).j].getDepcxx . . $ ConceptWDep#getDep(bce6462a16d96b29).().containscxx . . $ TDepSet#contains(8de63fdb265b07c1).(level) ) |
| 73 | { |
| 74 | // replace concept that depend on a given BC with TOP |
| 75 | Basecxx . . $ CWDArray#Base.[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).j] =cxx . . $ ConceptWDep#`operator=`(53d048f7c804eb56). ConceptWDepcxx . . $ ConceptWDep#ConceptWDep(12a183a495b39f91).(1,DepSetcxx . . $ TDepSet#TDepSet(49f6e7a06ebc5aa8).()); |
| 76 | } |
| 77 | } |
| 78 | else |
| 79 | Basecxx . . $ CWDArray#Base..resizecxx . . $ std/vector#resize(2c44cd906ae4e829).(ss.epcxx . . $ CWDArray#SaveState#ep.); |
| 80 | } |
| 81 | |
| 82 | /// print label part between given iterators |
| 83 | void |
| 84 | CWDArraycxx . . $ CWDArray# :: printcxx . . $ CWDArray#print(490063bd7e6d8d5d). ( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& o ) const |
| 85 | { |
| 86 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " ["; |
| 87 | const_iteratorcxx . . $ CWDArray#const_iterator# p = begincxx . . $ CWDArray#begin(e55d760a93e9f197).(), p_end = endcxx . . $ CWDArray#end(e55d760a93e9f197).(); |
| 88 | |
| 89 | if ( p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). p_end ) |
| 90 | { |
| 91 | o <<cxx . . $ `operator<<`(658aaef1ace96007). *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p; |
| 92 | |
| 93 | while ( ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end ) |
| 94 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ", " <<cxx . . $ `operator<<`(658aaef1ace96007). *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p; |
| 95 | } |
| 96 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "]"; |
| 97 | } |