edu.isi.powerloom.logic
Class QueryIterator

java.lang.Object
  extended by edu.isi.stella.Stella_Object
      extended by edu.isi.stella.StandardObject
          extended by edu.isi.stella.AbstractIterator
              extended by edu.isi.stella.Iterator
                  extended by edu.isi.powerloom.logic.QueryIterator

public class QueryIterator
extends Iterator

A query iterator points to a query environment representing the initial or intermediate state of a query. The iterator's 'value' is a vector representing a satisfying set bindings of the query's output variables. Each call to the iterator writes a new set of bindings into the vector.


Field Summary
 List activeGoalCaches
           
 int allottedClockTicks
          If defined, timeout after that many :DOWN moves.
 double allottedTime
          If defined, timeout after that many seconds.
 boolean augmentedGoalCacheP
           
 ControlFrame baseControlFrame
           
 ControlFramePriorityQueue controlFramePriorityQueue
           
 int currentClockTicks
           
 ControlFrame currentControlFrame
           
 int currentDepthCutoff
           
 ParallelThread currentParallelThread
           
 PatternRecord currentPatternRecord
           
 java.lang.String debugId
           
 boolean depthCutoffsP
          Set to TRUE if one or more depth cutoffs occurred.
 KeyValueList dynamicSlots
           
 boolean exhaustedP
           
 Vector externalVariables
           
 boolean failedToFindDuplicateSubgoalP
           
 boolean foundAtLeastOneSolutionP
           
 InferenceLevel inferenceLevel
           
 int maximumDepth
           
 PropertyList options
           
 PartialMatchFrame partialMatchStrategy
           
 Context queryContext
           
 QuerySolutionTable solutions
          Each element holds a solution record with a vector of bindings of the free external variables of the query plus all the appropriate truth-value and justification support.
 boolean timeoutP
          Set to TRUE if query times out.
 int timestamp
           
 boolean triggeredDepthCutoffP
           
 
Fields inherited from class edu.isi.stella.Iterator
value
 
Fields inherited from class edu.isi.stella.AbstractIterator
firstIterationP
 
Constructor Summary
QueryIterator()
           
 
Method Summary
static Stella_Object accessQueryIteratorSlotValue(QueryIterator self, Symbol slotname, Stella_Object value, boolean setvalueP)
           
 BooleanWrapper badP()
           
 List bestGoalSequence()
           
 Cons consify()
          Generate all solutions for the query self, and collect them into a cons list of result tuples.
 Cons consifyCurrentSolutions()
          Collect the current solutions of self into a cons list of result tuples.
static Cons consifyQuery(QueryIterator self)
           
static void cutoffSimilarWhynotProofs(QueryIterator query)
           
 boolean deletedP()
          Default deletedP method which always returns FALSE.
 boolean deletedPSetter(boolean value)
           
static QueryIterator deriveJustifiedPartialQuery(QueryIterator query)
           
static List deriveQueryJustifications(QueryIterator query, Stella_Object options, int solutionindex, int maxjustifications)
           
static boolean executeBackwardChainingProofP(QueryIterator query)
           
 void free()
          Default method.
static void freeCachedQuery(QueryIterator query, Symbol queryid)
           
static void freeQueryIterator(QueryIterator self)
           
static List getQueryJustifications(QueryIterator query, int solutionindex, int maxjustifications, boolean createP)
           
static List getWhynotJustifications(QueryIterator query, java.lang.String label, KeyValueList mapping)
          Programmer's interface to WHYNOT function.
static void initializePartialQuery(QueryIterator query)
           
static QueryIterator initializeQueryIterator(QueryIterator queryiterator, Description description, Vector outsidebindings, java.lang.String debugid)
           
 List listify()
          Just like QUERY_ITERATORDconsify but return a LIST instead.
static PartialMatchFrame makePartialMatchFrame(QueryIterator query)
           
static QueryIterator newQueryIterator()
           
 boolean nextP()
           
 Surrogate primaryType()
          Returns the primary type of self.
 void printObject(java.io.PrintStream stream)
           
static void printQueryIterator(QueryIterator self, java.io.PrintStream stream)
           
static void printQueryIteratorOrnately(QueryIterator self, java.io.PrintStream stream)
           
static void printQueryIteratorReadably(QueryIterator self, java.io.PrintStream stream)
           
static void printQueryIteratorSolutionOrnately(QueryIterator self, QuerySolution solution, int solutionnumber, java.io.PrintStream stream)
           
static void processQueryOptions(QueryIterator query, Stella_Object options)
           
 Description queryDescription()
           
 boolean queryIsPartialP()
           
 boolean queryIsTrueFalseP()
           
 Proposition queryProposition()
           
 boolean querySucceededP()
           
 void reset()
           
 List residueGoals()
           
static double returnPartialTruth(QueryIterator query, boolean topP)
           
static BooleanWrapper runYesOrNoQueryP(QueryIterator query)
           
static void sortSolutionsByScore(QueryIterator query)
           
static void traceSolution(QueryIterator self, QuerySolution solution, int solutionnumber)
           
static boolean tryToDefeatLastAnswerP(QueryIterator self, java.lang.Object[] MV_returnarray)
           
static Cons updatePropositionsFromQuery(QueryIterator query, Description description, Module module, Keyword updatemode, boolean recordjustificationsP)
           
 
Methods inherited from class edu.isi.stella.Iterator
advance, concatenate, emptyP, memberP, pop, printClassList
 
Methods inherited from class edu.isi.stella.AbstractIterator
accessAbstractIteratorSlotValue, allocateIterator, length
 
Methods inherited from class edu.isi.stella.StandardObject
arrayTypeSpecifierP, baseTypeToTypeSpec, cantOverwriteActiveCollectionSlot, compatibleParameterTypesP, computeAnchoredTypeSpec, computeRelativeTypeSpec, conformingTypeSpecP, copyWrappedLiteral, cppNonPointerTypeP, cppReferenceTypeP, cppReferencizeType, cppTranslateAndPointerizeTypeSpec, cppTranslateAndReferencizeTypeSpec, cppTranslateTypeSpec, cppTypeWithoutInteriorPointersP, dropSlotValue, extractParameterType, extractRequiredArgumentValues, getSlot, hashCode_, idlTranslateTypeSpec, inverseSlotDemon, javaLiteralP, javaNativeLiteralWrapperNames, javaSpecialSetterName, javaTranslateArrayOfTypeSpec, javaTranslateTypeSpec, javaTranslateTypeSpecForFunction, javaTranslateTypeSpecHelper, javaYieldClassObjectArrayExpression, javaYieldClassObjectExpression, javaYieldFullyQualifiedTypeName, javaYieldTranslatedClassAndMethodNames, listifyTypeSpec, lookupClTypeFromStellaType, objectEqlP, putSlotValue, readSlotValue, runConstructorDemons, runDestructorDemons, runSlotDemons, runSlotGuardDemonsP, standardObjectP, subTypeSpecOfP, twoArgumentLeastCommonSupertype, typeSpecToBaseType, typeSpecToClass, typeToWalkedNullValueTree, validateTypeSpecifier, voidP, walkTypeSpecIsNativeTypeP, writeSlotValue, yieldTypeSpecTree
 
Methods inherited from class edu.isi.stella.Stella_Object
_, accessInContext, addPropertyValue, amPm, anchoredTypeSpecifierP, andOrNotTreeP, applyCoercionMethod, atomicExpressionP, bindToSurrogateP, booleanP, bootstrapIsaP, bquotify, cast, characterP, chooseSortPredicate, clConditionalizeTypeDeclarationTree, clTranslateAtomicTree, clTranslateATree, clTranslateBooleanTest, clTranslatePlainBooleanTest, clTranslateVerbatimBodySymbols, clYieldTypedExpressionTree, coerceATree, coerceEvaluatedTree, coerceMvTree, coerceOptionValue, coerceToBoolean, coerceToFloat, coerceToHashSet, coerceToModule, coerceToModuleName, coerceToString, coerceToSymbol, coerceToXmlElement, coerceValueToBoolean, coerceValueToFloat, coerceValueToString, coerceValueToType, coercibleP, collectFeatureList, collectKeyValueList, commonLispSymbolP, computeExpressionType, consifyListsAndIterators, consP, consTreeMatchP, convertToLiteral, copyConsTree, cppArgumentIsStreamP, cppBinaryOperatorP, cppBlockP, cppMaybeOutputStatementWithParentheses, cppOperatorP, cppOutputAtomicExpression, cppOutputLiteral, cppOutputOneActualParameter, cppOutputStatement, cppOutputTypedEntity, cppPrognifyStatement, cppPrognP, cppStatementToList, cppStreamIsStandardOutputP, cpptrans, cppTranslateAtomicTree, cppTranslateATree, cppTranslatedArrayTypeP, csValueP, dateDivider, dateTimeDivider, day, dealWithAmPm, dealWithEra, dealWithNoonMidn, decrementReferenceCount, defaultOptionHandler, defineSystem, defmodule, describe, describeObject, describeTersely, destructureMethodNameTree, deUglifyParseTree, either, eqlP, eqlToBooleanP, eqlToCharacterP, eqlToFloatP, eqlToIntegerP, eqlToLongIntegerP, eqlToStringP, equalConsTreesP, equalHashCode, equalP, era, estimatedEvaluationCost, evaluate, evaluateArgumentTree, evaluateAtomicTree, evaluateCommand, expandBquoteTree, filterModuleP, floatP, get, getObject, getProperty, hashlist, hashMemoizedArguments, helpBquotify, helpClTranslateATree, helpCoerceATree, helpLptrans, helpPrintOutline, helpTransformBooleanProceduralExpression, helpWalkATree, homeModule, hour, idlOutputAtomicExpression, idlOutputLiteral, idlOutputStatement, idlTranslateAtomicTree, idlTranslateATree, illegalTreeP, implodePathname, incrementallyTranslate, incrementReferenceCount, inlineUnwrapBoolean, inlineWrapBoolean, inModule, integerP, isaP, javaBinaryOperatorP, javaBlockP, javaEndOfLineTokenP, javaHelpOutputPrintStream, javaMaybeOutputStatementWithParentheses, javaOperatorP, javaOutputLiteral, javaOutputStatement, javaPrognP, javaStreamIsStandardOutputP, javaSymbolCaseP, javaTranslateAtomicTree, javaTranslateATree, javaTranslateWithNativeWrapper, jptrans, keywordP, legalTokenizerFromStateP, legalTokenizerStateP, legalTokenizerToStateP, literalEqlP, logLevelLE, longIntegerP, lptrans, makeEvaluatableBquoteTree, makeFileNameFromRelativePath, makeMemoizedValueEntry, makeMemoizedValueEntryn, matchConsTree, methodSlotP, minute, month, nameToString, nilP, noonMidn, numberWrapperToFloat, objectEqualP, objectHashCode, one, oneI, onlyIf, parametricTypeSpecifierP, parseArrayDimensionsSpec, parseOptions, parseTokenizerCharacterSpec, parseTokenizerStateModifiers, permanentCopy, permanentify, permanentifyForm, po, prettyPrintLiteral, primaryClass, printOutline, printStellaCode, printStellaDefinition, printUndefinedSuperClasses, proceduralExpressionP, ptrans, publicSlots, registerRecycledItem, runOptionHandlerP, safeEqualHashCode, safeHashCode, safePrimaryType, safeYieldTypeSpecifier, searchConsTreeP, searchConsTreeWithFilterP, searchForObject, secondp, setProperty, sideEffectFreeExpressionP, simplifyBquoteTree, specialp, stella_Increment, stellaClassP, stellaCollectionP, stellaNeedToCompileP, stellaNeedToTranslateP, stellaObjectP, stellify, storageSlotP, stringifyInModule, stringP, substituteConsTree, substituteOnce, surrogateP, surrogatify, sweep, symbolCaseP, symbolP, sysTree, targetLanguageType, taxonomyIsaP, timeDivider, timeMultiply, tokenizerIncludeSpecP, tokenizerToStateAlias, tokenizerToStateName, toString, traceIf, traceKeywordP, transientifyForm, transientObjectP, transientSymbolP, translateWalkedTree, treeSize, treeToTrees, trueOptionP, tryToEvaluate, typeP, typify, unmake, unregisterRecycledItem, updateInContext, valuesTreeP, variableExpressionP, verbatimStringP, verbatimTreeP, vetOptions, vrletExpressionP, walkAtomicTree, walkATree, walkCollectionTree, walkDontCallMeTree, walkedExpressionExpression, walkedExpressionType, walkExpressionTree, walkMvExpressionTree, walkMvTree, walkStatement, walkTopLevelExpression, walkWithoutTypeTree, warnAboutUnknownSourceType, weekday, withinContext, withinModule, withinWorld, withStellaTokenizer, withSystemDefinition, withTokenizer, wrapperP, wrapWhereTest, xmlAttributeP, xmlBaseAttributeP, xmlCdataFormP, xmlCdataP, xmlDeclarationFormP, xmlDeclarationP, xmlDoctypeFormP, xmlElementFormP, xmlElementP, xmlGlobalAttributeP, xmlLocalAttributeP, xmlnsAttributeP, xmlProcessingInstructionFormP, xmlProcessingInstructionP, xmlTagCase, year, yieldCondTest, yieldCondTestOrTests, yieldHardcodedCaseSymbolIdOrIds, yieldInCursorClausesForArgumentList, yieldInCursorClausesForGeneralCollection, yieldInCursorClausesForVector, yieldTypeSpecifier, zone, zoneMinute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

