Beispiel #1
0
	void visit(const PredTable* table) {
		Assert(isTheoryOpen());
		if (not table->finite()) {
			std::clog << "Requested to print infinite table, did not do this.\n";
		}
		TableIterator kt = table->begin();
		if (table->arity() > 0) {
			output() << "{ ";
			if (not kt.isAtEnd()) {
				bool beginlist = true;
				for (; not kt.isAtEnd(); ++kt) {
					CHECKTERMINATION;
					if (not beginlist) {
						output() << "; ";
					}
					beginlist = false;
					ElementTuple tuple = *kt;
					bool begintuple = true;
					for (auto lt = tuple.cbegin(); lt != tuple.cend(); ++lt) {
						if (not begintuple) {
							output() << ',';
						}
						begintuple = false;
						output() << print(*lt);
					}
				}
			}
			output() << " }";
		} else if (not kt.isAtEnd()) {
			output() << "{()}";
		} else {
			output() << "{}";
		}
	}
FOPropTableDomain* FOPropTableDomainFactory::exists(FOPropTableDomain* domain, const varset& sv) const {
	vector<bool> keepcol;
	vector<Variable*> newvars;
	vector<SortTable*> newunivcols;
	for (unsigned int n = 0; n < domain->vars().size(); ++n) {
		Variable* v = domain->vars()[n];
		if (sv.find(v) == sv.cend()) {
			keepcol.push_back(true);
			newvars.push_back(v);
			newunivcols.push_back(domain->table()->universe().tables()[n]);
		} else {
			keepcol.push_back(false);
		}
	}

	if (not domain->table()->approxFinite()) {
		clog << "Probably entering an infinite loop when trying to project a possibly infinite table...\n";
	}
	PredTable* npt = new PredTable(new EnumeratedInternalPredTable(), Universe(newunivcols));
	for (TableIterator it = domain->table()->begin(); not it.isAtEnd(); ++it) {
		const ElementTuple& tuple = *it;
		ElementTuple newtuple;
		for (size_t n = 0; n < tuple.size(); ++n) {
			if (keepcol[n]) {
				newtuple.push_back(tuple[n]);
			}
		}
		npt->add(newtuple);
	}

	return new FOPropTableDomain(npt, newvars);
}
Beispiel #3
0
	void visit(FuncTable* table) {
		Assert(isTheoryOpen());
		std::vector<SortTable*> vst = table->universe().tables();
		vst.pop_back();
		Universe univ(vst);
		if (univ.approxFinite()) {
			TableIterator kt = table->begin();
			if (table->arity() != 0) {
				output() << "{ ";
				if (not kt.isAtEnd()) {
					ElementTuple tuple = *kt;
					output() << print(tuple[0]);
					for (unsigned int n = 1; n < tuple.size() - 1; ++n) {
						output() << ',' << print(tuple[n]);
					}
					output() << "->" << print(tuple.back());
					++kt;
					for (; not kt.isAtEnd(); ++kt) {
						CHECKTERMINATION;
						output() << "; ";
						tuple = *kt;
						output() << print(tuple[0]);
						for (unsigned int n = 1; n < tuple.size() - 1; ++n) {
							output() << ',' << print(tuple[n]);
						}
						output() << "->" << print(tuple.back());
					}
				}
				output() << " }";
			} else if (not kt.isAtEnd()) {
				output() << print((*kt)[0]);
			} else {
				output() << "{ }";
			}
		} else {
			output() << "possibly infinite table";
		}
	}