Debian Codegraph @

Kernel/dlVertex.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 DLVERTEX_H
21 #define DLVERTEX_Hcxx . . $ `Kernel/dlVertex.h:21:9`!
22
23 #include <vector>
24 #include <cstring> // memset
25 #include <iosfwd>
26
27 #include "globaldef.h"cxx . . $ `<file>/Kernel/globaldef.h`/
28 #include "BiPointer.h"cxx . . $ `<file>/Kernel/BiPointer.h`/
29 #include "modelCacheInterface.h"cxx . . $ `<file>/Kernel/modelCacheInterface.h`/
30 #include "mergeableLabel.h"cxx . . $ `<file>/Kernel/mergeableLabel.h`/ // for sort inferences
31
32 class DLDagcxx . . $ DLDag#;
33 class TRolecxx . . $ TRole#;
34 class TNamedEntrycxx . . $ TNamedEntry#;
35 class SaveLoadManagercxx . . $ SaveLoadManager#;
36
37 /// different Concept Expression tags
38 /*
39 * The one who changing this should always check:
40 * - Additional fields in the class DLVertex
41 * => operator ==
42 * => hash functions
43 * - DLVertex methods omitStat(), getTagName(), Print()
44 * - DLDag methods *Stat()
45 * - DLDag methods getIndex(), updateIndex()
46 * - tree2dag()
47 * - mergeSorts(v)
48 * - setRelevant()
49 * - PrintDagEntry()
50 * - ToDoPriorMatrix::getIndex()
51 * - CGLabel::isComplexConcept()
52 * - prepareCascadedCache()
53 * - commonTacticBody()
54 * - DLVertex::Save/Load methods (SaveLoad.cpp)
55 */
56 enum DagTagcxx . . $ DagTag# {
57 // illegal entry
58 dtBadcxx . . $ dtBad. = 0,
59 // operations
60 dtTopcxx . . $ dtTop.,
61 dtAndcxx . . $ dtAnd.,
62 dtForallcxx . . $ dtForall.,
63 dtLEcxx . . $ dtLE.,
64 dtIrrcxx . . $ dtIrr., // \neg\exists R.Self
65 dtProjcxx . . $ dtProj., // aux vertex with Projection FROM the current node
66 dtNNcxx . . $ dtNN., // NN-rule was applied
67 dtChoosecxx . . $ dtChoose., // choose-rule
68
69 // ID's
70 dtPConceptcxx . . $ dtPConcept., // primitive concept
71 dtNConceptcxx . . $ dtNConcept., // non-primitive concept
72 dtPSingletoncxx . . $ dtPSingleton.,
73 dtNSingletoncxx . . $ dtNSingleton.,
74 dtDataTypecxx . . $ dtDataType.,
75 dtDataValuecxx . . $ dtDataValue.,
76 dtDataExprcxx . . $ dtDataExpr., // data type with restrictions
77 };
78
79 /// check whether given DagTag is a primitive named concept-like entity
80 inline bool isPNameTagcxx . . $ isPNameTag(7b512e7165d9f2af). ( DagTagcxx . . $ DagTag# tag ) { return (tag == dtPConceptcxx . . $ dtPConcept. || tag == dtPSingletoncxx . . $ dtPSingleton.); }
81 /// check whether given DagTag is a non-primitive named concept-like entity
82 inline bool isNNameTagcxx . . $ isNNameTag(7b512e7165d9f2af). ( DagTagcxx . . $ DagTag# tag ) { return (tag == dtNConceptcxx . . $ dtNConcept. || tag == dtNSingletoncxx . . $ dtNSingleton.); }
83 /// check whether given DagTag is a named concept-like entity
84 inline bool isCNameTagcxx . . $ isCNameTag(7b512e7165d9f2af). ( DagTagcxx . . $ DagTag# tag ) { return isPNameTagcxx . . $ isPNameTag(7b512e7165d9f2af).(tag) || isNNameTagcxx . . $ isNNameTag(7b512e7165d9f2af).(tag); }
85
86 // define complex switch labels
87 #define dtConceptcxx . . $ `Kernel/dlVertex.h:87:9`! dtPConcept: case dtNConcept
88 #define dtSingletoncxx . . $ `Kernel/dlVertex.h:88:9`! dtPSingleton: case dtNSingleton
89 #define dtNamecxx . . $ `Kernel/dlVertex.h:89:9`! dtConceptcxx . . $ `Kernel/dlVertex.h:87:9`!: case dtSingletoncxx . . $ `Kernel/dlVertex.h:88:9`!
90 #define dtDatacxx . . $ `Kernel/dlVertex.h:90:9`! dtDataType: case dtDataValue: case dtDataExpr
91
92 /// interface for the cache of DLVertex
93 class DLVertexCachecxx . . $ DLVertexCache#
94 {
95 protected: // members
96 /// cache for the positive entry
97 const modelCacheInterfacecxx . . $ modelCacheInterface#* pCachecxx . . $ DLVertexCache#pCache. = nullptr;
98 /// cache for the negative entry
99 const modelCacheInterfacecxx . . $ modelCacheInterface#* nCachecxx . . $ DLVertexCache#nCache. = nullptr;
100
101 public: // interface
102 /// d'tor
103 virtual ~cxx . . $ DLVertexCache#`~DLVertexCache`(49f6e7a06ebc5aa8).DLVertexCachecxx . . $ DLVertexCache#() { delete pCachecxx . . $ DLVertexCache#pCache.; delete nCachecxx . . $ DLVertexCache#nCache.; }
104
105 // cache interface
106
107 /// return cache wrt positive flag
108 const modelCacheInterfacecxx . . $ modelCacheInterface#* getCachecxx . . $ DLVertexCache#getCache(b56d42e3b093d25c). ( bool pos ) const { return pos ? pCachecxx . . $ DLVertexCache#pCache. : nCachecxx . . $ DLVertexCache#nCache.; }
109 /// set cache wrt positive flag; note that cache is set up only once
110 void setCachecxx . . $ DLVertexCache#setCache(f730227c2b1a60d2). ( bool pos, const modelCacheInterfacecxx . . $ modelCacheInterface#* p )
111 {
112 if ( pos )
113 pCachecxx . . $ DLVertexCache#pCache. = p;
114 else
115 nCachecxx . . $ DLVertexCache#nCache. = p;
116 }
117 }; // DLVertexCache
118
119 class DLVertexStatisticcxx . . $ DLVertexStatistic#
120 {
121 public: // types
122 /// type for a statistic
123 typedef unsigned short int StatTypecxx . . $ DLVertexStatistic#StatType#;
124
125 protected: // members
126 /// maximal depth, size and frequency of reference of the expression
127 StatTypecxx . . $ DLVertexStatistic#StatType# statcxx . . $ DLVertexStatistic#stat.[10];
128
129 public: // static methods
130 /// get access to statistic by the depth of a concept
131 static unsigned int getStatIndexDepthcxx . . $ DLVertexStatistic#getStatIndexDepth(9e1a662fef1ac081). ( bool pos ) { return (pos ? 0 : 1); }
132 /// get access to statistic by the size of a concept
133 static unsigned int getStatIndexSizecxx . . $ DLVertexStatistic#getStatIndexSize(9e1a662fef1ac081). ( bool pos ) { return (pos ? 2 : 3); }
134 /// get access to statistic by the # of branching rules of a concept
135 static unsigned int getStatIndexBranchcxx . . $ DLVertexStatistic#getStatIndexBranch(9e1a662fef1ac081). ( bool pos ) { return (pos ? 4 : 5); }
136 /// get access to statistic by the # of generating rules of a concept
137 static unsigned int getStatIndexGenercxx . . $ DLVertexStatistic#getStatIndexGener(9e1a662fef1ac081). ( bool pos ) { return (pos ? 6 : 7); }
138 /// get access to statistic by the freq of a concept
139 static unsigned int getStatIndexFreqcxx . . $ DLVertexStatistic#getStatIndexFreq(9e1a662fef1ac081). ( bool pos ) { return (pos ? 8 : 9); }
140
141 public: // interface
142 /// default c'tor
143 DLVertexStatisticcxx . . $ DLVertexStatistic#DLVertexStatistic(49f6e7a06ebc5aa8). ( void ) { stdcxx . . $ std/::memset ( statcxx . . $ DLVertexStatistic#stat., 0, sizeof(statcxx . . $ DLVertexStatistic#stat.) ); }
144 /// empty d'tor
145 virtual ~cxx . . $ DLVertexStatistic#`~DLVertexStatistic`(49f6e7a06ebc5aa8).DLVertexStatisticcxx . . $ DLVertexStatistic#() = default;
146
147 // set methods
148
149 /// add-up all stat values at once by explicit values
150 void updateStatValuescxx . . $ DLVertexStatistic#updateStatValues(115ca1feb1740ab2). ( StatTypecxx . . $ DLVertexStatistic#StatType# d, StatTypecxx . . $ DLVertexStatistic#StatType# s, StatTypecxx . . $ DLVertexStatistic#StatType# b, StatTypecxx . . $ DLVertexStatistic#StatType# g, bool pos )
151 {
152 statcxx . . $ DLVertexStatistic#stat.[getStatIndexSizecxx . . $ DLVertexStatistic#getStatIndexSize(9e1a662fef1ac081).(pos)] += s;
153 statcxx . . $ DLVertexStatistic#stat.[getStatIndexBranchcxx . . $ DLVertexStatistic#getStatIndexBranch(9e1a662fef1ac081).(pos)] += b;
154 statcxx . . $ DLVertexStatistic#stat.[getStatIndexGenercxx . . $ DLVertexStatistic#getStatIndexGener(9e1a662fef1ac081).(pos)] += g;
155 if ( d > statcxx . . $ DLVertexStatistic#stat.[getStatIndexDepthcxx . . $ DLVertexStatistic#getStatIndexDepth(9e1a662fef1ac081).(pos)] )
156 statcxx . . $ DLVertexStatistic#stat.[getStatIndexDepthcxx . . $ DLVertexStatistic#getStatIndexDepth(9e1a662fef1ac081).(pos)] = d;
157 }
158 /// add-up all values at once by a given vertex
159 void updateStatValuescxx . . $ DLVertexStatistic#updateStatValues(7baf84d5bb3c1273). ( const DLVertexStatisticcxx . . $ DLVertexStatistic#& v, bool posV, bool pos )
160 { updateStatValuescxx . . $ DLVertexStatistic#updateStatValues(115ca1feb1740ab2). ( v.getDepthcxx . . $ DLVertexStatistic#getDepth(27106ebd64dc40f5).(posV), v.getSizecxx . . $ DLVertexStatistic#getSize(27106ebd64dc40f5).(posV), v.getBranchcxx . . $ DLVertexStatistic#getBranch(27106ebd64dc40f5).(posV), v.getGenercxx . . $ DLVertexStatistic#getGener(27106ebd64dc40f5).(posV), pos ); }
161 /// increment frequency value
162 void incFreqValuecxx . . $ DLVertexStatistic#incFreqValue(b45ddcbc8423892c). ( bool pos ) { ++statcxx . . $ DLVertexStatistic#stat.[getStatIndexFreqcxx . . $ DLVertexStatistic#getStatIndexFreq(9e1a662fef1ac081).(pos)]; }
163
164 // get methods
165
166 /// general access to a stat value by index
167 StatTypecxx . . $ DLVertexStatistic#StatType# getStatcxx . . $ DLVertexStatistic#getStat(bf63e0e82e9313b7). ( unsigned int i ) const { return statcxx . . $ DLVertexStatistic#stat.[i]; }
168 /// general access to a stat value by index
169 StatTypecxx . . $ DLVertexStatistic#StatType# getDepthcxx . . $ DLVertexStatistic#getDepth(27106ebd64dc40f5). ( bool pos ) const { return statcxx . . $ DLVertexStatistic#stat.[getStatIndexDepthcxx . . $ DLVertexStatistic#getStatIndexDepth(9e1a662fef1ac081).(pos)]; }
170 /// general access to a stat value by index
171 StatTypecxx . . $ DLVertexStatistic#StatType# getSizecxx . . $ DLVertexStatistic#getSize(27106ebd64dc40f5). ( bool pos ) const { return statcxx . . $ DLVertexStatistic#stat.[getStatIndexSizecxx . . $ DLVertexStatistic#getStatIndexSize(9e1a662fef1ac081).(pos)]; }
172 /// general access to a stat value by index
173 StatTypecxx . . $ DLVertexStatistic#StatType# getBranchcxx . . $ DLVertexStatistic#getBranch(27106ebd64dc40f5). ( bool pos ) const { return statcxx . . $ DLVertexStatistic#stat.[getStatIndexBranchcxx . . $ DLVertexStatistic#getStatIndexBranch(9e1a662fef1ac081).(pos)]; }
174 /// general access to a stat value by index
175 StatTypecxx . . $ DLVertexStatistic#StatType# getGenercxx . . $ DLVertexStatistic#getGener(27106ebd64dc40f5). ( bool pos ) const { return statcxx . . $ DLVertexStatistic#stat.[getStatIndexGenercxx . . $ DLVertexStatistic#getStatIndexGener(9e1a662fef1ac081).(pos)]; }
176 /// general access to a stat value by index
177 StatTypecxx . . $ DLVertexStatistic#StatType# getFreqcxx . . $ DLVertexStatistic#getFreq(27106ebd64dc40f5). ( bool pos ) const { return statcxx . . $ DLVertexStatistic#stat.[getStatIndexFreqcxx . . $ DLVertexStatistic#getStatIndexFreq(9e1a662fef1ac081).(pos)]; }
178 }; // DLVertexStatistic
179
180 /// tag of the vertex and bits and code for efficient DFS algorithms
181 class DLVertexTagDFScxx . . $ DLVertexTagDFS#
182 {
183 protected: // members
184 /// main operation in concept expression
185 // WARNING: the Visual Studio C++ compiler treat this as a signed integer,
186 // so I've added extra bit to stay in the unsigned field
187 DagTagcxx . . $ DagTag# Opcxx . . $ DLVertexTagDFS#Op. : 6; // 17 types
188 /// aux field for DFS in presence of cycles
189 bool VisitedPoscxx . . $ DLVertexTagDFS#VisitedPos. : 1;
190 /// aux field for DFS in presence of cycles
191 bool ProcessedPoscxx . . $ DLVertexTagDFS#ProcessedPos. : 1;
192 /// true iff node is involved in cycle
193 bool inCyclePoscxx . . $ DLVertexTagDFS#inCyclePos. : 1;
194 /// aux field for DFS in presence of cycles
195 bool VisitedNegcxx . . $ DLVertexTagDFS#VisitedNeg. : 1;
196 /// aux field for DFS in presence of cycles
197 bool ProcessedNegcxx . . $ DLVertexTagDFS#ProcessedNeg. : 1;
198 /// true iff node is involved in cycle
199 bool inCycleNegcxx . . $ DLVertexTagDFS#inCycleNeg. : 1;
200 /// padding
201 unsigned unusedcxx . . $ DLVertexTagDFS#unused. : 4;
202
203 public: // interface
204 /// default c'tor
205 explicit DLVertexTagDFScxx . . $ DLVertexTagDFS#DLVertexTagDFS(ad6456c609ca5a0d). ( DagTagcxx . . $ DagTag# op )
206 : Opcxx . . $ DLVertexTagDFS#Op.(op)
207 , VisitedPoscxx . . $ DLVertexTagDFS#VisitedPos.(false)
208 , ProcessedPoscxx . . $ DLVertexTagDFS#ProcessedPos.(false)
209 , inCyclePoscxx . . $ DLVertexTagDFS#inCyclePos.(false)
210 , VisitedNegcxx . . $ DLVertexTagDFS#VisitedNeg.(false)
211 , ProcessedNegcxx . . $ DLVertexTagDFS#ProcessedNeg.(false)
212 , inCycleNegcxx . . $ DLVertexTagDFS#inCycleNeg.(false)
213 {}
214 /// empty d'tor
215 virtual ~cxx . . $ DLVertexTagDFS#`~DLVertexTagDFS`(49f6e7a06ebc5aa8).DLVertexTagDFScxx . . $ DLVertexTagDFS#() = default;
216
217 // tag access
218
219 /// return tag of the CE
220 DagTagcxx . . $ DagTag# Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8). ( void ) const { return Opcxx . . $ DLVertexTagDFS#Op.; }
221
222 // DFS-related method
223
224 /// check whether current Vertex is being visited
225 bool isVisitedcxx . . $ DLVertexTagDFS#isVisited(962fae8be55e1d9). ( bool pos ) const { return (pos ? VisitedPoscxx . . $ DLVertexTagDFS#VisitedPos. : VisitedNegcxx . . $ DLVertexTagDFS#VisitedNeg.); }
226 /// check whether current Vertex is processed
227 bool isProcessedcxx . . $ DLVertexTagDFS#isProcessed(962fae8be55e1d9). ( bool pos ) const { return (pos ? ProcessedPoscxx . . $ DLVertexTagDFS#ProcessedPos. : ProcessedNegcxx . . $ DLVertexTagDFS#ProcessedNeg.); }
228 /// set that the node is being visited
229 void setVisitedcxx . . $ DLVertexTagDFS#setVisited(b45ddcbc8423892c). ( bool pos ) { if ( pos ) VisitedPoscxx . . $ DLVertexTagDFS#VisitedPos. = true; else VisitedNegcxx . . $ DLVertexTagDFS#VisitedNeg. = true; }
230 /// set that the node' DFS processing is completed
231 void setProcessedcxx . . $ DLVertexTagDFS#setProcessed(b45ddcbc8423892c). ( bool pos )
232 {
233 if ( pos )
234 {
235 ProcessedPoscxx . . $ DLVertexTagDFS#ProcessedPos. = true;
236 VisitedPoscxx . . $ DLVertexTagDFS#VisitedPos. = false;
237 }
238 else
239 {
240 ProcessedNegcxx . . $ DLVertexTagDFS#ProcessedNeg. = true;
241 VisitedNegcxx . . $ DLVertexTagDFS#VisitedNeg. = false;
242 }
243 }
244 /// clear DFS flags
245 void clearDFScxx . . $ DLVertexTagDFS#clearDFS(49f6e7a06ebc5aa8). ( void ) { ProcessedPoscxx . . $ DLVertexTagDFS#ProcessedPos. = VisitedPoscxx . . $ DLVertexTagDFS#VisitedPos. = ProcessedNegcxx . . $ DLVertexTagDFS#ProcessedNeg. = VisitedNegcxx . . $ DLVertexTagDFS#VisitedNeg. = false; }
246 /// check whether concept is in cycle
247 bool isInCyclecxx . . $ DLVertexTagDFS#isInCycle(962fae8be55e1d9). ( bool pos ) const { return (pos ? inCyclePoscxx . . $ DLVertexTagDFS#inCyclePos. : inCycleNegcxx . . $ DLVertexTagDFS#inCycleNeg.); }
248 /// set concept is in cycle
249 void setInCyclecxx . . $ DLVertexTagDFS#setInCycle(b45ddcbc8423892c). ( bool pos ) { if ( pos ) inCyclePoscxx . . $ DLVertexTagDFS#inCyclePos. = true; else inCycleNegcxx . . $ DLVertexTagDFS#inCycleNeg. = true; }
250 }; // DLVertexTagDFS
251
252 /// usage of the particular vertex during reasoning
253 class DLVertexUsagecxx . . $ DLVertexUsage#
254 {
255 public: // types
256 /// type for a statistic
257 typedef unsigned long UsageTypecxx . . $ DLVertexUsage#UsageType#;
258
259 protected: // members
260 /// usage statistic for pos- and neg occurrences of a vertex
261 UsageTypecxx . . $ DLVertexUsage#UsageType# posUsagecxx . . $ DLVertexUsage#posUsage. = 0;
262 UsageTypecxx . . $ DLVertexUsage#UsageType# negUsagecxx . . $ DLVertexUsage#negUsage. = 0;
263
264 public: // interface
265 /// empty d'tor
266 virtual ~cxx . . $ DLVertexUsage#`~DLVertexUsage`(49f6e7a06ebc5aa8).DLVertexUsagecxx . . $ DLVertexUsage#() = default;
267
268 /// get access to a usage wrt POS
269 UsageTypecxx . . $ DLVertexUsage#UsageType# getUsagecxx . . $ DLVertexUsage#getUsage(de6687e2a058588e). ( bool pos ) const { return pos ? posUsagecxx . . $ DLVertexUsage#posUsage. : negUsagecxx . . $ DLVertexUsage#negUsage.; }
270 /// increment usage of the node
271 void incUsagecxx . . $ DLVertexUsage#incUsage(b45ddcbc8423892c). ( bool pos ) { if ( pos ) ++posUsagecxx . . $ DLVertexUsage#posUsage.; else ++negUsagecxx . . $ DLVertexUsage#negUsage.; }
272 }; // DLVertexUsage
273
274 class DLVertexSortcxx . . $ DLVertexSort#
275 {
276 protected: // members
277 /// maximal depth, size and frequency of reference of the expression
278 mergeableLabelcxx . . $ mergeableLabel# Sortcxx . . $ DLVertexSort#Sort.;
279
280 public: // interface
281 /// empty d'tor
282 virtual ~cxx . . $ DLVertexSort#`~DLVertexSort`(49f6e7a06ebc5aa8).DLVertexSortcxx . . $ DLVertexSort#() = default;
283
284 // label access methods
285
286 /// get RW access to the label
287 mergeableLabelcxx . . $ mergeableLabel#& getSortcxx . . $ DLVertexSort#getSort(e1d2169d387f9f72). ( void ) { return Sortcxx . . $ DLVertexSort#Sort.; }
288 /// get RO access to the label
289 const mergeableLabelcxx . . $ mergeableLabel#& getSortcxx . . $ DLVertexSort#getSort(16201f018f613e0c). ( void ) const { return Sortcxx . . $ DLVertexSort#Sort.; }
290 /// merge local label to label LABEL
291 void mergecxx . . $ DLVertexSort#merge(e3a03ee78af03ab7). ( mergeableLabelcxx . . $ mergeableLabel#& label ) { Sortcxx . . $ DLVertexSort#Sort..mergecxx . . $ mergeableLabel#merge(e3a03ee78af03ab7).(label); }
292 }; // DLVertexSort
293
294 /// Class for normalised Concept Expressions
295 class DLVertexcxx . . $ DLVertex#
296 : public DLVertexCachecxx . . $ DLVertexCache#
297 , public DLVertexStatisticcxx . . $ DLVertexStatistic#
298 #ifdef RKG_PRINT_DAG_USAGE
299 , public DLVertexUsage
300 #endif
301 , public DLVertexTagDFScxx . . $ DLVertexTagDFS#
302 #ifdef RKG_USE_SORTED_REASONINGcxx . . $ `Kernel/globaldef.h:40:9`!
303 , public DLVertexSortcxx . . $ DLVertexSort#
304 #endif
305 {
306 protected: // typedefs
307 /// base type for array of BPs
308 typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<BipolarPointercxx . . $ BipolarPointer#> BaseTypecxx . . $ DLVertex#BaseType#;
309
310 public: // typedefs
311 /// RO access to the elements of node
312 typedef BaseTypecxx . . $ DLVertex#BaseType#::const_iteratorcxx . . $ std/vector#const_iterator# const_iteratorcxx . . $ DLVertex#const_iterator#;
313 /// RO access to the elements of node in reverse order
314 typedef BaseTypecxx . . $ DLVertex#BaseType#::const_reverse_iteratorcxx . . $ std/vector#const_reverse_iterator# const_reverse_iteratorcxx . . $ DLVertex#const_reverse_iterator#;
315
316 protected: // members
317 /// set of arguments (CEs, numbers for NR)
318 BaseTypecxx . . $ DLVertex#BaseType# Childcxx . . $ DLVertex#Child.;
319 /// pointer to concept-like entry (for PConcept, etc)
320 TNamedEntrycxx . . $ TNamedEntry#* Conceptcxx . . $ DLVertex#Concept. = nullptr;
321 /// pointer to role (for E\A, NR)
322 const TRolecxx . . $ TRole#* Rolecxx . . $ DLVertex#Role. = nullptr;
323 /// projection role (used for projection op only)
324 const TRolecxx . . $ TRole#* ProjRolecxx . . $ DLVertex#ProjRole. = nullptr;
325 /// C if available
326 BipolarPointercxx . . $ BipolarPointer# Ccxx . . $ DLVertex#C. = bpINVALIDcxx . . $ bpINVALID.;
327 /// n if available
328 unsigned int ncxx . . $ DLVertex#n. = 0;
329
330 public: // interface
331 /// c'tor for Top/CN/And (before adding any operands)
332 explicit DLVertexcxx . . $ DLVertex#DLVertex(ad6456c609ca5a0d). ( DagTagcxx . . $ DagTag# op )
333 : DLVertexTagDFScxx . . $ DLVertexTagDFS#DLVertexTagDFS(ad6456c609ca5a0d).(op)
334 {}
335 /// c'tor for Refl/Irr
336 DLVertexcxx . . $ DLVertex#DLVertex(b4cd0469b12e18ee). ( DagTagcxx . . $ DagTag# op, const TRolecxx . . $ TRole#* R )
337 : DLVertexTagDFScxx . . $ DLVertexTagDFS#(op)
338 , Rolecxx . . $ DLVertex#Role.(R)
339 {}
340 /// c'tor for CN/DE; C is an operand
341 DLVertexcxx . . $ DLVertex#DLVertex(1b450d680d29287e). ( DagTagcxx . . $ DagTag# op, BipolarPointercxx . . $ BipolarPointer# c )
342 : DLVertexTagDFScxx . . $ DLVertexTagDFS#(op)
343 , Ccxx . . $ DLVertex#C.(c)
344 {}
345 /// c'tor for <= n R_C; and for \A R{n}_C; Note order C, n, R->pointer
346 DLVertexcxx . . $ DLVertex#DLVertex(cb14fcc1b50645ce). ( DagTagcxx . . $ DagTag# op, unsigned int m, const TRolecxx . . $ TRole#* R, BipolarPointercxx . . $ BipolarPointer# c )
347 : DLVertexTagDFScxx . . $ DLVertexTagDFS#DLVertexTagDFS(ad6456c609ca5a0d).(op)
348 , Rolecxx . . $ DLVertex#Role.(R)
349 , Ccxx . . $ DLVertex#C.(c)
350 , ncxx . . $ DLVertex#n.(m)
351 {}
352 /// c'tor for ProjFrom R C ProjR
353 DLVertexcxx . . $ DLVertex#DLVertex(84ad0cda80722ebc). ( const TRolecxx . . $ TRole#* R, BipolarPointercxx . . $ BipolarPointer# c, const TRolecxx . . $ TRole#* ProjR )
354 : DLVertexTagDFScxx . . $ DLVertexTagDFS#(dtProjcxx . . $ dtProj.)
355 , Rolecxx . . $ DLVertex#Role.(R)
356 , ProjRolecxx . . $ DLVertex#ProjRole.(ProjR)
357 , Ccxx . . $ DLVertex#C.(c)
358 {}
359 /// no copy c'tor
360 DLVertexcxx . . $ DLVertex#DLVertex(c29169630048b37c). ( const DLVertexcxx . . $ DLVertex#& ) = delete;
361 /// no assignment
362 DLVertexcxx . . $ DLVertex#& operatorcxx . . $ DLVertex#`operator=`(5b176a126d8358db). = ( const DLVertexcxx . . $ DLVertex#& ) = delete;
363
364 /// compare 2 CEs
365 bool operatorcxx . . $ DLVertex#`operator==`(a7e9993be36471cf). == ( const DLVertexcxx . . $ DLVertex#& v ) const
366 {
367 return (Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8).() == v.Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8).()) &&
368 (Rolecxx . . $ DLVertex#Role. == v.Rolecxx . . $ DLVertex#Role.) &&
369 (ProjRolecxx . . $ DLVertex#ProjRole. == v.ProjRolecxx . . $ DLVertex#ProjRole.) &&
370 (Ccxx . . $ DLVertex#C. == v.Ccxx . . $ DLVertex#C.) &&
371 (ncxx . . $ DLVertex#n. == v.ncxx . . $ DLVertex#n.) &&
372 (Childcxx . . $ DLVertex#Child. ==cxx . . $ std/`operator==`(a0a51a13f7e42509). v.Childcxx . . $ DLVertex#Child.);
373 }
374 /// compare 2 CEs
375 bool operatorcxx . . $ DLVertex#`operator!=`(a7e9993be36471cf). != ( const DLVertexcxx . . $ DLVertex#& v ) const { return !(*this ==cxx . . $ DLVertex#`operator==`(a7e9993be36471cf). v); }
376 /// return C for concepts/quantifiers/NR vertices
377 BipolarPointercxx . . $ BipolarPointer# getCcxx . . $ DLVertex#getC(455f465bc33b4cdf). ( void ) const { return Ccxx . . $ DLVertex#C.; }
378 /// return N for the (<= n R) vertex
379 unsigned int getNumberLEcxx . . $ DLVertex#getNumberLE(ddd8539a2fcdd4ce). ( void ) const { return ncxx . . $ DLVertex#n.; }
380 /// return N for the (>= n R) vertex
381 unsigned int getNumberGEcxx . . $ DLVertex#getNumberGE(ddd8539a2fcdd4ce). ( void ) const { return ncxx . . $ DLVertex#n.+1; }
382 /// return STATE for the (\all R{state}.C) vertex
383 unsigned int getStatecxx . . $ DLVertex#getState(ddd8539a2fcdd4ce). ( void ) const { return ncxx . . $ DLVertex#n.; }
384
385 /// return pointer to the first concept name of the entry
386 const_iteratorcxx . . $ DLVertex#const_iterator# begincxx . . $ DLVertex#begin(d2502ee2ca3b883a). ( void ) const { return Childcxx . . $ DLVertex#Child..begincxx . . $ std/vector#begin(359ca5030082c9f).(); }
387 /// return pointer after the last concept name of the entry
388 const_iteratorcxx . . $ DLVertex#const_iterator# endcxx . . $ DLVertex#end(d2502ee2ca3b883a). ( void ) const { return Childcxx . . $ DLVertex#Child..endcxx . . $ std/vector#end(359ca5030082c9f).(); }
389
390 /// return pointer to the last concept name of the entry; WARNING!! works for AND only
391 const_reverse_iteratorcxx . . $ DLVertex#const_reverse_iterator# rbegincxx . . $ DLVertex#rbegin(58c1148bcabf3013). ( void ) const { return Childcxx . . $ std/reverse_iterator#reverse_iterator(e2d883c4bd185f58)..rbegincxx . . $ std/vector#rbegin(93c341aad09a535d).(); }
392 /// return pointer before the first concept name of the entry; WARNING!! works for AND only
393 const_reverse_iteratorcxx . . $ DLVertex#const_reverse_iterator# rendcxx . . $ DLVertex#rend(58c1148bcabf3013). ( void ) const { return Childcxx . . $ std/reverse_iterator#reverse_iterator(e2d883c4bd185f58)..rendcxx . . $ std/vector#rend(93c341aad09a535d).(); }
394
395 /// return pointer to Role for the Role-like vertices
396 const TRolecxx . . $ TRole#* getRolecxx . . $ DLVertex#getRole(69f26110a94b259f). ( void ) const { return Rolecxx . . $ DLVertex#Role.; }
397 /// return pointer to Projection Role for the Projection vertices
398 const TRolecxx . . $ TRole#* getProjRolecxx . . $ DLVertex#getProjRole(69f26110a94b259f). ( void ) const { return ProjRolecxx . . $ DLVertex#ProjRole.; }
399 /// get (RW) TConcept for concept-like fields
400 TNamedEntrycxx . . $ TNamedEntry#* getConceptcxx . . $ DLVertex#getConcept(f3d19eb180c44c64). ( void ) { return Conceptcxx . . $ DLVertex#Concept.; }
401 /// get (RO) TConcept for concept-like fields
402 const TNamedEntrycxx . . $ TNamedEntry#* getConceptcxx . . $ DLVertex#getConcept(1867504d72698304). ( void ) const { return Conceptcxx . . $ DLVertex#Concept.; }
403
404 /// set TConcept value to entry
405 void setConceptcxx . . $ DLVertex#setConcept(69d9f70ea506b4a4). ( TNamedEntrycxx . . $ TNamedEntry#* p ) { Conceptcxx . . $ DLVertex#Concept. = p; }
406 /// set a concept (child) to Name-like vertex
407 void setChildcxx . . $ DLVertex#setChild(d4f767463ce0a6b3). ( BipolarPointercxx . . $ BipolarPointer# p ) { Ccxx . . $ DLVertex#C. = p; }
408 /// adds a child to 'AND' vertex; returns TRUE if contradiction found
409 bool addChildcxx . . $ DLVertex#addChild(83c267b20bac841a). ( BipolarPointercxx . . $ BipolarPointer# p );
410
411 // methods for choosing ordering in the OR fields
412
413 /// whether statistic's gathering should be omitted due to the type of a vertex
414 bool omitStatcxx . . $ DLVertex#omitStat(962fae8be55e1d9). ( bool pos ) const;
415 /// sort entry using DAG's compare method
416 void sortEntrycxx . . $ DLVertex#sortEntry(dd585ec903520274). ( const DLDagcxx . . $ DLDag#& dag );
417
418 // output
419
420 /// get text name for CE tag
421 const char* getTagNamecxx . . $ DLVertex#getTagName(a9f41ea0e82d88cf). ( void ) const;
422 /// print the whole node
423 void Printcxx . . $ DLVertex#Print(490063bd7e6d8d5d). ( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& o ) const;
424
425 // save/load interface; implementation is in SaveLoad.cpp
426
427 /// save entry
428 void Savecxx . . $ DLVertex#Save(aaac402dd6f8bcf7). ( SaveLoadManagercxx . . $ SaveLoadManager#& m ) const;
429 /// load entry
430 void Loadcxx . . $ DLVertex#Load(da67b8e43f9c9b96). ( SaveLoadManagercxx . . $ SaveLoadManager#& m );
431 }; // DLVertex
432
433
434 /// whether statistic's gathering should be omitted due to the type of a vertex
435 inline bool
436 DLVertexcxx . . $ DLVertex# :: omitStatcxx . . $ DLVertex#omitStat(962fae8be55e1d9). ( bool pos ) const
437 {
438 switch ( Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8).() )
439 {
440 case dtDataTypecxx . . $ dtDataType.:
441 case dtDataValuecxx . . $ dtDataValue.:
442 case dtDataExprcxx . . $ dtDataExpr.:
443 case dtNNcxx . . $ dtNN.: // no way to get it in expressions
444 case dtChoosecxx . . $ dtChoose.: // same
445 case dtBadcxx . . $ dtBad.:
446 case dtTopcxx . . $ dtTop.:
447 return true;
448 case dtPConceptcxx . . $ dtPConcept.:
449 case dtPSingletoncxx . . $ dtPSingleton.:
450 case dtProjcxx . . $ dtProj.:
451 return !pos;
452 default:
453 return false;
454 }
455 }
456
457 /**
458 * returns true iff corresponding NRs may clash.
459 * Clash may appears for (>= n R) and (<= m R) if n > m.
460 * Since \neg (<= n R) represents (>= (n+1) R), so
461 * comparison became (n+1) > m, or n >= m
462 */
463 inline bool mayClashNRcxx . . $ mayClashNR(8e1b545ea3aecce3). ( unsigned int geNR, unsigned int leNR )
464 {
465 return geNR >= leNR;
466 }
467
468 #endif