aminePlatform.engines.prologPlusCG.interpreter
Class Resolution

java.lang.Object
  extended byaminePlatform.engines.prologPlusCG.interpreter.Resolution
All Implemented Interfaces:
AmineConstants
Direct Known Subclasses:
Interpreter

public class Resolution
extends java.lang.Object
implements AmineConstants

Title : Resolution

Description : Resolution implements the resolution process of Prolog+CG. It is the Core of Prolog+CG interpreter.

Copyright : Copyright (c) Adil KABBAJ 2004-2009


Field Summary
(package private)  boolean atLeastOneSolution
           
 ResolutionStack backTrackStack
           
 int cptVarBid
           
 Debuger debuger
           
(package private)  DebugFrame debugFrame
           
(package private) static java.lang.String fail
           
 java.util.HashMap globalPrlgPCGObjs
          We include in Prolog+CG the possibility to define and use global objects.
 boolean goal2RslveFrstRsltion
           
 GoalToResolve goalToResolve
           
 Lexicon lexicon
           
 java.lang.String operation
           
protected  Rules paquet
           
 PPCGBindingContext ppcgBindingContext
           
 PPCGParser ppcgParser
           
 java.util.HashMap ppcgPrgs
          ppcgPrgs will contains the internal representation of not only Prolog+CG program, but also several programs if it is required.
protected  Rule request
           
 ResolutionStack resolutionStack
          The three stacks for the resolution process : resolution stack, backtrack stack and unification stack.
 boolean stop
           
(package private)  boolean unifiable
           
 UnificationStack unificationStack
           
protected  java.util.ArrayList varsInRequest
           
 
Fields inherited from interface aminePlatform.util.AmineConstants
ANALOGY, B_ASSIGN, B_DSPLY_WT_DELAY, B_DSPLY_WTT_DELAY, B_TRIGGER, B_WTT_DSPLY, BLOCK_BACKWARD_PROPAGATION, BLOCK_FORWARD_PROPAGATION, CANON, CGIF, CGRAPHIC, CHECK_PRECONDITIONS, COMPARE, COMPOSED_GOAL, CONCEPT_TYPE_IDENT, CONTEXT, COVERED_BY, CPLTE_CONTRACT, DEFINITION, EQ_OR_MORE_SPCFQ, EQUAL, EXPAND, FALSE_FOCUS_LIST, FUNCTIONAL, GENERALISE, GENERALIZE, HAVE_AN_INTERSECTION, ID_ADD, ID_DIV, ID_EQ, ID_INF, ID_IS, ID_MESSAGE, ID_MUL, ID_NOT, ID_NULL, ID_OPER_AND, ID_OPER_OR, ID_SUB, ID_SUP, IN_ACTIVATION, IN_MODE, IN_MODE2, INDIVIDUAL, INDIVIDUAL_IDENT, INTEGRATED, IS_CANONIC, KEY_GLOBAL_RULE, LC_ADD, LC_AMINE_BOOLEAN, LC_AMINE_DOUBLE, LC_AMINE_INTEGER, LC_AND, LC_BOOLEAN, LC_CG, LC_CLOSE_BRKT, LC_CLOSE_PARENT, LC_CLOSE_SET, LC_COMMA, LC_COMMA_SEMI, LC_CONCEPT, LC_CONSTRUCTOR, LC_CS, LC_CUT, LC_DIFF, LC_DIV, LC_DOUBLE, LC_DSBL_BKWRD_PRPGTN, LC_DSBL_FRWRD_PRPGTN, LC_EOF, LC_EQ, LC_FOUR_POINTS, LC_IDENTIFIER, LC_IF, LC_INF, LC_INTEGER, LC_INTEROG, LC_IS, LC_JAVA_OBJECT, LC_LEFT_ARROW, LC_LIST, LC_NULL, LC_OPEN_BRKT, LC_OPEN_PARENT, LC_OPEN_SET, LC_OPER_AND, LC_OPER_OR, LC_POINT, LC_RELATION, LC_RGHT_ARROW, LC_SEMI_COMMA, LC_SET, LC_STAR, LC_STATE, LC_STRING, LC_SUB, LC_SUP, LC_TERM, LC_TWO_POINTS, LC_VAR_LIST_CONSTRUCTOR, LC_VARIABLE, LF, MAXIMAL_JOIN, MORE_GENERAL, MORE_SPECIFIC, NOTHING_TO_INTEGRATE, OPERS_WITH_RSLT, OUT_MODE, OUT_MODE2, PARTIAL_CONTRACT, PARTIAL_SUBSUME, PRJCT_OPERS, PROJECT, READ, READ_SENTENCE, RELATION_TYPE_IDENT, S_AND, S_BOOLEAN, S_CG, S_CLOSE_BRKT, S_CLOSE_PARENT, S_CLOSE_SET, S_COMMA, S_CONCEPT, S_CONSTRUCTOR, S_CUT, S_DIFF, S_DOUBLE, S_EOF, S_EQUAL, S_EXPAND, S_FALSE, S_FOUR_POINTS, S_GENERALISE, S_GENERALIZE, S_IDENTIFIER, S_IF, S_INTEGER, S_INTEROG, S_IS, S_IS_CANONIC, S_LEFT_ARROW, S_LIST, S_MAXIMAL_JOIN, S_OPEN_BRKT, S_OPEN_PARENT, S_OPEN_SET, S_POINT, S_RGHT_ARROW, S_SEMI_COMMA, S_SOURCE, S_SPECIALIZE, S_STATE, S_STRING, S_SUBSUME, S_SUBSUME_WITH_RESULT, S_SUPER, S_TARGET, S_TERM, S_THIS, S_TRUE, S_TWO_POINTS, S_UNIFY, S_VARIABLE, SITUATION, SPECIALIZE, STEADY, SUBSUME, SUBSUME_WITH_RSLT, TRIGGER, UNCOMPARABLE, UNIFY, VAR_SUPER, WAIT_ASSIGNMENT, WAIT_END_OF_ASSIGNMENT, WAIT_PRECONDITIONS, WAIT_VALUE
 
