/** * ***************************************************************** * * @return true if a quantifiers in a quantifier list is not found in the body of the statement. */ private static boolean quantifierNotInStatement(Formula f) { if (f.theFormula == null || f.theFormula.length() < 1 || !f.listP() || f.empty()) return false; if (!Arrays.asList("forall", "exists").contains(f.car())) { Formula f1 = new Formula(); f1.read(f.car()); Formula f2 = new Formula(); f2.read(f.cdr()); return (quantifierNotInStatement(f1) || quantifierNotInStatement(f2)); } Formula form = new Formula(); form.read(f.theFormula); if (form.car() != null && form.car().length() > 0) { // This test shouldn't be needed. String rest = form.cdr(); // Quantifier list plus rest of statement Formula quant = new Formula(); quant.read(rest); String q = quant.car(); // Now just the quantifier list. String body = quant.cdr(); quant.read(q); ArrayList<String> qList = quant.argumentsToArrayList(0); // Put all the quantified variables into a list. if (rest.indexOf("exists") != -1 || rest.indexOf("forall") != -1) { // nested quantifiers Formula restForm = new Formula(); restForm.read(rest); restForm.read(restForm.cdr()); if (quantifierNotInStatement(restForm)) return true; } for (int i = 0; i < qList.size(); i++) { String var = (String) qList.get(i); if (body.indexOf(var) == -1) return true; } } return false; }