externalVariables

public Vector externalVariables

exhaustedP

public boolean exhaustedP

options

public PropertyList options

solutions

public QuerySolutionTable solutions
Each element holds a solution record with a vector of bindings of the free external variables of the query plus all the appropriate truth-value and justification support.


debugId

public java.lang.String debugId

queryContext

public Context queryContext

baseControlFrame

public ControlFrame baseControlFrame

currentControlFrame

public ControlFrame currentControlFrame

currentPatternRecord

public PatternRecord currentPatternRecord

currentParallelThread

public ParallelThread currentParallelThread

controlFramePriorityQueue

public ControlFramePriorityQueue controlFramePriorityQueue

augmentedGoalCacheP

public boolean augmentedGoalCacheP

activeGoalCaches

public List activeGoalCaches

triggeredDepthCutoffP

public boolean triggeredDepthCutoffP

failedToFindDuplicateSubgoalP

public boolean failedToFindDuplicateSubgoalP

foundAtLeastOneSolutionP

public boolean foundAtLeastOneSolutionP

timestamp

public int timestamp

partialMatchStrategy

public PartialMatchFrame partialMatchStrategy

inferenceLevel

public InferenceLevel inferenceLevel

currentDepthCutoff

public int currentDepthCutoff

maximumDepth

public int maximumDepth

allottedTime

public double allottedTime
If defined, timeout after that many seconds.


allottedClockTicks

public int allottedClockTicks
If defined, timeout after that many :DOWN moves.


currentClockTicks

public int currentClockTicks

timeoutP

public boolean timeoutP
Set to TRUE if query times out.


depthCutoffsP

public boolean depthCutoffsP
Set to TRUE if one or more depth cutoffs occurred.


dynamicSlots

public KeyValueList dynamicSlots
Constructor Detail

QueryIterator

public QueryIterator()
Method Detail

newQueryIterator

public static QueryIterator newQueryIterator()

getWhynotJustifications

public static List getWhynotJustifications(QueryIterator query,
                                           java.lang.String label,
                                           KeyValueList mapping)
Programmer's interface to WHYNOT function. Derive justifications why query failed, or, if label was supplied as non-NULL, lookup its justification relative to mapping and return the result.

Parameters:
query -
label -
mapping -
Returns:
List

deriveJustifiedPartialQuery

public static QueryIterator deriveJustifiedPartialQuery(QueryIterator query)

cutoffSimilarWhynotProofs

public static void cutoffSimilarWhynotProofs(QueryIterator query)

deriveQueryJustifications

public static List deriveQueryJustifications(QueryIterator query,
                                             Stella_Object options,
                                             int solutionindex,
                                             int maxjustifications)

getQueryJustifications

public static List getQueryJustifications(QueryIterator query,
                                          int solutionindex,
                                          int maxjustifications,
                                          boolean createP)

returnPartialTruth

public static double returnPartialTruth(QueryIterator query,
                                        boolean topP)

sortSolutionsByScore

public static void sortSolutionsByScore(QueryIterator query)

initializePartialQuery

public static void initializePartialQuery(QueryIterator query)

makePartialMatchFrame

