public abstract class LiteralAbstract1 extends Argument
Predicate
and an ArrayListModifier and Type | Field and Description |
---|---|
static java.lang.String[] |
argCodes |
java.util.ArrayList<java.lang.Object> |
args |
static java.lang.String[] |
cancellingPredsA |
static java.lang.String[] |
cancellingPredsB |
static java.util.ArrayList<java.lang.Object> |
cancelPredsA |
static java.util.ArrayList<java.lang.Object> |
cancelPredsB |
static int |
debugSerial |
static int |
expansionSerial |
static java.lang.String |
failReason |
static java.lang.String[] |
generalPreds |
static java.util.ArrayList<java.lang.Object> |
genPreds |
static boolean |
negativeConstraintPhase |
static java.util.ArrayList<java.lang.Object> |
oppoPredsA |
static java.util.ArrayList<java.lang.Object> |
oppoPredsB |
static java.lang.String[] |
oppositePredsA |
static java.lang.String[] |
oppositePredsB |
Predicate |
predicate |
static java.lang.String |
stdAlter |
static java.lang.String |
stdEgo |
Constructor and Description |
---|
LiteralAbstract1() |
Modifier and Type | Method and Description |
---|---|
static void |
apply(Literal lit)
Apply this constraint-predicate by installing the constraints on the arguments.
|
int |
computeLevel(java.lang.String pcStr) |
boolean |
constraintCheck(java.lang.String egoGender,
ConstraintObj constraints,
java.util.ArrayList<java.lang.Object> genderStuff,
java.util.ArrayList<java.lang.Object> starStuff)
Begin (or add to) the extraction of gender, equality etc constraints.
|
boolean |
constraintPred(Literal lit) |
boolean |
containsAll(java.util.ArrayList list1,
java.util.ArrayList list2) |
Argument |
copy()
Make a copy of this Literal, containing a list of copies of its args.
|
void |
countArgs(java.util.ArrayList<java.lang.Object> firstMention,
java.util.ArrayList<java.lang.Object> otherMentions) |
void |
expand(Context hypo,
java.util.ArrayList<java.lang.Object> clauseSoFar,
java.util.ArrayList<java.lang.Object> remainingLits,
java.util.ArrayList<java.lang.Object> expandedDefs,
java.util.ArrayList<java.lang.Object> save4Last,
StackMarkerObj marker,
ClauseBody origCB,
java.util.ArrayList<java.lang.Object> path)
Expand this literal into the (multiple) primitive clause(s) which it represents.
|
static boolean |
finalConstraintCheck(java.lang.String egoGender,
java.util.TreeMap bindings,
ConstraintObj constraints,
java.util.ArrayList<java.lang.Object> body,
java.util.ArrayList<java.lang.Object> genderStuff,
java.util.ArrayList<java.lang.Object> starStuff)
Perform a final review of the constraints extracted from a ClauseBody of Literals, with emphasis on gender constraints.
|
void |
finishExpansion(Context hypo,
java.util.ArrayList<java.lang.Object> clauseSoFar,
ClauseBody origCB,
java.util.ArrayList<java.lang.Object> expandedDefs,
java.util.ArrayList<java.lang.Object> save4Last,
java.util.ArrayList<java.lang.Object> path) |
static void |
genderInferences(ConstraintObj constraints,
java.util.ArrayList<java.lang.Object> body) |
boolean |
isEquivalent(Literal other)
Any other Literal is equivalent to this one if the predicate names match, the arg lists are the same
length, and each arg is of the same type and has the same name.
|
java.util.ArrayList<java.lang.Object> |
lits2MiniStrings(java.util.ArrayList<java.lang.Object> clauseSoFar) |
Literal |
mergeWith(Literal lit2) |
void |
neg_expand(Context hypo,
java.util.ArrayList<java.lang.Object> save4Last,
java.util.ArrayList<java.lang.Object> expNegConstraints,
ClauseBody origCB,
java.util.ArrayList<java.lang.Object> subPaths)
Expand the negated predicates (e.g.
|
static java.util.ArrayList<java.lang.Object> |
setClosureOf(java.lang.String arg1,
java.util.ArrayList<java.lang.Object> listOne,
java.util.ArrayList<java.lang.Object> closureSoFar,
java.util.TreeMap assoc)
Produce the set-closure of nodes which can be reached from
listOne , a starting list of nodes. |
java.lang.String |
toString()
Make a string that replicates the form of this Literal when it was
parsed.
|
abstract void |
updatePath(java.util.ArrayList<java.lang.Object> path,
java.util.ArrayList<java.lang.Object> pathCopy) |
public static java.lang.String failReason
public static boolean negativeConstraintPhase
public static int expansionSerial
public static int debugSerial
public static final java.lang.String stdEgo
public static final java.lang.String stdAlter
public static final java.lang.String[] argCodes
public static final java.lang.String[] cancellingPredsA
public static final java.lang.String[] cancellingPredsB
public static final java.lang.String[] oppositePredsA
public static final java.lang.String[] oppositePredsB
public static final java.lang.String[] generalPreds
public static java.util.ArrayList<java.lang.Object> cancelPredsA
public static java.util.ArrayList<java.lang.Object> cancelPredsB
public static java.util.ArrayList<java.lang.Object> oppoPredsA
public static java.util.ArrayList<java.lang.Object> oppoPredsB
public static java.util.ArrayList<java.lang.Object> genPreds
public Predicate predicate
public java.util.ArrayList<java.lang.Object> args
public Argument copy()
public boolean isEquivalent(Literal other)
other
- is the other Literal to be compared for equalitypublic java.lang.String toString()
toString
in class java.lang.Object
public void countArgs(java.util.ArrayList<java.lang.Object> firstMention, java.util.ArrayList<java.lang.Object> otherMentions)
public java.util.ArrayList<java.lang.Object> lits2MiniStrings(java.util.ArrayList<java.lang.Object> clauseSoFar) throws KSInternalErrorException
KSInternalErrorException
public boolean constraintPred(Literal lit)
public int computeLevel(java.lang.String pcStr) throws KSInternalErrorException
KSInternalErrorException
public void expand(Context hypo, java.util.ArrayList<java.lang.Object> clauseSoFar, java.util.ArrayList<java.lang.Object> remainingLits, java.util.ArrayList<java.lang.Object> expandedDefs, java.util.ArrayList<java.lang.Object> save4Last, StackMarkerObj marker, ClauseBody origCB, java.util.ArrayList<java.lang.Object> path) throws KSBadHornClauseException, KSInternalErrorException
hypo
- the context from which this clause came.clauseSoFar
- a list of the expanded literals created before the current literal.remainingLits
- the literals remaining to be expanded.expandedDefs
- the list of expandedDefs to which we will add the finished product(s).save4Last
- the list of general negated constraints we'll process last.marker
- a StackMarkerObj holding the state of a recursive expansion (i.e. how many levels deep
we are on which predicate). We push it onto the stack (remainingLits) behind the
expansion of a non-primitive predicate, so that we can re-set our state to that after
we finish expanding this predicate.origCB
- the original (non-expanded) clause we are expanding.path
- a trace of the expansion path followed in generating the current clauseSoFar.KSBadHornClauseException
- if an invalid condition is encountered.KSInternalErrorException
public void finishExpansion(Context hypo, java.util.ArrayList<java.lang.Object> clauseSoFar, ClauseBody origCB, java.util.ArrayList<java.lang.Object> expandedDefs, java.util.ArrayList<java.lang.Object> save4Last, java.util.ArrayList<java.lang.Object> path) throws KSBadHornClauseException, KSInternalErrorException
public void neg_expand(Context hypo, java.util.ArrayList<java.lang.Object> save4Last, java.util.ArrayList<java.lang.Object> expNegConstraints, ClauseBody origCB, java.util.ArrayList<java.lang.Object> subPaths) throws KSBadHornClauseException, KSInternalErrorException
NOTE: If we are expanding the literal 'not(alpha(A,B))' and alpha is defined as beta or gamma, then the logical equivalent of 'not(alpha(A,B))' is 'not(beta(A,B)) AND not(gamma(A,B))'. The meaning of a ClauseBody is "a conjunction of literals" i.e. each literal in a clause must be true for the clause to be true. Therefore, we build a single ClauseBody from each negated predicate.
hypo
- the context from which this clause came.save4Last
- a list of the negated literals to be expanded.expNegConstraints
- a list to receive the expanded negated literals.origCB
- the original (non-expanded) clause we are expanding.subPaths
- a trace of the expansion path followed in expanding the negated literals.KSBadHornClauseException
KSInternalErrorException
public boolean constraintCheck(java.lang.String egoGender, ConstraintObj constraints, java.util.ArrayList<java.lang.Object> genderStuff, java.util.ArrayList<java.lang.Object> starStuff) throws KSBadHornClauseException, KSConstraintInconsistency
ConstraintObj
are single-valued. The others have lists of values.
If the user has defined any properties (constraints), those must have names beginning with '*'. They are
recorded as userDefined constraints.
The negated constraints are unique; they apply to the entire clause, not to any one Variable
;
each negated constraint is a ClauseBody.egoGender
- the gender of Ego: "M" or "F".constraints
- a (perhaps empty) ConstraintObj holding the constraints extracted thus far.genderStuff
- a (perhaps empty) ArrayListstarStuff
- a (perhaps empty) ArrayListKSBadHornClauseException
- if an invalid number of args is supplied for a predicateKSConstraintInconsistency
- if a contradictory constraints are encountered (e.g. male(X) and female(X))public static boolean finalConstraintCheck(java.lang.String egoGender, java.util.TreeMap bindings, ConstraintObj constraints, java.util.ArrayList<java.lang.Object> body, java.util.ArrayList<java.lang.Object> genderStuff, java.util.ArrayList<java.lang.Object> starStuff) throws KSConstraintInconsistency
egoGender
- the gender of ego: "M" or "F".bindings
- the binding list that will be used to bind all the variables in the body
to Individuals.constraints
- the constraints extracted from body
during prior analysis.body
- the Literals which comprise this ClauseBody.genderStuff
- a subset of constraints
with only gender-related information.starStuff
- a subset of constraints
with information about User-Defined (or "*-") predicates.KSConstraintInconsistency
- if a contradictory constraints are encountered for anyone other than Ego.public static void genderInferences(ConstraintObj constraints, java.util.ArrayList<java.lang.Object> body) throws KSConstraintInconsistency
KSConstraintInconsistency
public boolean containsAll(java.util.ArrayList list1, java.util.ArrayList list2)
public static void apply(Literal lit) throws KSConstraintInconsistency
MathVariable
arguments replaced by a Constant
. In
that case, we treat the Constant as a variable whose value is already (permanently) fixed.lit
- the literal to be processed. It's predicate will be applied to its arguments.KSConstraintInconsistency
- if a literal's predicate is a star-constraint with no definition.public static java.util.ArrayList<java.lang.Object> setClosureOf(java.lang.String arg1, java.util.ArrayList<java.lang.Object> listOne, java.util.ArrayList<java.lang.Object> closureSoFar, java.util.TreeMap assoc)
listOne
, a starting list of nodes.
assoc
is an "associative list" of node/list-of-reachable-nodes pairs; each pair is interpreted as
"from node I can reach each of the nodes in list-of-reachable-nodes." (All nodes are represented by a String with the
name of the node.) The starting node and all nodes reached are placed into closureSoFar
. Then
any nodes reachable from the newly-added nodes are recursively added, until all nodes have been added that are
reachable in any way.arg1
- the original starting node.listOne
- the original list of nodes reachable from arg1
.closureSoFar
- a set-closure under construction, initially empty.assoc
- an "associative list" of node/list-of-reachable-nodes pairs.public abstract void updatePath(java.util.ArrayList<java.lang.Object> path, java.util.ArrayList<java.lang.Object> pathCopy)