org.opencyc.constraintsolver
Class ArgumentTypeConstrainer

java.lang.Object
  |
  +--org.opencyc.constraintsolver.ArgumentTypeConstrainer

public class ArgumentTypeConstrainer
extends java.lang.Object

Provides argument type consistency checking for candidate backchaining rules, and also provides additional constraint rules derived from argument type constraints on the restricting constraint rules using the input constraint rules as a starting point. No additional rules are derived for domain populating rules because their purpose is not to restrict permitted variable bindings, but to populate the domains with values.

Argument type constraints are retrieved for candidate rules during backchaining. For variables mentioned in both the antecedant and consequent portions of the candidate backchain rule, the argument type constraints on these variables can rule out candidates for backchaining if associated collections are proven disjoint. The ArgumentTypeConstrainer provides the additional constraint rules as a preparation step before beginning the forward checking search for permitted bindings.

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.


Field Summary
protected  ConstraintProblem constraintProblem
          Reference to the parent ConstraintProblem object.
protected  int verbosity
          Sets verbosity of the constraint solver output.
 
Constructor Summary
ArgumentTypeConstrainer(ConstraintProblem constraintProblem)
          Constructs a new ArgumentTypeConstrainer object given the parent ConstraintProblem object.
 
Method Summary
protected  java.util.ArrayList gatherPredicateVariableArgConstaints(CycList expression)
          Returns the argument type constraint rules for the variables within the given expression.
 boolean isUnaryRuleConsistent(ConstraintRule unaryRule, CycVariable cycVariable)
          Returns true iff the given unary constraint rule is consistent with the previously accepted unary constraints on the given variable.
 java.util.ArrayList retrieveArgGenls(CycConstant predicate, int argPosition, CycVariable cycVariable)
          Retrieves the #$argGenl constraint rules for the given predicate at the given argument position, indexed base 1.
 java.util.ArrayList retrieveArgNIsas(CycConstant predicate, int argPosition, CycVariable cycVariable)
          Retrieves the #$argNIsa constraint rules for the given predicate at the given argument position, indexed base 1.
 java.util.ArrayList retrieveArgumentTypeConstraintRules(ConstraintRule rule)
          Retrieves the argument type constraint rules for the given rule.
 java.util.ArrayList retrieveArgumentTypeConstraintRules(CycConstant predicate, int argPosition, CycVariable cycVariable)
          Retrieves the argument type constraint rules for the given predicate at the given argument position, indexed base 1.
 void setVerbosity(int verbosity)
          Sets verbosity of the constraint solver output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

verbosity

protected int verbosity
Sets verbosity of the constraint solver output. 0 --> quiet ... 9 -> maximum diagnostic input.

constraintProblem

protected ConstraintProblem constraintProblem
Reference to the parent ConstraintProblem object.
Constructor Detail

ArgumentTypeConstrainer

public ArgumentTypeConstrainer(ConstraintProblem constraintProblem)
Constructs a new ArgumentTypeConstrainer object given the parent ConstraintProblem object.
Parameters:
constraintProblem - the parent constraint problem
Method Detail

retrieveArgumentTypeConstraintRules

public java.util.ArrayList retrieveArgumentTypeConstraintRules(ConstraintRule rule)
                                                        throws java.io.IOException,
                                                               CycApiException
Retrieves the argument type constraint rules for the given rule.
Parameters:
predicate - the CycConstant which is the predicate of a simple rule
argPosition - the argument position, indexed base 1, for which the argument type constraint rules are sought
cycVariable - the variable used to construct the returned rules
Returns:
the argument type constraint rules for the given rule

gatherPredicateVariableArgConstaints

protected java.util.ArrayList gatherPredicateVariableArgConstaints(CycList expression)
                                                            throws java.io.IOException,
                                                                   CycApiException
Returns the argument type constraint rules for the variables within the given expression.
Parameters:
expression - the expression which possibly contains variables
Returns:
the argument type constraint rules for the variables within the given expression

retrieveArgumentTypeConstraintRules

public java.util.ArrayList retrieveArgumentTypeConstraintRules(CycConstant predicate,
                                                               int argPosition,
                                                               CycVariable cycVariable)
                                                        throws java.io.IOException,
                                                               CycApiException
Retrieves the argument type constraint rules for the given predicate at the given argument position, indexed base 1.
Parameters:
predicate - the CycConstant which is the predicate of a simple rule
argPosition - the argument position, indexed base 1, for which the argument type constraint rules are sought
cycVariable - the variable used to construct the returned rules
Returns:
the argument type constraint rules for the predicate

retrieveArgNIsas

public java.util.ArrayList retrieveArgNIsas(CycConstant predicate,
                                            int argPosition,
                                            CycVariable cycVariable)
                                     throws java.io.IOException,
                                            CycApiException
Retrieves the #$argNIsa constraint rules for the given predicate at the given argument position, indexed base 1.
Parameters:
predicate - the CycConstant which is the predicate of a simple rule
argPosition - the argument position, indexed base 1, for which the argument type constraint rules are sought
cycVariable - the variable used to construct the returned rules
Returns:
the #$argNIsa constraint rules for the given predicate at the given argument position, indexed base 1

retrieveArgGenls

public java.util.ArrayList retrieveArgGenls(CycConstant predicate,
                                            int argPosition,
                                            CycVariable cycVariable)
                                     throws java.io.IOException,
                                            java.net.UnknownHostException,
                                            CycApiException
Retrieves the #$argGenl constraint rules for the given predicate at the given argument position, indexed base 1.
Parameters:
predicate - the CycConstant which is the predicate of a simple rule
argPosition - the argument position, indexed base 1, for which the argument type constraint rules are sought
cycVariable - the variable used to construct the returned rules
Returns:
the #$argNGenls constraint rules for the given predicate at the given argument position, indexed base 1

isUnaryRuleConsistent

public boolean isUnaryRuleConsistent(ConstraintRule unaryRule,
                                     CycVariable cycVariable)
                              throws java.io.IOException,
                                     CycApiException
Returns true iff the given unary constraint rule is consistent with the previously accepted unary constraints on the given variable. Consistency is determined by cases. If the unary constraint is of the form
(#$isa variable collection)
then the collection must not be disjoint from any other collections having the variable as an element. And in the case where the unary constraint is of the form
(#$genls variable collection)
then the collection must not be disjoint from any other collections have the variable as a spec.
Parameters:
unaryRule - the unary constraint rule whose consistency is in question
cycVariable - the variable to which the unary constraint is checked for consistency
Returns:
true iff the given unary constraint rule is consistent with the previously accepted unary constraints on the given variable

setVerbosity

public void setVerbosity(int verbosity)
Sets verbosity of the constraint solver output. 0 --> quiet ... 9 -> maximum diagnostic input.
Parameters:
verbosity - 0 --> quiet ... 9 -> maximum diagnostic input