01: /*
02: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package org.mandarax.kernel;
19:
20: import java.util.Collection;
21: import java.util.Vector;
22:
23: /**
24: * Represents the result of a unification comprising a collection containing the substitutions and
25: * the two unified terms with the replacements applied.
26: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
27: * @version 3.4 <7 March 05>
28: * @since 1.0
29: * Prova re-integration modifications
30: * @author <A HREF="mailto:a.kozlenkov@city.ac.uk">Alex Kozlenkov</A>
31: * @version 3.4 <7 March 05>
32: */
33: public final class Unification extends LObject {
34:
35: public Term[] terms1 = null;
36: public Term[] terms2 = null;
37: public Collection replacements = null;
38: public Collection replacementsLocal = null;
39: public static Unification noUnificationPossible = new Unification();
40:
41: /**
42: * Basic constructor.
43: */
44: private Unification() {
45: super ();
46: replacements = new Vector();
47: }
48:
49: /**
50: * Constructor.
51: * @param r a collection of replacements
52: * @param t1 the first array of terms
53: * @param t2 the second array of terms
54: */
55: public Unification(Collection r, Term[] t1, Term[] t2) {
56: super ();
57:
58: replacements = r;
59: terms1 = t1;
60: terms2 = t2;
61: }
62:
63: /**
64: * Constructor used in Prova.
65: * @param r a collection of replacements
66: * @param rLocal a collection of local replacements
67: * @param t1 the first array of terms
68: * @param t2 the second array of terms
69: */
70: public Unification(Collection r, Collection rLocal, Term[] t1,
71: Term[] t2) {
72: super ();
73:
74: replacements = r;
75: replacementsLocal = rLocal;
76: terms1 = t1;
77: terms2 = t2;
78: }
79:
80: /**
81: * Indicates whether unification has failed.
82: * @return true if the unification has failed, false otherwise
83: */
84: public boolean hasFailed() {
85: return Unification.noUnificationPossible == this;
86: }
87: }
|