dlvhex
2.5.0
|
00001 /* dlvhex -- Answer-Set Programming with external interfaces. 00002 * Copyright (C) 2005-2007 Roman Schindlauer 00003 * Copyright (C) 2006-2015 Thomas Krennwallner 00004 * Copyright (C) 2009-2016 Peter Schüller 00005 * Copyright (C) 2011-2016 Christoph Redl 00006 * Copyright (C) 2015-2016 Tobias Kaminski 00007 * Copyright (C) 2015-2016 Antonius Weinzierl 00008 * 00009 * This file is part of dlvhex. 00010 * 00011 * dlvhex is free software; you can redistribute it and/or modify it 00012 * under the terms of the GNU Lesser General Public License as 00013 * published by the Free Software Foundation; either version 2.1 of 00014 * the License, or (at your option) any later version. 00015 * 00016 * dlvhex is distributed in the hope that it will be useful, but 00017 * WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with dlvhex; if not, write to the Free Software 00023 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00024 * 02110-1301 USA. 00025 */ 00026 00034 #ifndef EXTSOURCEPROPERTIES_HPP_ 00035 #define EXTSOURCEPROPERTIES_HPP_ 00036 00037 #include "dlvhex2/PlatformDefinitions.h" 00038 #include "dlvhex2/Logger.h" 00039 #include "dlvhex2/ID.h" 00040 #include "dlvhex2/fwd.h" 00041 #include "dlvhex2/Printhelpers.h" 00042 00043 #include <vector> 00044 #include <string> 00045 00046 DLVHEX_NAMESPACE_BEGIN 00047 00048 WARNING("TODO what is the difference/intended usage of ExtSourceProperty vs ExtSourceProperties? (the names are not very intuitive)") 00049 00050 00082 struct ExtSourceProperties 00083 { 00084 // exactly one of the following pointers will be NULL 00086 ExternalAtom* ea; 00088 PluginAtom* pa; 00089 00090 // all indices are 0-based 00092 std::set<int> monotonicInputPredicates; 00094 std::set<int> antimonotonicInputPredicates; 00096 std::set<int> predicateParameterNameIndependence; 00098 std::set<int> finiteOutputDomain; 00100 std::set<std::pair<int, int> > relativeFiniteOutputDomain; 00102 bool functional; 00104 int functionalStart; 00106 bool supportSets; 00108 bool onlySafeSupportSets; 00110 bool completePositiveSupportSets; 00112 bool completeNegativeSupportSets; 00114 bool variableOutputArity; 00116 bool caresAboutAssigned; 00118 bool caresAboutChanged; 00120 bool atomlevellinear; // predicate input can be split into single atoms 00122 bool tuplelevellinear; // predicate input can be split such that only atoms with the same arguments must be grouped 00124 bool usesEnvironment; // external atom uses the environment (cf. acthex) 00126 bool finiteFiber; // a fixed output value can be produced only by finitly many different inputs 00128 // <i,j> means that output value at position j is strictly smaller than at input position i (strlen) 00129 std::set<std::pair<int, int> > wellorderingStrlen; 00131 // <i,j> means that output value at position j is strictly smaller than at input position i (wrt. natural numbers) 00132 std::set<std::pair<int, int> > wellorderingNatural; 00134 bool providesPartialAnswer; 00135 00139 ExtSourceProperties() : ea(0), pa(0), functionalStart(0) { 00140 functional = false; 00141 atomlevellinear = false; 00142 tuplelevellinear = false; 00143 usesEnvironment = false; 00144 finiteFiber = false; 00145 onlySafeSupportSets = false; 00146 supportSets = false; 00147 completePositiveSupportSets = false; 00148 completeNegativeSupportSets = false; 00149 variableOutputArity = false; 00150 caresAboutAssigned = false; 00151 caresAboutChanged = false; 00152 providesPartialAnswer = false; 00153 } 00154 00160 ExtSourceProperties& operator|=(const ExtSourceProperties& prop2); 00161 00162 // setter 00164 inline void addMonotonicInputPredicate(int index) { monotonicInputPredicates.insert(index); } 00166 inline void addAntimonotonicInputPredicate(int index) { antimonotonicInputPredicates.insert(index); } 00168 inline void addPredicateParameterNameIndependence(int index) { predicateParameterNameIndependence.insert(index); } 00170 inline void addFiniteOutputDomain(int index) { finiteOutputDomain.insert(index); } 00172 inline void addRelativeFiniteOutputDomain(int index1, int index2) { relativeFiniteOutputDomain.insert(std::pair<int, int>(index1, index2)); } 00174 inline void setFunctional(bool value) { functional = value; } 00176 inline void setFunctionalStart(int value) { functionalStart = value; } 00178 inline void setOnlySafeSupportSets(bool value) { onlySafeSupportSets = value; } 00180 inline void setSupportSets(bool value) { supportSets = value; } 00182 inline void setCompletePositiveSupportSets(bool value) { completePositiveSupportSets = value; } 00184 inline void setCompleteNegativeSupportSets(bool value) { completeNegativeSupportSets = value; } 00186 inline void setVariableOutputArity(bool value) { variableOutputArity = value; } 00188 inline void setCaresAboutAssigned(bool value) { caresAboutAssigned = value; } 00190 inline void setCaresAboutChanged(bool value) { caresAboutChanged = value; } 00192 inline void setAtomlevellinear(bool value) { atomlevellinear = value; } 00194 inline void setTuplelevellinear(bool value) { tuplelevellinear = value; } 00196 inline void setUsesEnvironment(bool value) { usesEnvironment = value; } 00198 inline void setFiniteFiber(bool value) { finiteFiber = value; } 00200 inline void addWellorderingStrlen(int index1, int index2) { wellorderingStrlen.insert(std::pair<int, int>(index1, index2)); } 00202 inline void addWellorderingNatural(int index1, int index2) { wellorderingNatural.insert(std::pair<int, int>(index1, index2)); } 00204 inline void setProvidesPartialAnswer(bool value) { providesPartialAnswer = value; } 00205 00210 bool isMonotonic() const; 00211 00216 bool isAntimonotonic() const; 00217 00222 bool isNonmonotonic() const; 00223 00229 bool isMonotonic(int parameterIndex) const 00230 { return monotonicInputPredicates.count(parameterIndex) > 0; } 00231 00237 bool isAntimonotonic(int parameterIndex) const 00238 { return antimonotonicInputPredicates.count(parameterIndex) > 0; } 00239 00245 bool isNonmonotonic(int parameterIndex) const 00246 { return !isMonotonic(parameterIndex) && !isAntimonotonic(parameterIndex); } 00247 00257 bool isFunctional() const 00258 { return functional; } 00259 00268 bool isLinearOnAtomLevel() const 00269 { return atomlevellinear; } 00270 00279 bool isLinearOnTupleLevel() const 00280 { return tuplelevellinear; } 00281 00287 bool isIndependentOfPredicateParameterName(int parameterIndex) const 00288 { return predicateParameterNameIndependence.count(parameterIndex) > 0; } 00289 00294 bool doesItUseEnvironment() const 00295 { return usesEnvironment; } 00296 00302 bool hasFiniteDomain(int outputElement) const 00303 { return finiteOutputDomain.count(outputElement) > 0; } 00304 00310 bool hasRelativeFiniteDomain(int outputElement, int inputElement) const 00311 { return relativeFiniteOutputDomain.count(std::pair<int, int>(outputElement, inputElement)) > 0; } 00312 00319 bool hasFiniteFiber() const 00320 { return finiteFiber; } 00321 00330 bool hasWellorderingStrlen(int from, int to) const 00331 { return wellorderingStrlen.count(std::pair<int, int>(from, to)) > 0; } 00332 00341 bool hasWellorderingNatural(int from, int to) const 00342 { return wellorderingNatural.count(std::pair<int, int>(from, to)) > 0; } 00343 00348 bool providesOnlySafeSupportSets() const 00349 { return onlySafeSupportSets; } 00350 00355 bool providesSupportSets() const 00356 { return supportSets; } 00357 00362 bool providesCompletePositiveSupportSets() const 00363 { return completePositiveSupportSets; } 00364 00369 bool providesCompleteNegativeSupportSets() const 00370 { return completeNegativeSupportSets; } 00371 00376 bool hasVariableOutputArity() const 00377 { return variableOutputArity; } 00378 00387 bool doesCareAboutAssigned() const 00388 { return caresAboutAssigned; } 00389 00398 bool doesCareAboutChanged() const 00399 { return caresAboutChanged; } 00400 00408 bool doesProvidePartialAnswer() const 00409 { return providesPartialAnswer; } 00410 00420 void interpretProperties(RegistryPtr reg, const ExternalAtom& atom, const std::vector<std::vector<std::string> >& props); 00421 }; 00422 00423 DLVHEX_NAMESPACE_END 00424 #endif 00425 00426 // vim:expandtab:ts=4:sw=4: 00427 // mode: C++ 00428 // End: