public class FormulaPreprocessor
extends java.lang.Object
Constructor and Description |
---|
FormulaPreprocessor() |
Modifier and Type | Method and Description |
---|---|
Formula |
addTypeRestrictions(Formula form,
KB kb)
Add clauses for every variable in the antecedent to restrict its
type to the type restrictions defined on every relation in which
it appears.
|
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> |
computeVariableTypes(Formula form,
KB kb)
This method returns a HashMap that maps each String variable in
this the names of types (classes) of which the variable must be
an instance or the names of types of which the variable must be
a subclass.
|
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> |
computeVariableTypesRecurse(KB kb,
Formula f,
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> input) |
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> |
findExplicitTypes(Formula form)
Collect variable names and their types from instance or subclass
expressions.
|
void |
findExplicitTypesClasses(Formula form,
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> varExplicitTypes,
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> varExplicitClasses)
Collect variable names and their types from instance or subclass
expressions.
|
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> |
findExplicitTypesClassesInAntecedent(Formula form)
Collect the types of any variables that are specifically defined
in the antecedent of a rule with an instance expression;
Collect the super classes of any variables that are specifically
defined in the antecedent of a rule with an subclass expression;
|
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> |
findExplicitTypesInAntecedent(Formula form)
Collect the types of any variables that are specifically defined
in the antecedent of a rule with an instance or subclass expression.
|
static void |
findExplicitTypesRecurse(Formula form,
boolean isNegativeLiteral,
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> varExplicitTypes,
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> varExplicitClasses)
Recursively collect a variable name and its types.
|
static java.lang.String |
findType(int numarg,
java.lang.String pred,
KB kb)
Find the argument type restriction for a given predicate and
argument number that is inherited from one of its super-relations.
|
protected java.lang.String |
getMostRelevantType(KB kb,
java.util.HashSet<java.lang.String> types)
Get the most specific type for variables.
|
static void |
main(java.lang.String[] args) |
java.util.ArrayList<Formula> |
preProcess(Formula form,
boolean isQuery,
KB kb)
Pre-process a formula before sending it to the theorem prover.
|
static void |
testAddTypes() |
static void |
testFindExplicit() |
static void |
testFindTypes() |
void |
winnowTypeList(java.util.HashSet<java.lang.String> types,
KB kb)
This method tries to remove all but the most specific relevant
classes from a List of sortal classes.
|
public static java.lang.String findType(int numarg, java.lang.String pred, KB kb)
public void winnowTypeList(java.util.HashSet<java.lang.String> types, KB kb)
types
- A List of classes (class name Strings) that
constrain the value of a SUO-KIF variable.kb
- The KB used to determine if any of the classes in the
List types are redundant.public Formula addTypeRestrictions(Formula form, KB kb)
protected java.lang.String getMostRelevantType(KB kb, java.util.HashSet<java.lang.String> types)
kb
- The KB to be used for processingtypes
- a list of sumo types for a sumo term/variablepublic java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> findExplicitTypesInAntecedent(Formula form)
public java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> findExplicitTypesClassesInAntecedent(Formula form)
public java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> findExplicitTypes(Formula form)
form
- The formula in KIF syntaxpublic void findExplicitTypesClasses(Formula form, java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> varExplicitTypes, java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> varExplicitClasses)
form
- The formula in KIF syntaxvarExplicitTypes
- A map of variables paired with sumo types
collected from instance expressionsvarExplicitClasses
- A map of variables paired with sumo types
collected from subclass expressionpublic static void findExplicitTypesRecurse(Formula form, boolean isNegativeLiteral, java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> varExplicitTypes, java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> varExplicitClasses)
public java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> computeVariableTypes(Formula form, KB kb)
kb
- The KB to be used to compute the sortal constraints
for each variable.public java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> computeVariableTypesRecurse(KB kb, Formula f, java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> input)
public java.util.ArrayList<Formula> preProcess(Formula form, boolean isQuery, KB kb)
isQuery
- If true the Formula is a query and should be
existentially quantified, else the Formula is a
statement and should be universally quantifiedkb
- The KB to be used for processing this Formulapublic static void testFindTypes()
public static void testFindExplicit()
public static void testAddTypes()
public static void main(java.lang.String[] args)