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.ConstrainedFormula;
14: import de.uka.ilkd.key.logic.PosInOccurrence;
15: import de.uka.ilkd.key.proof.Goal;
16: import de.uka.ilkd.key.rule.IfFormulaInstSeq;
17: import de.uka.ilkd.key.rule.IteratorOfIfFormulaInstantiation;
18: import de.uka.ilkd.key.rule.ListOfIfFormulaInstantiation;
19: import de.uka.ilkd.key.rule.TacletApp;
20:
21: /**
22: * Binary feature that returns zero iff the <tt>\assumes</tt>- and find-formula
23: * of a Taclet are matched to different members of the sequent. If a taclet has
24: * more than one formula in its <tt>\assumes</tt> part, all of the must be matched
25: * to different members.
26: */
27: public class DiffFindAndIfFeature extends BinaryTacletAppFeature {
28:
29: /** the single instance of this feature */
30: public static final Feature INSTANCE = new DiffFindAndIfFeature();
31:
32: private DiffFindAndIfFeature() {
33: }
34:
35: protected boolean filter(TacletApp app, PosInOccurrence pos,
36: Goal goal) {
37: assert pos != null : "Feature is only applicable to rules with find";
38:
39: ListOfIfFormulaInstantiation list = app
40: .ifFormulaInstantiations();
41:
42: assert list != null;
43:
44: final IteratorOfIfFormulaInstantiation it = list.iterator();
45: while (it.hasNext()) {
46: final IfFormulaInstSeq iffi = (IfFormulaInstSeq) it.next();
47: assert iffi != null;
48: final ConstrainedFormula findFormula = pos
49: .constrainedFormula();
50: final ConstrainedFormula ifFormula = iffi
51: .getConstrainedFormula();
52:
53: final boolean result = pos.isInAntec() != iffi.inAntec()
54: || !findFormula.equals(ifFormula);
55: if (!result) {
56: return false;
57: }
58: }
59: return true;
60: }
61:
62: }
|