71 for (
const auto &v : vec) {
72 result.insert(v.begin(), v.end());
79 if (vec.empty())
return one();
82 for (
size_t i = 1; i < vec.size(); ++i) {
84 for (
const auto &s1 : result) {
85 for (
const auto &s2 : vec[i]) {
87 combined.insert(s2.begin(), s2.end());
88 temp.insert(std::move(combined));
91 result = std::move(temp);
98 for (
auto const &s : y) {
105 return x.empty() ?
zero() : x;
137 single.insert(std::string(v));
139 result.insert(std::move(single));
143 const char *p = v + 1;
159 const char *start = p;
160 while(*p && *p !=
',' && *p !=
'}' && *p !=
'{')
164 witness.insert(std::string(start, p - start));
165 if(*p ==
',') { ++p;
continue; }
172 result.insert(std::move(witness));
187 std::ostringstream oss;
189 bool firstOuter =
true;
190 for (
const auto &inner : prov) {
191 if (!firstOuter) oss <<
",";
194 bool firstInner =
true;
195 for (
const auto &label : inner) {
196 if (!firstInner) oss <<
",";
Abstract semiring interface for provenance evaluation.
Exception thrown when a semiring operation is not supported.
Abstract base class for (m-)semirings.
why_provenance_t value_type
value_type one() const override
Return the multiplicative identity .
value_type times(const std::vector< value_type > &vec) const override
Apply the multiplicative operation to a list of values.
value_type plus(const std::vector< value_type > &vec) const override
Apply the additive operation to a list of values.
std::string to_text(const value_type &prov) const
virtual value_type monus(value_type x, value_type y) const override
Apply the monus (m-semiring difference) operation.
value_type zero() const override
Return the additive identity .
value_type parse_leaf(const char *v) const
Parse a leaf value into a why-provenance set-of-sets.
virtual bool compatibleWithBooleanRewrite() const override
No semiring homomorphism BoolFunc(Y) →+* Why exists, so the safe-query Boolean rewrite is unsound und...
value_type delta(value_type x) const override
Apply the operator.
std::set< label_t > label_set
A witness: a set of labels that collectively justify one derivation.
std::string label_t
A single label identifying a base tuple.
std::set< label_set > why_provenance_t
Why-provenance value: the full set of all witnesses.