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.JavaBlock;
14: import de.uka.ilkd.key.logic.PosInOccurrence;
15: import de.uka.ilkd.key.logic.Term;
16: import de.uka.ilkd.key.logic.TermFactory;
17: import de.uka.ilkd.key.logic.op.Operator;
18: import de.uka.ilkd.key.logic.op.QuantifiableVariable;
19: import de.uka.ilkd.key.proof.Goal;
20: import de.uka.ilkd.key.rule.RuleApp;
21:
22: /**
23: * Term projection for constructing a bigger term from a sequence of direct
24: * subterms and an operator.
25: *
26: * NB: this is a rather restricted version of term construction, one can think
27: * of also allowing bound variables, etc to be specified
28: */
29: public class TermConstructionProjection implements ProjectionToTerm {
30:
31: private final Operator op;
32: private final ProjectionToTerm[] subTerms;
33: private final QuantifiableVariable[] boundVars = new QuantifiableVariable[0];
34:
35: private TermConstructionProjection(Operator op,
36: ProjectionToTerm[] subTerms) {
37: this .op = op;
38: this .subTerms = subTerms;
39: assert op.arity() == subTerms.length;
40: }
41:
42: public static ProjectionToTerm create(Operator op,
43: ProjectionToTerm[] subTerms) {
44: return new TermConstructionProjection(op, subTerms);
45: }
46:
47: public Term toTerm(RuleApp app, PosInOccurrence pos, Goal goal) {
48: final Term[] subs = new Term[subTerms.length];
49: for (int i = 0; i != subTerms.length; ++i)
50: subs[i] = subTerms[i].toTerm(app, pos, goal);
51: return TermFactory.DEFAULT.createTerm(op, subs, boundVars,
52: JavaBlock.EMPTY_JAVABLOCK);
53: }
54:
55: }
|