/*
 * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package org.mandarax.kernel;


import java.util.Collection;
import java.util.Vector;

/**
 * Represents the result of a unification comprising a collection containing the substitutions and
 * the two unified terms with the replacements applied.
 * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
 * @version 3.3.1 <9 August 2004>
 * @since 1.0
 * Prova re-integration modifications
 * @author <A HREF="mailto:a.kozlenkov@city.ac.uk">Alex Kozlenkov</A>
 * @version 3.3.1 <9 August 2004>
 */
public final class Unification extends LObject {

    public Term[]             terms1                = null;
    public Term[]             terms2                = null;
    public Collection         replacements          = null;
	 public Collection         replacementsLocal     = null;
    public static Unification noUnificationPossible = new Unification ();

    /**
     * Basic constructor.
     */
    private Unification() {
        super ();
        replacements = new Vector();
    }

    /**
     * Constructor.
     * @param r a collection of replacements
     * @param t1 the first array of terms
     * @param t2 the second array of terms
     */
    public Unification(Collection r, Term[] t1, Term[] t2) {
        super ();

        replacements = r;
        terms1       = t1;
        terms2       = t2;
    }

    /**
     * Constructor used in Prova.
     * @param r a collection of replacements
	  * @param rLocal a collection of local replacements
     * @param t1 the first array of terms
     * @param t2 the second array of terms
     */
    public Unification(Collection r, Collection rLocal, Term[] t1, Term[] t2) {
        super ();

        replacements = r;
		  replacementsLocal = rLocal;
        terms1       = t1;
        terms2       = t2;
    }
    /**
     * Indicates whether unification has failed.
     * @return true if the unification has failed, false otherwise
     */
    public boolean hasFailed() {
        return Unification.noUnificationPossible == this;
    }
}
