/*
 * 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.io.Serializable;


/**
 * Derivation nodes represent the application of a single clause (usually a rule) in a derivation.
 * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
 * @version 3.3.1 <9 August 2004>
 * @since 1.0
 */
public interface DerivationNode extends Serializable {

    // constant for the state of a derivation node    
    //@deprecated see getState()
    public final static byte UNKNOWN    = 0;
    public final static byte FAILED     = 1;
    public final static byte SUCCESS    = 2;
    public final static byte IRRELEVANT = 3;

    /**
     * Get the applied clause.
     * @return the applied clause
     */
    public Clause getAppliedClause();

    /**
     * Get the query (= goal).
     * @return the query
     */
    public Clause getQuery();

    /**
     * Get the state of the derivation node. I.e., basically whether this
     * derivation step has failed or not. Possible states are defined in
     * this interface by static variables. There is also a state indicating that
     * a derivation node is irrelevant, e.g. if a node is in a proof tree containing
     * derivations for many solutions but the structure is only considered in the
     * context of one special solution. Then a node successful w.r.t. one solutions
     * might be irrelevant w.r.t. another solution.
     * @deprecated the idea of this method was to figure out which results are supported 
     * by this node. This is now achieved by isSupported
     * @return the state of this node
     * @see #FAILED
     * @see #IRRELEVANT
     * @see #SUCCESS
     * @see #UNKNOWN
     */
    int getState();
    /**
     * Indicates whether the result at the given index is supported by this node. 
     * @param int resultNumber - the number of the result in the result set indexing starts with 0
     * @return boolean
     */
    boolean isSupported(int resultNumber);
    /**
     * Get an array of integers containing the indexes of all solutions supported.
     * @return an array of integer
     */
    int[] getSupportedResults();

    /**
     * Returns the sub nodes of this node.
     * @return the list of children (sub nodes)
     */
    java.util.List getSubNodes();

    /**
     * Get the unification.
     * @return the unification performed
     */
    public Unification getUnification();
    /**
	 * Indicates whether this derivation step has failed.
	 * @return true if this proof step has failed, false otherwise
	 */
	public boolean isFailed();
}