public static PartialMatchFrame makePartialMatchFrame(QueryIterator query)

updatePropositionsFromQuery

public static Cons updatePropositionsFromQuery(QueryIterator query,
                                               Description description,
                                               Module module,
                                               Keyword updatemode,
                                               boolean recordjustificationsP)

freeCachedQuery

public static void freeCachedQuery(QueryIterator query,
                                   Symbol queryid)

listify

public List listify()
Just like QUERY_ITERATORDconsify but return a LIST instead.

Overrides:
listify in class Iterator
Returns:
List

consifyQuery

public static Cons consifyQuery(QueryIterator self)

consify

public Cons consify()
Generate all solutions for the query self, and collect them into a cons list of result tuples. If CSINGLETONSP_TRUE, collect a list of atoms rather than a list of lists for tuples of arity=1.

Overrides:
consify in class Iterator
Returns:
Cons

consifyCurrentSolutions

public Cons consifyCurrentSolutions()
Collect the current solutions of self into a cons list of result tuples. If CSINGLETONSP_TRUE, collect a list of atoms rather than a list of lists for tuples of arity=1.

Returns:
Cons

runYesOrNoQueryP

public static BooleanWrapper runYesOrNoQueryP(QueryIterator query)

processQueryOptions

public static void processQueryOptions(QueryIterator query,
                                       Stella_Object options)

reset

public void reset()

tryToDefeatLastAnswerP

public static boolean tryToDefeatLastAnswerP(QueryIterator self,
                                             java.lang.Object[] MV_returnarray)

nextP

public boolean nextP()
Overrides:
nextP in class AbstractIterator

querySucceededP

public boolean querySucceededP()

queryIsPartialP

public boolean queryIsPartialP()

queryIsTrueFalseP

public boolean queryIsTrueFalseP()

queryDescription

public Description queryDescription()

queryProposition

public Proposition queryProposition()

initializeQueryIterator

public static QueryIterator initializeQueryIterator(QueryIterator queryiterator,
                                                    Description description,
                                                    Vector outsidebindings,
                                                    java.lang.String debugid)

freeQueryIterator

public static void freeQueryIterator(QueryIterator self)

free

public void free()
Description copied from class: Stella_Object
Default method. Deallocate storage for self.

Overrides:
free in class Stella_Object

printQueryIteratorReadably

public static void printQueryIteratorReadably(QueryIterator self,
                                              java.io.PrintStream stream)

traceSolution

public static void traceSolution(QueryIterator self,
                                 QuerySolution solution,
                                 int solutionnumber)

printQueryIteratorSolutionOrnately

public static void printQueryIteratorSolutionOrnately(QueryIterator self,
                                                      QuerySolution solution,
                                                      int solutionnumber,
                                                      java.io.PrintStream stream)

printQueryIteratorOrnately

public static void printQueryIteratorOrnately(QueryIterator self,
                                              java.io.PrintStream stream)

printQueryIterator

public static void printQueryIterator(QueryIterator self,
                                      java.io.PrintStream stream)

executeBackwardChainingProofP

public static boolean executeBackwardChainingProofP(QueryIterator query)

printObject

public void printObject(java.io.PrintStream stream)
Overrides:
printObject in class Stella_Object

deletedPSetter

public boolean deletedPSetter(boolean value)

deletedP

public boolean deletedP()
Description copied from class: Stella_Object
Default deletedP method which always returns FALSE. Objects that inherit DYNAMIC-SLOTS-MIXIN also inherit the dynamically-allocated slot deletedObjectP which is read/writable with specializations of this method.

Overrides:
deletedP in class Stella_Object
Returns:
boolean

accessQueryIteratorSlotValue

public static Stella_Object accessQueryIteratorSlotValue(QueryIterator self,
                                                         Symbol slotname,
                                                         Stella_Object value,
                                                         boolean setvalueP)

badP

public BooleanWrapper badP()

bestGoalSequence

public List bestGoalSequence()

residueGoals

public List residueGoals()

primaryType

public Surrogate primaryType()
Description copied from class: Stella_Object
Returns the primary type of self. Gets defined automatically for every non-abstract subclass of OBJECT.

Overrides:
primaryType in class Stella_Object
Returns:
Surrogate