public class Prolog extends Object implements Serializable
Constructor and Description |
---|
Prolog()
Builds a prolog engine with default libraries loaded.
|
Prolog(String[] libs)
Builds a tuProlog engine with loaded
the specified libraries
|
Modifier and Type | Method and Description |
---|---|
void |
addLibraryListener(LibraryListener l)
Adds a listener to library events
|
void |
addOutputListener(OutputListener l)
Adds a listener to ouput events
|
void |
addQueryListener(QueryListener l)
Adds a listener to theory events
|
void |
addSpyListener(SpyListener l)
Adds a listener to spy events
|
void |
addTheory(Theory th)
Adds (appends) a theory
|
void |
addTheoryListener(TheoryListener l)
Adds a listener to theory events
|
void |
addWarningListener(WarningListener l)
Adds a listener to warning events
|
void |
clearTheory()
Clears current theory
|
String[] |
getCurrentLibraries()
Gets the list of current libraries loaded
|
List |
getCurrentOperatorList()
Gets the list of the operators currently defined
|
EngineManager |
getEngineManager()
Gets the component managing engine
|
alice.tuprolog.FlagManager |
getFlagManager()
Gets the component managing flags
|
Theory |
getLastConsultedTheory()
Gets last consulted theory, with the original textual format
|
Library |
getLibrary(String name)
Gets the reference to a loaded library
|
protected Library |
getLibraryFunctor(String name,
int nArgs) |
List |
getLibraryListenerList()
Gets a copy of current listener list to library events
|
LibraryManager |
getLibraryManager()
Gets the component managing libraries
|
protected Library |
getLibraryPredicate(String name,
int nArgs) |
alice.tuprolog.OperatorManager |
getOperatorManager()
Gets the component managing operators
|
List |
getOutputListenerList()
Gets a copy of current listener list to output events
|
PrimitiveManager |
getPrimitiveManager()
Gets the component managing primitives
|
List |
getQueryListenerList()
Gets a copy of current listener list to query events
|
List |
getSpyListenerList()
Gets a copy of current listener list to spy events
|
Theory |
getTheory()
Gets current theory
|
List |
getTheoryListenerList()
Gets a copy of current listener list to theory events
|
TheoryManager |
getTheoryManager()
Gets the component managing theory
|
static String |
getVersion()
Gets the current version of the tuProlog system
|
List |
getWarningListenerList()
Gets a copy of current listener list to warning events
|
boolean |
hasOpenAlternatives()
Asks for the presence of open alternatives to be explored
in current demostration process.
|
void |
identifyFunctor(Term term)
Identify functors
|
boolean |
isHalted()
Checks if the demonstration process was stopped by an halt command.
|
boolean |
isSpy()
Checks the spy state of the engine
|
boolean |
isWarning()
Checks if warning information are notified
|
void |
loadLibrary(Library lib)
Loads a specific instance of a library
If a library with the same name is already present,
a warning event is notified
|
Library |
loadLibrary(String className)
Loads a library.
|
boolean |
match(Term t0,
Term t1)
Unifies two terms using current demonstration context.
|
protected void |
notifyChangedTheory(TheoryEvent e)
Notifies a new theory set or updated event
|
protected void |
notifyLoadedLibrary(LibraryEvent e)
Notifies a library loaded event
|
protected void |
notifyNewQueryResultAvailable(QueryEvent e)
Notifies a library loaded event
|
protected void |
notifyOutput(OutputEvent e)
Notifies an ouput information event
|
protected void |
notifySpy(SpyEvent e)
Notifies a spy information event
|
protected void |
notifyUnloadedLibrary(LibraryEvent e)
Notifies a library unloaded event
|
protected void |
notifyWarning(WarningEvent e)
Notifies a warning information event
|
void |
removeAllOutputListeners()
Removes all output event listeners
|
void |
removeAllSpyListeners()
Removes all spy event listeners
|
void |
removeAllWarningListeners()
Removes all warning event listeners
|
void |
removeLibraryListener(LibraryListener l)
Removes a listener to library events
|
void |
removeOutputListener(OutputListener l)
Removes a listener to ouput events
|
void |
removeQueryListener(QueryListener l)
Removes a listener to query events
|
void |
removeSpyListener(SpyListener l)
Removes a listener to spy events
|
void |
removeTheoryListener(TheoryListener l)
Removes a listener to theory events
|
void |
removeWarningListener(WarningListener l)
Removes a listener to warning events
|
void |
setSpy(boolean state)
Switches on/off the notification of spy information events
|
void |
setTheory(Theory th)
Sets a new theory
|
void |
setWarning(boolean state)
Switches on/off the notification of warning information events
|
SolveInfo |
solve(String st)
Solves a query
|
SolveInfo |
solve(Term g)
Solves a query
|
void |
solveEnd()
Accepts current solution
|
void |
solveHalt()
Halts current solve computation
|
SolveInfo |
solveNext()
Gets next solution
|
protected void |
spy(String s)
Notifies a spy information event
|
protected void |
spy(String s,
Engine e)
Notifies a spy information event
|
void |
stdOutput(String m)
Produces an output information event
|
String |
toString(Term term)
Gets the string representation of a term, using operators
currently defined by engine
|
Term |
toTerm(String st)
Gets a term from a string, using the operators currently
defined by the engine
|
boolean |
unify(Term t0,
Term t1)
Unifies two terms using current demonstration context.
|
void |
unloadLibrary(String name)
Unloads a previously loaded library
|
void |
warn(String m)
Notifies a warn information event
|
public Prolog()
public Prolog(String[] libs) throws InvalidLibraryException
libs
- the (class) name of the libraries to be loadedInvalidLibraryException
public alice.tuprolog.FlagManager getFlagManager()
public TheoryManager getTheoryManager()
public PrimitiveManager getPrimitiveManager()
public LibraryManager getLibraryManager()
public alice.tuprolog.OperatorManager getOperatorManager()
public EngineManager getEngineManager()
public static String getVersion()
public void setTheory(Theory th) throws InvalidTheoryException
th
- is the new theoryInvalidTheoryException
- if the new theory is not validTheory
public void addTheory(Theory th) throws InvalidTheoryException
th
- is the theory to be addedInvalidTheoryException
- if the new theory is not validTheory
public Theory getTheory()
public Theory getLastConsultedTheory()
public void clearTheory()
public Library loadLibrary(String className) throws InvalidLibraryException
className
- name of the Java class containing the library to be loadedInvalidLibraryException
- if name is not a valid librarypublic void loadLibrary(Library lib) throws InvalidLibraryException
lib
- the (Java class) name of the library to be loadedInvalidLibraryException
- if name is not a valid librarypublic String[] getCurrentLibraries()
public void unloadLibrary(String name) throws InvalidLibraryException
name
- of the library to be unloadedInvalidLibraryException
- if name is not a valid loaded librarypublic Library getLibrary(String name)
name
- the name of the library already loadedpublic List getCurrentOperatorList()
public SolveInfo solve(Term g)
g
- the term representing the goal to be demonstratedSolveInfo
public SolveInfo solve(String st) throws MalformedGoalException
st
- the string representing the goal to be demonstratedMalformedGoalException
SolveInfo
public SolveInfo solveNext() throws NoMoreSolutionException
NoMoreSolutionException
- if no more solutions are presentSolveInfo
public void solveHalt()
public void solveEnd()
public boolean hasOpenAlternatives()
public boolean isHalted()
public boolean match(Term t0, Term t1)
t0
- first term to be unifiedt1
- second term to be unifiedpublic boolean unify(Term t0, Term t1)
t0
- first term to be unifiedt1
- second term to be unifiedpublic void identifyFunctor(Term term)
term
- term to identifypublic Term toTerm(String st) throws InvalidTermException
st
- the string representing a termInvalidTermException
- if the string does not represent a valid termpublic String toString(Term term)
term
- the term to be represented as a stringpublic void setSpy(boolean state)
state
- - true for enabling the notification of spy eventpublic boolean isSpy()
protected void spy(String s)
public void setWarning(boolean state)
state
- - true for enabling warning information notificationpublic boolean isWarning()
public void warn(String m)
m
- the warning messagepublic void stdOutput(String m)
m
- the output stringpublic void addOutputListener(OutputListener l)
l
- the listenerpublic void addTheoryListener(TheoryListener l)
l
- the listenerpublic void addLibraryListener(LibraryListener l)
l
- the listenerpublic void addQueryListener(QueryListener l)
l
- the listenerpublic void addSpyListener(SpyListener l)
l
- the listenerpublic void addWarningListener(WarningListener l)
l
- the listenerpublic void removeOutputListener(OutputListener l)
l
- the listenerpublic void removeAllOutputListeners()
public void removeTheoryListener(TheoryListener l)
l
- the listenerpublic void removeLibraryListener(LibraryListener l)
l
- the listenerpublic void removeQueryListener(QueryListener l)
l
- the listenerpublic void removeSpyListener(SpyListener l)
l
- the listenerpublic void removeAllSpyListeners()
public void removeWarningListener(WarningListener l)
l
- the listenerpublic void removeAllWarningListeners()
public List getOutputListenerList()
public List getWarningListenerList()
public List getSpyListenerList()
public List getTheoryListenerList()
public List getLibraryListenerList()
public List getQueryListenerList()
protected void notifyOutput(OutputEvent e)
e
- the eventprotected void notifySpy(SpyEvent e)
e
- the eventprotected void notifyWarning(WarningEvent e)
e
- the eventprotected void notifyChangedTheory(TheoryEvent e)
e
- the eventprotected void notifyLoadedLibrary(LibraryEvent e)
e
- the eventprotected void notifyUnloadedLibrary(LibraryEvent e)
e
- the eventprotected void notifyNewQueryResultAvailable(QueryEvent e)
e
- the eventCopyright © 2015. All rights reserved.