## org.opencyc.inferencesupport
Class HornClause

    java.lang.Object
      |
      +--org.opencyc.inferencesupport.HornClause

public class HornClause
extends java.lang.Object

Provides attribute and behavior for a horn clause assertion, used during backchaining inference. Horn clauses are the result of OpenCyc's canonicalization of implication assertions and consist of two parts, both of which are logical formulae. The first part is the antecedant and the second part is the consequent. Backchaining inference employs horn clauses when seeking to prove a logical formula. If the formula can be unified with the consequent of a horn clause, then the search for a proof can be transformed into a search for a proof of the logical formulae which constitute the horn clause antecedant. This logical inference step in a proof is named modus ponens.

Author:
  Stephen L. Reed

  Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.

  the license

  www.opencyc.org

  OpenCyc at SourceForge

  THIS SOFTWARE AND KNOWLEDGE BASE CONTENT ARE PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENCYC ORGANIZATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE AND KNOWLEDGE BASE CONTENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Constructor Summary
`HornClause()` Constructs a new (empty) `HornClause` object.
`HornClause(java.util.ArrayList antecedantConjuncts, QueryLiteral consequent)` Constructs a new `HornClause` object from the given antecedant conjuncts and consequent.
`HornClause(CycList hornClause)` Constructs a new `HornClause` object from the given `CycList` representation.
`HornClause(Literal rule)` Constructs a new `HornClause` object from the given implication `ConstraintRule`.
`HornClause(java.lang.String hornClauseString)` Constructs a new `HornClause` object from the given cyclified string representation.

Method Summary
`java.lang.Object` `clone()` Creates and returns a copy of this `QueryLiteral` suitable for mutation.
`protected java.lang.String` `cyclify()` Returns the cyclified string representation of the `HornClause`.
`boolean` `equals(java.lang.Object object)` Returns `true` if the object equals this object.
`protected void` `gatherVariables()` Gathers the variables used in the antecedant conjuncts and in the consequent of the horn clause.
`java.util.ArrayList` `getAntecedantConjuncts()` Returns the antecedant conjuncts for this horn clause.
`QueryLiteral` `getConsequent()` Returns the consequent for this horn clause.
`java.util.ArrayList` `getVariables()` Returns the variables for this horn clause.
`static boolean` `isValidHornExpression(CycList cycList)` Returns `true` iff the given `CycList` is a valid representation of a constraint horn clause.
`static boolean` `isValidHornExpression(java.lang.String string)` Returns `true` iff the given `CycList` is a valid representation of a constraint horn clause.
`void` `renameVariables(java.util.ArrayList otherVariables, int verbosity)` Renames variables that occur in the given list of other variables.
`boolean` `substituteVariable(CycVariable variable, java.lang.Object newObject, int verbosity)` Substitutes an object for a variable, returning `true` iff all argument type constraints are satisfied, otherwise `false` is returned at the point where the argument type conflict is found.
`java.lang.String` `toString()` Returns the string representation of the `HornClause`.

Methods inherited from class java.lang.Object
`finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### HornClause

    public HornClause()

  Constructs a new (empty) `HornClause` object.

### HornClause

    public HornClause(java.util.ArrayList antecedantConjuncts,
                      QueryLiteral consequent)

  Constructs a new `HornClause` object from the given antecedant conjuncts and consequent.

### HornClause

    public HornClause(Literal rule)

  Constructs a new `HornClause` object from the given implication `ConstraintRule`.
  Parameters:
    `rule` - the given implication `ConstraintRule`

### HornClause

    public HornClause(java.lang.String hornClauseString)
               throws CycApiException

  Constructs a new `HornClause` object from the given cyclified string representation.
  Parameters:
    `hornClauseString` - the cyclified string representation of the horn clause

### HornClause

    public HornClause(CycList hornClause)

  Constructs a new `HornClause` object from the given `CycList` representation.
  Parameters:
    `cycList` - the `CycList` representation of the horn clause

Method Detail

### getAntecedantConjuncts

    public java.util.ArrayList getAntecedantConjuncts()

  Returns the antecedant conjuncts for this horn clause.
  Returns:
    the antecedant conjuncts for this horn clause

### getConsequent

    public QueryLiteral getConsequent()

  Returns the consequent for this horn clause.
  Returns:
    the consequent for this horn clause

### getVariables

    public java.util.ArrayList getVariables()

  Returns the variables for this horn clause.
  Returns:
    the variables for this horn clause

### gatherVariables

    protected void gatherVariables()

  Gathers the variables used in the antecedant conjuncts and in the consequent of the horn clause.

### renameVariables

    public void renameVariables(java.util.ArrayList otherVariables,
                                int verbosity)
                         throws java.io.IOException,
                                CycApiException

  Renames variables that occur in the given list of other variables.
  Parameters:
    `otherVariables` - the other variables with whom this horn clause will have no variables in common
    `verbosity` - a verbosity indicator, 0 = quiet ... 9 = most diagnostic output

### substituteVariable

    public boolean substituteVariable(CycVariable variable,
                                      java.lang.Object newObject,
                                      int verbosity)
                               throws java.io.IOException,
                                      CycApiException

  Substitutes an object for a variable, returning `true` iff all argument type constraints are satisfied, otherwise `false` is returned at the point where the argument type conflict is found.
  Parameters:
    `oldVariable` - the variable to replaced
    `verbosity` - a verbosity indicator, 0 = quiet ... 9 = most diagnostic output
  Returns:
    `true` iff all argument type constraints are satisfied, otherwise `false` is returned at the point where the argument type conflict is found

### equals

    public boolean equals(java.lang.Object object)

  Returns `true` if the object equals this object.
  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `object` - the object for comparison
  Returns:
    `boolean` indicating equality of an object with this object.

### clone

    public java.lang.Object clone()

  Creates and returns a copy of this `QueryLiteral` suitable for mutation.
  Overrides:
    `clone` in class `java.lang.Object`
  Returns:
    a clone of this instance

### toString

    public java.lang.String toString()

  Returns the string representation of the `HornClause`.
  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    the string representation of the `HornClause`

### cyclify

    protected java.lang.String cyclify()

  Returns the cyclified string representation of the `HornClause`. Embedded constants are prefixed with ""#$".
  Returns:
    the cyclified string representation of the `HornClause`

### isValidHornExpression

    public static boolean isValidHornExpression(java.lang.String string)
                                         throws java.io.IOException,
                                                CycApiException

  Returns `true` iff the given `CycList` is a valid representation of a constraint horn clause. Specifically, an expression is not a valid constraint horn clause if any predicate is not a `CycConstant` object.
  Parameters:
    `string` - the representation of a constraint horn clause to be validated
  Returns:
    `true` iff the given `CycList` is a valid representation of a constraint horn clause

### isValidHornExpression

    public static boolean isValidHornExpression(CycList cycList)
                                         throws java.io.IOException,
                                                CycApiException

  Returns `true` iff the given `CycList` is a valid representation of a constraint horn clause. Specifically, an expression is not a valid constraint horn clause if any predicate is not a `CycConstant` object.
  Parameters:
    `cycList` - the representation of a constraint horn clause to be validated
  Returns:
    `true` iff the given `CycList` is a valid representation of a constraint horn clause