Constructor Summary
Resolution()
           
Resolution(java.util.HashMap ppcgPrograms, Lexicon lexicon)
           
Resolution(java.util.HashMap ppcgPrograms, Lexicon lexicon, DebugFrame debugFrame)
           
Resolution(java.lang.String[] ppcgFilePaths)
           
Resolution(java.lang.String ontologyFilePath, java.lang.String[] ppcgFilePaths)
           
 
Method Summary
 void clearData()
           
(package private)  void clearGlobalPrlgPCGObjs()
           
protected  boolean cut()
           
protected  boolean execPrimitive(java.lang.String signature)
           
 void finalize()
           
 java.util.ArrayList findAllSolutions(boolean debug)
          Find all solutions for the current request.
 java.util.ArrayList findAllSolutions(java.lang.String request)
          Find all solutions for the specified request.
 java.util.HashMap findFirstSolution(boolean debug)
          Find the first solution for the current request.
 java.util.HashMap findNextSolution(boolean debug)
          Find the next solution for the current request.
 java.util.HashMap getASolution()
           
 int getCptVarBid()
           
 boolean getDebug()
          Get the debug flag value.
 Debuger getDebuger()
           
 DebugFrame getDebugFrame()
           
 Lexicon getLexicon()
          Get the lexicon of the current resolution
static java.lang.String getPPCGDirPath()
           
 java.util.HashMap getPPCGPrgs()
           
 Rule getRequest()
          Get the current request.
 UnificationStack getUnificationStack()
           
 java.lang.Object getValOfGlobalObject(Identifier ident)
           
 java.util.ArrayList getVarsInRequest()
           
 boolean isGlobalObject(Identifier ident)
           
protected  boolean isNullTerm(java.lang.Object obj)
           
 boolean isPrimitive(java.lang.String signature)
           
(package private)  boolean isUnifiable(Rules paquet)
          starting with the position recorded in goalToResolve, search for a rule in the paquet paquet so that the head of the rule could be unified with the current goal (recorded in goalToResolve.goal.
protected  boolean reExecPrimitive(java.lang.String signature)
           
 void setCptVarBid(int nVal)
           
 void setDebug(boolean debug)
          Set the mode of the debugger: if debug is true, then debugger will be actif, otherwise the debugger will not be actif
 void setDebuger(Debuger debuger)
           
 void setDebugFrame(DebugFrame dbgFrame)
           
 void setLexicon(Lexicon lex)
           
 void setOneSolution(java.util.HashMap solution)
           
static void setPPCGDirPath(java.lang.String ppcgDrPath)
           
 void setPPCGPrgs(java.util.HashMap ppcgPrgs)
           
 void setRequest(Rule request)
          Set the specified request as the current request to resolve.
 void setRequest(java.lang.String request)
          Analyze the specified request; from its string form to an internal structure, then determine the variables that are specified in the request and store them in the resolution attribute varsInRequest.
protected  void setValOfGlobalObject(Identifier ident, java.lang.Object val)
           
protected  void setVarsInRequest(java.util.ArrayList arrVars)
           
 void stopDebug()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lexicon

public Lexicon lexicon

ppcgBindingContext

public PPCGBindingContext ppcgBindingContext

ppcgParser

public PPCGParser ppcgParser

debuger

public Debuger debuger

stop

public boolean stop

operation

public java.lang.String operation

unifiable

boolean unifiable

atLeastOneSolution

boolean atLeastOneSolution

debugFrame

DebugFrame debugFrame

cptVarBid

public int cptVarBid

resolutionStack

public ResolutionStack resolutionStack
The three stacks for the resolution process : resolution stack, backtrack stack and unification stack.


backTrackStack

public ResolutionStack backTrackStack

unificationStack

public UnificationStack unificationStack

globalPrlgPCGObjs

public java.util.HashMap globalPrlgPCGObjs
We include in Prolog+CG the possibility to define and use global objects. globalPrlgPCGObjs will enables us to manage the global objects in a Prolog+CG program


ppcgPrgs

public java.util.HashMap ppcgPrgs
ppcgPrgs will contains the internal representation of not only Prolog+CG program, but also several programs if it is required. It is a HashMap of paquets (a list of rules) with their signature as key.


request

protected Rule request

varsInRequest

protected java.util.ArrayList varsInRequest

paquet

protected Rules paquet

goalToResolve

public GoalToResolve goalToResolve

goal2RslveFrstRsltion

public boolean goal2RslveFrstRsltion

fail

static java.lang.String fail
Constructor Detail

Resolution

public Resolution()

Resolution

public Resolution(java.util.HashMap ppcgPrograms,
                  Lexicon lexicon)

Resolution

public Resolution(java.util.HashMap ppcgPrograms,
                  Lexicon lexicon,
                  DebugFrame debugFrame)

Resolution

public Resolution(java.lang.String ontologyFilePath,
                  java.lang.String[] ppcgFilePaths)

Resolution

public Resolution(java.lang.String[] ppcgFilePaths)
Method Detail

getCptVarBid

public int getCptVarBid()

setCptVarBid

public void setCptVarBid(int nVal)

getUnificationStack

public UnificationStack getUnificationStack()

getPPCGPrgs

public java.util.HashMap getPPCGPrgs()

setPPCGPrgs

public void setPPCGPrgs(java.util.HashMap ppcgPrgs)

clearData

public void clearData()

finalize

public void finalize()

clearGlobalPrlgPCGObjs

void clearGlobalPrlgPCGObjs()

getDebug

public boolean getDebug()
Get the debug flag value.

Returns:
true if the debugger is actif and false otherwise

setDebug

public void setDebug(boolean debug)
Set the mode of the debugger: if debug is true, then debugger will be actif, otherwise the debugger will not be actif

Parameters:
debug - A boolean

stopDebug

public void stopDebug()

getDebuger

public Debuger getDebuger()

setDebuger

public void setDebuger(Debuger debuger)

getDebugFrame

public DebugFrame getDebugFrame()

setDebugFrame

public void setDebugFrame(DebugFrame dbgFrame)

getLexicon

public Lexicon getLexicon()
Get the lexicon of the current resolution

Returns:
the lexicon of the current resolution

setLexicon

public void setLexicon(Lexicon lex)

getASolution

public java.util.HashMap getASolution()

setOneSolution

public void setOneSolution(java.util.HashMap solution)

isGlobalObject

public boolean isGlobalObject(Identifier ident)

getValOfGlobalObject

public java.lang.Object getValOfGlobalObject(Identifier ident)

setValOfGlobalObject

protected void setValOfGlobalObject(Identifier ident,
                                    java.lang.Object val)

getVarsInRequest

public java.util.ArrayList getVarsInRequest()

setVarsInRequest

protected void setVarsInRequest(java.util.ArrayList arrVars)

getRequest

public Rule getRequest()
Get the current request.

Returns:
A Rule that represents the request.

setRequest

public void setRequest(java.lang.String request)
                throws java.lang.Exception
Analyze the specified request; from its string form to an internal structure, then determine the variables that are specified in the request and store them in the resolution attribute varsInRequest.

Parameters:
request - A String that represents the request.
Throws:
java.lang.Exception - if problems occur during the analysis of the request.

setRequest

public void setRequest(Rule request)
                throws java.lang.Exception
Set the specified request as the current request to resolve.

Parameters:
request - A Rule that represents the request.
Throws:
java.lang.Exception - if problems occur during the analysis of the request.

getPPCGDirPath

public static java.lang.String getPPCGDirPath()

setPPCGDirPath

public static void setPPCGDirPath(java.lang.String ppcgDrPath)

findFirstSolution

public java.util.HashMap findFirstSolution(boolean debug)
                                    throws java.lang.Exception
Find the first solution for the current request.

Parameters:
debug - A Boolean that specifies if the debugger will be actif or not.
Returns:
A Solution specified as a HashMap of
Throws:
java.lang.Exception - if problems occurs during the resolution

findNextSolution

public java.util.HashMap findNextSolution(boolean debug)
                                   throws java.lang.Exception
Find the next solution for the current request.

Parameters:
debug - A Boolean that specifies if the debugger will be actif or not.
Returns:
A Solution specified as a HashMap of
Throws:
java.lang.Exception - if problems occurs during the resolution

findAllSolutions

public java.util.ArrayList findAllSolutions(java.lang.String request)
Find all solutions for the specified request.

Parameters:
request - A String that specifies the request to answer.
Returns:
An ArrayList of all the solutions.
Throws:
java.lang.Exception - if a problem occurs during the resolution

findAllSolutions

public java.util.ArrayList findAllSolutions(boolean debug)
                                     throws java.lang.Exception
Find all solutions for the current request.

Parameters:
debug - A Boolean that specifies if the debugger will be actif or not.
Returns:
An ArrayList of all the solutions.
Throws:
java.lang.Exception - if a problem occurs during the resolution

isNullTerm

protected boolean isNullTerm(java.lang.Object obj)

isPrimitive

public boolean isPrimitive(java.lang.String signature)

execPrimitive

protected boolean execPrimitive(java.lang.String signature)
                         throws java.lang.Exception
Throws:
java.lang.Exception

cut

protected boolean cut()

reExecPrimitive

protected boolean reExecPrimitive(java.lang.String signature)
                           throws java.lang.Exception
Throws:
java.lang.Exception

isUnifiable

boolean isUnifiable(Rules paquet)
              throws java.lang.Exception
starting with the position recorded in goalToResolve, search for a rule in the paquet paquet so that the head of the rule could be unified with the current goal (recorded in goalToResolve.goal.

Throws:
java.lang.Exception