Debian Codegraph @

Kernel/DataReasoning.cpp

raw symbols SCIP
1 /* This file is part of the FaCT++ DL reasoner
2 Copyright (C) 2005-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 "DataReasoning.h"cxx . . $ `<file>/Kernel/DataReasoning.h`/
21
22 //toms code start
23 bool DataTypeReasonercxx . . $ DataTypeReasoner# :: addDataEntrycxx . . $ DataTypeReasoner#addDataEntry(cbd92d0fb85c8e0). ( BipolarPointercxx . . $ BipolarPointer# p, const DepSetcxx . . $ DepSet#& dep )
24 {
25 switch ( DLHeapcxx . . $ DataTypeReasoner#DLHeap.[cxx . . $ DLDag#`operator[]`(5fe3b8e96045ba2c).p].Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8).() )
26 {
27 case dtDataTypecxx . . $ dtDataType.: // get appropriate type
28 {
29 DataTypeAppearancecxx . . $ DataTypeAppearance#* type = getDTAbyTypecxx . . $ DataTypeReasoner#getDTAbyType(1c0342045d0830e1).(getDataEntrycxx . . $ DataTypeReasoner#getDataEntry(8513d1ebfa7d4562).(p));
30
31 if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llCDActioncxx . . $ llCDAction.) ) // level of logging
32 LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). ' ' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). (isPositivecxx . . $ isPositive(83c267b20bac841a).(p) ? '+' : '-') <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). getDataEntrycxx . . $ DataTypeReasoner#getDataEntry(8513d1ebfa7d4562).(p)->getNamecxx . . $ TNamedEntry#getName(a9f41ea0e82d88cf).();
33
34 return setTypePresencecxx . . $ DataTypeReasoner#setTypePresence(16f7716646b17346). ( type, isPositivecxx . . $ isPositive(83c267b20bac841a).(p), dep );
35 }
36 case dtDataValuecxx . . $ dtDataValue.:
37 return processDataValuecxx . . $ DataTypeReasoner#processDataValue(49ad94d50ca1887c). ( isPositivecxx . . $ isPositive(83c267b20bac841a).(p), getDataEntrycxx . . $ DataTypeReasoner#getDataEntry(8513d1ebfa7d4562).(p), dep );
38 case dtDataExprcxx . . $ dtDataExpr.:
39 return processDataExprcxx . . $ DataTypeReasoner#processDataExpr(49ad94d50ca1887c). ( isPositivecxx . . $ isPositive(83c267b20bac841a).(p), getDataEntrycxx . . $ DataTypeReasoner#getDataEntry(8513d1ebfa7d4562).(p), dep );
40 case dtAndcxx . . $ dtAnd.: // processed by general reasoning
41 return false;
42 default:
43 fpp_unreachablecxx . . $ `Kernel/fpp_assert.h:49:9`!();
44 }
45 }
46
47 // ---------- Processing different alternatives
48
49 bool
50 DataTypeAppearancecxx . . $ DataTypeAppearance#::DepIntervalcxx . . $ DataTypeAppearance#DepInterval# :: checkMinMaxClashcxx . . $ DataTypeAppearance#DepInterval#checkMinMaxClash(86fbde385cece29c). ( DepSetcxx . . $ DepSet#& dep ) const
51 {
52 // we are interested in a NEG intervals iff a PType is set
53 if ( !Constraintscxx . . $ DataTypeAppearance#DepInterval#Constraints..closedcxx . . $ TDataInterval#closed(50ce9a9e25b4a850).() )
54 return false;
55
56 const ComparableDTcxx . . $ ComparableDT#& Min = Constraintscxx . . $ DataTypeAppearance#DepInterval#Constraints..mincxx . . $ TDataInterval#min.;
57 const ComparableDTcxx . . $ ComparableDT#& Max = Constraintscxx . . $ DataTypeAppearance#DepInterval#Constraints..maxcxx . . $ TDataInterval#max.;
58
59 // normal interval
60 if ( Min <cxx . . $ ComparableDT#`operator<`(91deb93419938144). Max )
61 return false;
62
63 // >?x and <?y leads to clash for y < x
64 // >5 and <5, >=5 and <5, >5 and <=5 leads to clash
65 if ( Max <cxx . . $ ComparableDT#`operator<`(91deb93419938144). Min || Constraintscxx . . $ DataTypeAppearance#DepInterval#Constraints..minExclcxx . . $ TDataInterval#minExcl. || Constraintscxx . . $ DataTypeAppearance#DepInterval#Constraints..maxExclcxx . . $ TDataInterval#maxExcl. )
66 {
67 dep +=cxx . . $ TDepSet#`operator+=`(6a948e2ed08fa462). locDepcxx . . $ DataTypeAppearance#DepInterval#locDep.;
68 return true;
69 }
70
71 return false;
72 }
73
74 bool
75 DataTypeAppearancecxx . . $ DataTypeAppearance# :: addPosIntervalcxx . . $ DataTypeAppearance#addPosInterval(9fad8f796b1ecb4f). ( const TDataIntervalcxx . . $ TDataInterval#& Int, const DepSetcxx . . $ DepSet#& dep )
76 {
77 DTConstraintcxx . . $ DataTypeAppearance#DTConstraint# auxcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
78 if ( Int.hasMincxx . . $ TDataInterval#hasMin(50ce9a9e25b4a850).() )
79 {
80 Constraintscxx . . $ DataTypeAppearance#Constraints..swapcxx . . $ std/vector#swap(a8be04fc17cbdf49).(aux);
81 setLocalcxx . . $ DataTypeAppearance#setLocal(3703ed15ae49253e). ( /*min=*/true, /*excl=*/Int.minExclcxx . . $ TDataInterval#minExcl., Int.mincxx . . $ TDataInterval#min., dep );
82 if ( addIntervalscxx . . $ DataTypeAppearance#addIntervals(85b4fd7dc680f52b). ( aux.begincxx . . $ std/vector#begin(33b10a496a38335b).(), aux.endcxx . . $ std/vector#end(33b10a496a38335b).() ) )
83 return true;
84 aux.clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).();
85 }
86 if ( Int.hasMaxcxx . . $ TDataInterval#hasMax(50ce9a9e25b4a850).() )
87 {
88 Constraintscxx . . $ DataTypeAppearance#Constraints..swapcxx . . $ std/vector#swap(a8be04fc17cbdf49).(aux);
89 setLocalcxx . . $ DataTypeAppearance#setLocal(3703ed15ae49253e). ( /*min=*/false, /*excl=*/Int.maxExclcxx . . $ TDataInterval#maxExcl., Int.maxcxx . . $ TDataInterval#max., dep );
90 if ( addIntervalscxx . . $ DataTypeAppearance#addIntervals(85b4fd7dc680f52b). ( aux.begincxx . . $ std/vector#begin(33b10a496a38335b).(), aux.endcxx . . $ std/vector#end(33b10a496a38335b).() ) )
91 return true;
92 aux.clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).();
93 }
94 if ( Constraintscxx . . $ DataTypeAppearance#Constraints..emptycxx . . $ std/vector#empty(50ce9a9e25b4a850).() )
95 return reportClashcxx . . $ DataTypeAppearance#reportClash(6e83bd8e52edb65e). ( accDepcxx . . $ DataTypeAppearance#accDep., "C-MM" );
96 return false;
97 }
98
99 bool
100 DataTypeAppearancecxx . . $ DataTypeAppearance# :: addNegIntervalcxx . . $ DataTypeAppearance#addNegInterval(9fad8f796b1ecb4f). ( const TDataIntervalcxx . . $ TDataInterval#& Int, const DepSetcxx . . $ DepSet#& dep )
101 {
102 // negative interval -- make a copies
103 DTConstraintcxx . . $ DataTypeAppearance#DTConstraint# auxcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
104 Constraintscxx . . $ DataTypeAppearance#Constraints..swapcxx . . $ std/vector#swap(a8be04fc17cbdf49).(aux);
105
106 if ( Int.hasMincxx . . $ TDataInterval#hasMin(50ce9a9e25b4a850).() )
107 {
108 setLocalcxx . . $ DataTypeAppearance#setLocal(3703ed15ae49253e). ( /*min=*/false, /*excl=*/!Int.minExclcxx . . $ TDataInterval#minExcl., Int.mincxx . . $ TDataInterval#min., dep );
109 if ( addIntervalscxx . . $ DataTypeAppearance#addIntervals(85b4fd7dc680f52b). ( aux.begincxx . . $ std/vector#begin(33b10a496a38335b).(), aux.endcxx . . $ std/vector#end(33b10a496a38335b).() ) )
110 return true;
111 }
112 if ( Int.hasMaxcxx . . $ TDataInterval#hasMax(50ce9a9e25b4a850).() )
113 {
114 setLocalcxx . . $ DataTypeAppearance#setLocal(3703ed15ae49253e). ( /*min=*/ true, /*excl=*/!Int.maxExclcxx . . $ TDataInterval#maxExcl., Int.maxcxx . . $ TDataInterval#max., dep );
115 if ( addIntervalscxx . . $ DataTypeAppearance#addIntervals(85b4fd7dc680f52b). ( aux.begincxx . . $ std/vector#begin(33b10a496a38335b).(), aux.endcxx . . $ std/vector#end(33b10a496a38335b).() ) )
116 return true;
117 }
118 aux.clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).();
119 if ( Constraintscxx . . $ DataTypeAppearance#Constraints..emptycxx . . $ std/vector#empty(50ce9a9e25b4a850).() )
120 return reportClashcxx . . $ DataTypeAppearance#reportClash(6e83bd8e52edb65e). ( accDepcxx . . $ DataTypeAppearance#accDep., "C-MM" );
121 return false;
122 }
123
124 // comparison methods
125
126 /// @return true iff there is at least one point that two DTA share
127 bool
128 DataTypeAppearancecxx . . $ DataTypeAppearance# :: operatorcxx . . $ DataTypeAppearance#`operator==`(424a1824d79577c0). == ( const DataTypeAppearancecxx . . $ DataTypeAppearance#& other ) const
129 {
130 if ( Constraintscxx . . $ DataTypeAppearance#Constraints..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).() != 1 && other.Constraintscxx . . $ DataTypeAppearance#Constraints..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).() != 1 )
131 return false; // FORNOW: just a single interval
132 const TDataIntervalcxx . . $ TDataInterval#& i0 = Constraintscxx . . $ DataTypeAppearance#Constraints.[cxx . . $ std/vector#`operator[]`(b61e45a10b63f40a).0].getDataIntervalcxx . . $ DataTypeAppearance#DepInterval#getDataInterval(46692a9b285f8bd6).();
133 const TDataIntervalcxx . . $ TDataInterval#& i1 = other.Constraintscxx . . $ DataTypeAppearance#Constraints.[cxx . . $ std/vector#`operator[]`(b61e45a10b63f40a).0].getDataIntervalcxx . . $ DataTypeAppearance#DepInterval#getDataInterval(46692a9b285f8bd6).();
134 if ( !i0.closedcxx . . $ TDataInterval#closed(50ce9a9e25b4a850).() || !i1.closedcxx . . $ TDataInterval#closed(50ce9a9e25b4a850).() ) // FORNOW: only closed ones
135 return false;
136 const ComparableDTcxx . . $ ComparableDT#& min0 = i0.mincxx . . $ TDataInterval#min.;
137 const ComparableDTcxx . . $ ComparableDT#& min1 = i1.mincxx . . $ TDataInterval#min.;
138 const ComparableDTcxx . . $ ComparableDT#& max0 = i0.maxcxx . . $ TDataInterval#max.;
139 const ComparableDTcxx . . $ ComparableDT#& max1 = i1.maxcxx . . $ TDataInterval#max.;
140 if ( max0 <cxx . . $ ComparableDT#`operator<`(91deb93419938144). min1 || max1 <cxx . . $ ComparableDT#`operator<`(91deb93419938144). min0 ) // no intersection
141 return false;
142 // here there is an intersection: minx-miny-maxz-maxt
143 if ( min0 ==cxx . . $ ComparableDT#`operator==`(91deb93419938144). max1 && (i0.minExclcxx . . $ TDataInterval#minExcl. || i1.maxExclcxx . . $ TDataInterval#maxExcl.) ) // no touch with a border
144 return false;
145 if ( min1 ==cxx . . $ ComparableDT#`operator==`(91deb93419938144). max0 && (i1.minExclcxx . . $ TDataInterval#minExcl. || i0.maxExclcxx . . $ TDataInterval#maxExcl.) ) // no touch with a border
146 return false;
147 return true;
148 }
149
150 /// @return true iff there is at least one point in OTHER that there is not in THIS
151 bool
152 DataTypeAppearancecxx . . $ DataTypeAppearance# :: operatorcxx . . $ DataTypeAppearance#`operator<`(424a1824d79577c0). < ( const DataTypeAppearancecxx . . $ DataTypeAppearance#& other ) const
153 {
154 if ( Constraintscxx . . $ DataTypeAppearance#Constraints..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).() != 1 && other.Constraintscxx . . $ DataTypeAppearance#Constraints..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).() != 1 )
155 return false; // FORNOW: just a single interval
156 const TDataIntervalcxx . . $ TDataInterval#& i0 = Constraintscxx . . $ DataTypeAppearance#Constraints.[cxx . . $ std/vector#`operator[]`(b61e45a10b63f40a).0].getDataIntervalcxx . . $ DataTypeAppearance#DepInterval#getDataInterval(46692a9b285f8bd6).();
157 const TDataIntervalcxx . . $ TDataInterval#& i1 = other.Constraintscxx . . $ DataTypeAppearance#Constraints.[cxx . . $ std/vector#`operator[]`(b61e45a10b63f40a).0].getDataIntervalcxx . . $ DataTypeAppearance#DepInterval#getDataInterval(46692a9b285f8bd6).();
158 if ( !i1.hasMaxcxx . . $ TDataInterval#hasMax(50ce9a9e25b4a850).() ) // always can find larger one
159 return true;
160 // here i1.max exists
161 if ( !i0.hasMincxx . . $ TDataInterval#hasMin(50ce9a9e25b4a850).() ) // always can find a smaller one
162 return true;
163 // here i0.min exists
164 if ( i0.mincxx . . $ TDataInterval#min. <cxx . . $ ComparableDT#`operator<`(91deb93419938144). i1.maxcxx . . $ TDataInterval#max. ) // {5,} and {,7}
165 return true;
166 if ( i0.mincxx . . $ TDataInterval#min. ==cxx . . $ ComparableDT#`operator==`(91deb93419938144). i1.maxcxx . . $ TDataInterval#max. && i0.minExclcxx . . $ TDataInterval#minExcl. && !i1.maxExclcxx . . $ TDataInterval#maxExcl. )
167 return true; // (5,} and {,5]
168 // note that (6,} and {,5] are not in the < relation
169 return false;
170 }
171