// $Id: Formula.java,v 1.5 2004/02/27 16:30:00 m31 Exp $
//
// This file is part of the program suite "Principia Mathematica II"
// which is a working prototype for the main project:
// "Hilbert II" - http://www.qedeq.org
//
// Copyright 2001-2004  Michael Meyling <mime@qedeq.org>.
//
// "Principia Mathematica II" is free software; you can redistribute
// it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program 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 General Public License for more details.

package com.meyling.principia.logic.basic;


import com.meyling.principia.argument.Argument;
import com.meyling.principia.argument.ArgumentException;
import com.meyling.principia.argument.Enumerator;


/**
 * This interface tells us about the methods a Formula must have.
 * @version $Revision: 1.5 $
 * @author  Michael Meyling
 */
public interface Formula extends Argument {

    /**
     * Get the number of part formulas that this formula contains.
     * @return number of part formulas that this formula is build of
     */
    public abstract int getPartFormulaSize();


    /**
     * Get the requested part formula
     * @param   i   number of part formula (starting with <code>0</code>)
     * @return  <code>i</code>-th part formula
     * @throws  IllegalArgumentException    if <code>i</code> is not inbetween
     *           <code>0</code> and <code>{@link #getPartFormulaSize} - 1</code>
     */
    public abstract Formula getPartFormula(int i) throws IllegalArgumentException;


    /**
     * Get all free subject variables.
     * @return  all free subject variables
     */
    public abstract SubjectVariables getFreeSubjectVariables();


    /**
     * Get all bounded subject variables.
     * @return  all bounded subject variables
     */
    public abstract SubjectVariables getBoundSubjectVariables();


    /**
     *  Get all subject variables that occur in this formula.
     *  @return  all subject variables
     */
    public abstract SubjectVariables getSubjectVariables();


    /**
     * Replace the <code>occurrence</code>-th occurence of a bound
     * {@link SubjectVariable} by another one.
     *
     * @param   counter         number of matches so far
     * @param   occurrence      number of matches to act on
     * @param   search          subject variable to look for
     * @param   replacement     replacement subject variable
     * @return  replaced formula
     * @throws  ArgumentException   if creating replacement failed
     */
    public abstract Formula replaceBoundSubjectVariable(Enumerator counter,
            int occurrence, SubjectVariable search,
            SubjectVariable replacement) throws ArgumentException;


    /**
     * Replace every bound SubjectVariable by a
     * BasicSubjectVariablePatternVariable
     *
     * @param   counter contains starting number for
     *     replacement pattern variable, is increased
     *     after one complete replacement
     * @throws  ArgumentException
     */
    public abstract Formula replaceBoundSubjectVariables(
        Enumerator counter)
        throws ArgumentException;



}
