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: package de.uka.ilkd.key.strategy.feature;
09:
10: import de.uka.ilkd.key.logic.IteratorOfConstrainedFormula;
11: import de.uka.ilkd.key.logic.PosInOccurrence;
12: import de.uka.ilkd.key.proof.Goal;
13: import de.uka.ilkd.key.rule.RuleApp;
14: import de.uka.ilkd.key.strategy.termfeature.BinaryTermFeature;
15: import de.uka.ilkd.key.strategy.termfeature.ContainsExecutableCodeTermFeature;
16: import de.uka.ilkd.key.strategy.termfeature.TermFeature;
17:
18: public class SeqContainsExecutableCodeFeature extends BinaryFeature {
19:
20: private final TermFeature tf;
21:
22: private SeqContainsExecutableCodeFeature(boolean considerQueries) {
23: if (considerQueries)
24: tf = ContainsExecutableCodeTermFeature.PROGRAMS_OR_QUERIES;
25: else
26: tf = ContainsExecutableCodeTermFeature.PROGRAMS;
27: }
28:
29: public final static Feature PROGRAMS = new SeqContainsExecutableCodeFeature(
30: false);
31: public final static Feature PROGRAMS_OR_QUERIES = new SeqContainsExecutableCodeFeature(
32: true);
33:
34: protected boolean filter(RuleApp app, PosInOccurrence pos, Goal goal) {
35: return containsExec(goal.sequent().succedent().iterator())
36: || containsExec(goal.sequent().antecedent().iterator());
37: }
38:
39: private boolean containsExec(IteratorOfConstrainedFormula it) {
40: while (it.hasNext()) {
41: if (tf.compute(it.next().formula()).equals(
42: BinaryTermFeature.ZERO_COST))
43: return true;
44: }
45: return false;
46: }
47: }
|