public Set<String> getRulesToDerive(Set<Literal> literals) {
		Set<Literal> literalsChecked = new TreeSet<Literal>();
		Set<Literal> literalsToCheck = new TreeSet<Literal>();
		Set<Literal> literalsToAdd = new TreeSet<Literal>();
		Set<String> rulesExtracted = new TreeSet<String>();

		literalsToAdd.addAll(getLiteralsToCheck(literals));

		do {
			literalsChecked.addAll(literalsToAdd);
			literalsToCheck.addAll(literalsToAdd);
			literalsToAdd.clear();
			for (Literal literalToCheck : literalsToCheck) {
				for (Rule rule : getRulesWithHead(literalToCheck)) {
					if (!rulesExtracted.contains(rule.getLabel())) {
						rulesExtracted.add(rule.getLabel());
						for (Literal bodyLiteral : rule.getBodyLiterals()) {
							if (!literalsToAdd.contains(bodyLiteral)) {
								literalsToAdd.addAll(getLiteralsToCheck(bodyLiteral));
							}
						}
					}
				}
			}
		} while (literalsToAdd.size() > 0);

		return rulesExtracted;
	}