Ejemplo n.º 1
0
	std::vector<Structure*> propagate(AbstractTheory* theory, Structure* structure) {
		// TODO: doens't work with cp support (because a.o.(?) backtranslation is not implemented)

		//Set MinisatID solver options
		auto data = SolverConnection::createsolver(0);

		auto clonetheory = theory->clone();
		auto result = structure->clone();
		auto voc = new Vocabulary("intern_voc");
		voc->add(clonetheory->vocabulary());
		result->changeVocabulary(voc);
		clonetheory->vocabulary(voc);

		auto grounding = GroundingInference<PCSolver>::doGrounding(clonetheory, result, NULL, NULL, NULL, true, data);

		auto mx = SolverConnection::initpropsolution(data);
		mx->execute();

		result->changeVocabulary(structure->vocabulary());

		auto translator = grounding->translator();
		auto entailed = mx->getEntailedLiterals();
		for (auto literal = entailed.cbegin(); literal < entailed.cend(); ++literal) {
			int atomnr = var(*literal);
			if (translator->isInputAtom(atomnr)) {
				auto symbol = translator->getSymbol(atomnr);
				auto args = translator->getArgs(atomnr);
				if (sign(*literal)) {
					result->inter(symbol)->makeFalseAtLeast(args);
				} else {
					result->inter(symbol)->makeTrueAtLeast(args);
				}
			}
		}
		result->clean();
		clonetheory->recursiveDelete();
		delete (voc);
		delete (data);
		delete (mx);

		if (not result->isConsistent()) {
			return std::vector<Structure*> { };
		}
		return {result};
	}
Ejemplo n.º 2
0
	const ElementTuple& getArgs(int atom) const {
		Assert(isInputAtom(atom) && atom2Tuple[atom]->first!=NULL);
		return atom2Tuple[atom]->second;
	}
Ejemplo n.º 3
0
	PFSymbol* getSymbol(int atom) const {
		Assert(isInputAtom(atom) && atom2Tuple[atom]->first!=NULL);
		return atom2Tuple[atom]->first;
	}