Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.opencyc.inferencesupport
Class ConstraintRule

    java.lang.Object
      |
      +--org.opencyc.inferencesupport.Literal
            |
            +--org.opencyc.inferencesupport.ConstraintRule

All Implemented Interfaces:
  java.lang.Comparable

public class ConstraintRule
extends Literal
implements java.lang.Comparable

`ConstraintRule` object to model the attributes and behavior of a constraint rule.

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.

See Also:
  `UnitTest.testConstraintRule()`

Fields inherited from class org.opencyc.inferencesupport.Literal
`formula, nbrFormulaInstances, NO_SUBSUMPTION, SUBSUMED_BY, SUBSUMES, variables`

Constructor Summary
`ConstraintRule(CycList formula)` Constructs a new `ConstraintRule` object from a `CycList`.
`ConstraintRule(java.lang.String formulaString)` Constructs a new `ConstraintRule` object from a `CycList` `String` representation.

Method Summary
`java.lang.Object` | `clone()` Creates and returns a copy of this `ConstraintRule`.
`static boolean` | `evaluateConstraintRule(CycList instantiatedConstraintRule)` Evaluates the instantiated constraint rule locally without asking OpenCyc.
`ConstraintRule` | `instantiate(CycVariable cycVariable, java.lang.Object value)` Returns a new `ConstraintRule` which is the result of substituting the given `Object` value for the given `CycVariable`.
`boolean` | `isExtensionalVariableDomainPopulatingConstraintRule()` Returns `true` if this is an extensional variable domain populating `ConstraintRule`.
`boolean` | `isVariableDomainPopulatingRule()` Returns `true` if this is a variable domain populating `Rule`.
`static int` | `numericallyEvaluateExpression(java.lang.Object expression)` Returns the numerical value of the expression.
`static java.util.ArrayList` | `simplifyConstraintRuleExpression(CycList cycList)` Simplifies a rule expression.

Methods inherited from class org.opencyc.inferencesupport.Literal
`compareTo, cyclify, determineSubsumption, equals, gatherVariables, getArguments, getArity, getFormula, getPredicate, getVariables, hasEvaluatableNumericalArgs, hashCode, isAllDifferent, isEvaluatable, isGround, isIrreflexive, isSubsumedBy, isUnary, isValidConstraintRuleExpression, substituteVariable, subsumes, toString`

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

Methods inherited from interface java.lang.Comparable
`compareTo`

Constructor Detail

### ConstraintRule

    public ConstraintRule(java.lang.String formulaString)
                   throws CycApiException

  Constructs a new `ConstraintRule` object from a `CycList` `String` representation.

  Parameters:
    `formulaString` - the rule's formula `String`, which must be a well formed OpenCyc query represented by a `CycList`.

### ConstraintRule

    public ConstraintRule(CycList formula)

  Constructs a new `ConstraintRule` object from a `CycList`.

        String ruleAsString = "(#$isa ?x #$Cathedral)";
        ConstraintRule rule1 = new ConstraintRule (cycAccess.makeCycList(ruleAsString));

  Parameters:
    `formula` - the rule's formula, which must be a well formed OpenCyc query represented by a `CycList`.

Method Detail

### simplifyConstraintRuleExpression

    public static java.util.ArrayList simplifyConstraintRuleExpression(CycList cycList)
                                                                throws java.io.IOException

  Simplifies a rule expression.

  (#$and ( ... ) becomes ...

  Parameters:
    `cycList` - the rule expression that is simplified
  Returns:
    an `ArrayList` of `ConstraintRule` objects.
  See Also:
    `UnitTest.testConstraintRule()`

### clone

    public java.lang.Object clone()

  Creates and returns a copy of this `ConstraintRule`.
  Overrides:
    `clone` in class `java.lang.Object`
  Returns:
    a clone of this instance

### evaluateConstraintRule

    public static boolean evaluateConstraintRule(CycList instantiatedConstraintRule)
                                          throws java.io.IOException

  Evaluates the instantiated constraint rule locally without asking OpenCyc.
  Parameters:
    `instantiatedConstraintRule` - the fully instantiated constraint rule whose predicates can be evaluated locally without asking OpenCyc.
  Returns:
    the truth value of the fully instantiated constraint rule

### numericallyEvaluateExpression

    public static int numericallyEvaluateExpression(java.lang.Object expression)
                                             throws java.io.IOException

  Returns the numerical value of the expression.
  Parameters:
    `expression` - the expression to be evaluated which can be a `Integer` value, or a `CycList`
  Returns:
    the numerical value of the expression

### isVariableDomainPopulatingRule

    public boolean isVariableDomainPopulatingRule()
                                           throws java.io.IOException,
                                                  CycApiException

  Returns `true` if this is a variable domain populating `Rule`.
  Returns:
    `boolean` indicating if this is a variable domain populating `Rule`.

### isExtensionalVariableDomainPopulatingConstraintRule

    public boolean isExtensionalVariableDomainPopulatingConstraintRule()
                                                                throws java.io.IOException,
                                                                       CycApiException

  Returns `true` if this is an extensional variable domain populating `ConstraintRule`. An extensional rule is one in which all the values are listed.
  Returns:
    `boolean` indicating if this is an extensional variable domain populating `ConstraintRule`.

### instantiate

    public ConstraintRule instantiate(CycVariable cycVariable,
                                      java.lang.Object value)

  Returns a new `ConstraintRule` which is the result of substituting the given `Object` value for the given `CycVariable`.
  Parameters:
    `cycVariable` - the variable for substitution
    `value` - the value which is substituted for each occurrance of the variable
  Returns:
    a new `ConstraintRule` which is the result of substituting the given `Object` value for the given `CycVariable`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD