ubc.cs.JLog.Foundation
Class jGoal

java.lang.Object
  extended by ubc.cs.JLog.Foundation.jGoal
All Implemented Interfaces:
iName, iNameArity
Direct Known Subclasses:
jAddEventGoal, jAnimateGoal, jAppendArrayGoal, jAssertGoal, jBinaryBuiltinPredicateGoal, jCallGoal, jClauseGoal, jCompareGoal, jCopyGoal, jCreateGoal, jCurrentOpListGoal, jCutGoal, jDBDisconnectGoal, jDBExecuteGoal, jDBExecuteParamGoal, jEnumerateVariablesArrayGoal, jEquivalenceGoal, jEquivGoal, jFailGoal, jFunctorGoal, jGetArrayElementGoal, jImportGoal, jIntersectArrayGoal, jInvokeGoal, jIsGoal, jJ2PGoal, jLookupGoal, jNameGoal, jNaryBuiltinPredicateGoal, jOperatorGoal, jOpGoal, jOrGoal, jP2JGoal, jPredicateGoal, jQuadaryBuiltinPredicateGoal, jReadGoal, jRegisterGoal, jRepeatGoal, jRetractGoal, jSetArrayElementGoal, jSortGoal, jStaticGoal, jSubtractArrayGoal, jTermToListGoal, jTimeGoal.jReportTimeGoal, jTrinaryBuiltinPredicateGoal, jTrueGoal, jUnaryArithmeticGoal, jUnaryBuiltinPredicateGoal, jUnaryOperatorGoal, jUnionArrayGoal, jUnregisterGoal, jUserGoal, jWriteGoal

public abstract class jGoal
extends java.lang.Object
implements iNameArity

This abstract class specifies the behaviour for a goal. The jGoal class is designed to work in conjunction with iGoalStacks and with jProver. jGoals provide services for proving and retrying goals, and in the process they must correctly update the goal and proved stacks for jProver.

Each jGoal is associated to some type of provable predicate, which provides some type of prove member function to perform the actual proof (or evaluation). The jGoal is responsible for updating the goal stacks as needed.

Author:
Glendon Holst

Field Summary
 jGoal next
           
 
Constructor Summary
jGoal()
           
 
Method Summary
protected  void internal_remove(iGoalStack goals)
          Make a rule on the proved stack clean up children on the goal stack.
 void internal_restore(iGoalStack goals)
          Combines internal_remove with a full restart and resoration of any previous variable state.
abstract  boolean prove(iGoalStack goals, iGoalStack proved)
          Attempt to prove the goal represented by this jGoal.
abstract  boolean retry(iGoalStack goals, iGoalStack proved)
          Attempt to prove the goal represented by this jGoal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ubc.cs.JLog.Terms.iNameArity
getArity
 
Methods inherited from interface ubc.cs.JLog.Terms.iName
getName
 

Field Detail

next

public jGoal next
Constructor Detail

jGoal

public jGoal()
Method Detail

prove

public abstract boolean prove(iGoalStack goals,
                              iGoalStack proved)
Attempt to prove the goal represented by this jGoal. Goal must not be on either stack to prove (pop off goals stack before prove call). Goal must place itself on the appropriate stack before returning. proved stack if 'proved', goals stack otherwise. Since proved doesn't pop the stack we don't need a try/catch block. Must be called at least once before calling retry.

Parameters:
goals - iGoalStack containing goals yet to be proved.
proved - iGoalStack containing evaluated goals (goals that may already be proved, or awaiting their child goals to be proved).
Returns:
boolean is true if this goal ended up on proved, false otherwise.

retry

public abstract boolean retry(iGoalStack goals,
                              iGoalStack proved)
Attempt to prove the goal represented by this jGoal. Goal must not be on either stack to retry (pop off proved stack before retry call). Goal must place itself on the goal stack, and normally need not pop either stack. Since retry doesn't pop the stack we don't need a try/catch block.

Parameters:
goals - iGoalStack containing goals yet to be proved.
proved - iGoalStack containing evaluated goals (goals that may already be proved, or awaiting their child goals to be proved).
Returns:
boolean is true if the prover should attempt a prove on this goal, false otherwise.

internal_remove

protected void internal_remove(iGoalStack goals)
Make a rule on the proved stack clean up children on the goal stack. Should be called from within retry, and should rely on retry to adjust the proved stack. this remains on proved stack.

Parameters:
goals - iGoalStack containing goals yet to be proved.

internal_restore

public void internal_restore(iGoalStack goals)
Combines internal_remove with a full restart and resoration of any previous variable state. May be called by other goals, such as a jCutGoal. this is still located on proved stack.

Parameters:
goals - iGoalStack containing goals yet to be proved.