|
JTP API Documentation | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jtp.fol.SubstUtils
Utility methods for use with instances of Substitutable
and
its subclasses.
Constructor Summary | |
SubstUtils()
|
Method Summary | |
static SubstitutableList |
createList(Collection args)
Returns instance of SubstitutableList that contains
elements of Collection args . |
static Clause |
deReferenceClause(Clause cl)
Returns a Clause based on cl in which Variables in
its literals '
arguments have been replaced by the values that they
are bound to. |
static Literal |
deReferenceLiteral(Literal inputLiteral)
Returns a Literal based on inputLiteral in which
Variables in its arguments have been replaced by the values
that they are bound to. |
static CNFSentence |
deReferenceSentence(CNFSentence s)
Returns a CNFSentence based on s in which Variables
in its clauses '
literals ' arguments have been replaced
by the values that they are bound to. |
static String |
print(Object o)
Printing method for sentences. |
static String |
printClause(Clause cl)
Printing method for Clauses. |
static String |
printCNFSentence(CNFSentence s)
Printing method for CNFSentences. |
static String |
printLiteral(Literal lit)
Printing method for Literals. |
static String |
printSymbol(Symbol sym)
Printing method for Symbols. |
static CNFSentence |
replaceVariables(CNFSentence s)
Replaces all Variables in a sentence. |
static Object |
replaceVariables(Unifyable u)
Replaces all Variables in a Unifyable. |
protected static Object |
substitute(Object o,
Map m)
If Object o is a key in mapping m ,
returns value that o is mapped to. |
static Literal |
substituteLiteral(Literal l,
Map m)
Uses mapping m to substitute arguments of
Literal l that are (or contain) keys of mapping
with values in mapping. |
static void |
unbindStack(List stack,
int sz)
Unbinds each variable in stack . |
static boolean |
unify(Object o1,
Object o2,
List varStack)
Attempts to make two Objects equal by unifying them if either Object is a Unifyable. |
static boolean |
variableIndependentEquals(CNFSentence s1,
CNFSentence s2)
Determines if two sentences are identical even though they contain different free variables. |
static int |
variableIndependentHashCode(CNFSentence s)
Hash code function for sentences that returns same value for arguments that are variableIndependentEquals . |
static Map |
variableStackToMap(List varStack,
Map m)
Given a List of Variable s, returns a Map in which
the keys are the Variables and the values are the Variables'
dereferenced
values. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SubstUtils()
Method Detail |
protected static Object substitute(Object o, Map m)
o
is a key in mapping m
,
returns value that o
is mapped to. If o
is a Substitutable, returns
substitution
of o
using m
. Otherwise, returns o
.
o
- Object to be substitutedm
- substitution mapping
public static Literal substituteLiteral(Literal l, Map m)
m
to substitute arguments of
Literal l
that are (or contain) keys of mapping
with values in mapping. Returns substituted Literal.
l
- Literal whose arguments are to be substitutedm
- substitution mapping
public static final SubstitutableList createList(Collection args)
SubstitutableList
that contains
elements of Collection args
. Order of elements
in returned list is same as order in which they are returned
by args
iterator.
args
- a Collection of elements
args
public static final void unbindStack(List stack, int sz)
Unbinds
each variable in stack
.
Assumes that all elements of stack
are
Variable
s.
stack
- List of Variablessz
- length of stack
public static String print(Object o)
o
- a Literal, Clause, or CNFSentence, or an Object or String that is a Literal argument
o
public static final String printClause(Clause cl)
cl
- a Clause
cl
public static final String printLiteral(Literal lit)
lit
- a Literal
lit
public static final String printCNFSentence(CNFSentence s)
s
- a CNFSentence
s
public static final String printSymbol(Symbol sym)
sym
- a Symbol
sym
public static final Literal deReferenceLiteral(Literal inputLiteral)
inputLiteral
in which
Variables in its arguments have been replaced by the values
that they are bound to.
inputLiteral
- a Literal optionally containing Unifyable
arguments
inputLiteral
.Variable
public static final Clause deReferenceClause(Clause cl)
cl
in which Variables in
its literals
'
arguments have been replaced by the values that they
are bound to.
cl
- a Clause
cl
.Variable
public static final CNFSentence deReferenceSentence(CNFSentence s)
s
in which Variables
in its clauses
'
literals
' arguments have been replaced
by the values that they are bound to.
s
- a CNFSentence
s
.Variable
public static Map variableStackToMap(List varStack, Map m)
Variable
s, returns a Map in which
the keys are the Variables and the values are the Variables'
dereferenced
values. If m
is
provided, uses and returns it. Otherwise, creates an
ArrayMap
or TreeMap
depending on the size
of varStack
.
This method is useful for for generating
bindings
for Proofs.
varStack
- a List of Variablesm
- the Map that the Variables and their values will be put in
varStack
and their valuespublic static Object replaceVariables(Unifyable u)
u
- a Unifyable that is to have its Variables replaced
u
with Variables replaced as described abovepublic static CNFSentence replaceVariables(CNFSentence s)
s
- a CNFSentence that is to have its Variables replaced
s
with Variables replaced as described abovepublic static boolean unify(Object o1, Object o2, List varStack)
equal
.
o1
- Object to unifyo2
- Object to unifyvarStack
- List in which Variables that are bound during this unification will be placed
public static boolean variableIndependentEquals(CNFSentence s1, CNFSentence s2)
(p ?x ?y)
and (p ?w ?z)
would be
considered identical, but (p A ?x)
and
(p B ?x)
are not identical.
s1
- CNFSentence for comparisons2
- CNFSentence for comparison
public static int variableIndependentHashCode(CNFSentence s)
variableIndependentEquals
.
s
- CNFSentence whose hash code is to be computed
|
JTP API Documentation | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |