01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: package de.uka.ilkd.key.strategy.feature;
12:
13: import de.uka.ilkd.key.logic.PIOPathIterator;
14: import de.uka.ilkd.key.logic.PosInOccurrence;
15: import de.uka.ilkd.key.logic.Term;
16: import de.uka.ilkd.key.logic.op.Operator;
17: import de.uka.ilkd.key.logic.op.Quantifier;
18: import de.uka.ilkd.key.proof.Goal;
19: import de.uka.ilkd.key.rule.RuleApp;
20: import de.uka.ilkd.key.util.Debug;
21:
22: /**
23: * Binary feature that returns zero iff the position of the given rule app is
24: * not within the scope of a quantifier
25: */
26: public class NotBelowQuantifierFeature extends BinaryFeature {
27:
28: public static final Feature INSTANCE = new NotBelowQuantifierFeature();
29:
30: private NotBelowQuantifierFeature() {
31: }
32:
33: public boolean filter(RuleApp app, PosInOccurrence pos, Goal goal) {
34: Debug.assertFalse(pos == null,
35: "Feature is only applicable to rules with find");
36:
37: return !belowQuantifier(pos);
38: }
39:
40: /**
41: * @return true iff the given position is in the scope of a quantifier
42: */
43: private boolean belowQuantifier(PosInOccurrence pos) {
44: final PIOPathIterator it = pos.iterator();
45:
46: while (it.next() != -1) {
47: final Term t = it.getSubTerm();
48: final Operator op = t.op();
49:
50: if (op instanceof Quantifier)
51: return true;
52: }
53:
54: return false;
55: }
56:
57: }
|