/*
 * 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;


/**
 * Clauses are clauses in the prolog sense, i.e. usually either rules or facts
 * (= rules without body).
 * @see org.mandarax.kernel.Fact
 * @see org.mandarax.kernel.Rule
 * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
 * @version 3.3.1 <9 August 2004>
 * @since 1.0
 * Prova re-integration
 * @author <A HREF="mailto:a.kozlenkov@city.ac.uk">Alex Kozlenkov</A>
 * @version 3.3.1 <9 August 2004>
 */
public interface Clause extends ClauseSet, SemanticsSupport {

    /**
     * Apply a set of replacements to a clause. Returns a new clause!
     * @see org.mandarax.kernel.Replacement
     * @return the resulting clause
     * @param r the set of replacements
     */
    public Clause apply(java.util.Collection r);

    /**
     * Apply a single replacement to a clause.
     * @see org.mandarax.kernel.Fact
     * @return the resulting clause
     * @param r the replacement
     */
    public Clause apply(Replacement r);

    /**
     * Get the clause set containing the clause. This method is in particular useful for analyzing derivations,
     * since derivations show only the clauses used, not the clause set generating this clauses (e.g., AutoFacts). On the other
     * hand, knowledge bases contain often clause sets. So it could be hard to find the clause sets in the knowledge base
     * that caused a certain result. For sme clauses such as facts, the container is just the fact itself.
     * @return a clause set
     */
    ClauseSet getContainer();

    /**
     * Get the negative literals.
     * @return the list of negative literals
     */
    java.util.List getNegativeLiterals();

    /**
     * Get the positive literals.
     * @return the list of positive literals
     */
    java.util.List getPositiveLiterals();

	 /**
	  * Whether the head contains variables
	  * @return boolean
	  */
	 boolean isBound();

    /**
     * Indicates whether the clause is atomic, or is a real clause set containing other clauses.
     * The main motivation for introducing this method are rules with prerequisites connected by OR.
     * This rules are clauses, but they can also be seen as clause sets: A or B implies C is a clause set
     * containing the two rules A implies C and B implies C.
     * @return a boolean
     */
    boolean isAtomic();

    /**
     * Indicates whether the clause is the empty clause.
     * @return true if this is an empty clause, false otherwise
     */
    boolean isEmpty();

    /**
     * Set a container.
     * @param aContainerthe new container
     */
    void setContainer(ClauseSet aContainer);
}
