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.java.Services;
14: import de.uka.ilkd.key.logic.PosInOccurrence;
15: import de.uka.ilkd.key.logic.Term;
16: import de.uka.ilkd.key.proof.Goal;
17: import de.uka.ilkd.key.rule.RuleApp;
18: import de.uka.ilkd.key.rule.metaconstruct.arith.Monomial;
19:
20: /**
21: * Projection for dividing one monomial by another.
22: */
23: public class ReduceMonomialsProjection implements ProjectionToTerm {
24:
25: private final ProjectionToTerm dividend, divisor;
26:
27: private ReduceMonomialsProjection(ProjectionToTerm dividend,
28: ProjectionToTerm divisor) {
29: this .dividend = dividend;
30: this .divisor = divisor;
31: }
32:
33: public static ProjectionToTerm create(ProjectionToTerm dividend,
34: ProjectionToTerm divisor) {
35: return new ReduceMonomialsProjection(dividend, divisor);
36: }
37:
38: public Term toTerm(RuleApp app, PosInOccurrence pos, Goal goal) {
39: final Term dividendT = dividend.toTerm(app, pos, goal);
40: final Term divisorT = divisor.toTerm(app, pos, goal);
41:
42: final Services services = goal.proof().getServices();
43: final Monomial mDividend = Monomial.create(dividendT, services);
44: final Monomial mDivisor = Monomial.create(divisorT, services);
45:
46: return mDivisor.reduce(mDividend).toTerm(services);
47: }
48: }
|