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.termProjection;
12:
13: import de.uka.ilkd.key.logic.PosInOccurrence;
14: import de.uka.ilkd.key.logic.Term;
15: import de.uka.ilkd.key.proof.Goal;
16: import de.uka.ilkd.key.rule.RuleApp;
17:
18: /**
19: * Projection of a rule application to its focus (the term or formula that the
20: * rule operates on, that for taclets is described using <code>\find</code>,
21: * and that can be modified by the rule). Optionally, the projection can walk
22: * "upwards" towards the root of the term/formula
23: */
24: public class FocusProjection implements ProjectionToTerm {
25:
26: private final int stepsUpwards;
27:
28: private FocusProjection(int stepsUpwards) {
29: assert stepsUpwards >= 0;
30: this .stepsUpwards = stepsUpwards;
31: }
32:
33: public static ProjectionToTerm create(int stepsUpwards) {
34: return new FocusProjection(stepsUpwards);
35: }
36:
37: public Term toTerm(RuleApp app, PosInOccurrence pos, Goal goal) {
38: assert pos != null : "Projection is only applicable to rules with find";
39:
40: int n = stepsUpwards;
41: while (n-- > 0) {
42: pos = pos.up();
43: }
44:
45: return pos.subTerm();
46: }
47:
48: }
|