Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## alice.tuprolog
Class Prolog

    java.lang.Object
      alice.tuprolog.Prolog

All Implemented Interfaces:
  java.io.Serializable

public class Prolog
extends java.lang.Object
implements java.io.Serializable

The Prolog class represents a tuProlog engine.

See Also:
  Serialized Form

Constructor Summary
`Prolog()` Builds a prolog engine with default libraries loaded.
`Prolog(java.lang.String[] libs)` Builds a tuProlog engine with loaded the specified libraries

Method Summary
`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
`java.lang.String[]` | `getCurrentLibraries()` Gets the list of current libraries loaded
`java.util.List` | `getCurrentOperatorList()` Gets the list of the operators currently defined
`Theory` | `getLastConsultedTheory()` Gets last consulted theory, with the original textual format
`Library` | `getLibrary(java.lang.String name)` Gets the reference to a loaded library
`protected Library` | `getLibraryFunctor(java.lang.String name, int nArgs)`
`java.util.List` | `getLibraryListenerList()` Gets a copy of current listener list to library events
`protected Library` | `getLibraryPredicate(java.lang.String name, int nArgs)`
`java.util.List` | `getOutputListenerList()` Gets a copy of current listener list to output events
`java.util.List` | `getQueryListenerList()` Gets a copy of current listener list to query events
`java.util.List` | `getSpyListenerList()` Gets a copy of current listener list to spy events
`Theory` | `getTheory()` Gets current theory
`java.util.List` | `getTheoryListenerList()` Gets a copy of current listener list to theory events
`static java.lang.String` | `getVersion()` Gets the current version of the tuProlog system
`java.util.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(java.lang.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(java.lang.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(java.lang.String s)` Notifies a spy information event
`protected void` | `spy(java.lang.String s, Engine e)` Notifies a spy information event
`void` | `stdOutput(java.lang.String m)` Produces an output information event
`java.lang.String` | `toString(Term term)` Gets the string representation of a term, using operators currently defined by engine
`Term` | `toTerm(java.lang.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(java.lang.String name)` Unloads a previously loaded library
`void` | `warn(java.lang.String m)` Notifies a warn information event

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Prolog

    public Prolog()

  Builds a prolog engine with default libraries loaded. The default libraries are BasicLibrary, ISOLibrary, IOLibrary, and JavaLibrary

### Prolog

    public Prolog(java.lang.String[] libs)
           throws InvalidLibraryException

  Builds a tuProlog engine with loaded the specified libraries

Parameters:
  `libs` - the (class) name of the libraries to be loaded

Method Detail

### getVersion

    public static java.lang.String getVersion()

  Gets the current version of the tuProlog system

### setTheory

    public void setTheory(Theory th)
                   throws InvalidTheoryException

  Sets a new theory

  Parameters:
    `th` - is the new theory
  Throws:
    `InvalidTheoryException` - if the new theory is not valid
  See Also:
    `Theory`

### addTheory

    public void addTheory(Theory th)
                   throws InvalidTheoryException

  Adds (appends) a theory

  Parameters:
    `th` - is the theory to be added
  Throws:
    `InvalidTheoryException` - if the new theory is not valid
  See Also:
    `Theory`

### getTheory

    public Theory getTheory()

  Gets current theory

  Returns:
    current(dynamic) theory

### getLastConsultedTheory

    public Theory getLastConsultedTheory()

  Gets last consulted theory, with the original textual format

  Returns:
    theory

### clearTheory

    public void clearTheory()

  Clears current theory

### loadLibrary

    public Library loadLibrary(java.lang.String className)
                        throws InvalidLibraryException

  Loads a library. If a library with the same name is already present, a warning event is notified and the request is ignored.

  Parameters:
    `className` - name of the Java class containing the library to be loaded
  Returns:
    the reference to the Library just loaded
  Throws:
    `InvalidLibraryException` - if name is not a valid library

### loadLibrary

    public void loadLibrary(Library lib)
                     throws InvalidLibraryException

  Loads a specific instance of a library If a library with the same name is already present, a warning event is notified

  Parameters:
    `lib` - the (Java class) name of the library to be loaded
  Throws:
    `InvalidLibraryException` - if name is not a valid library

### getCurrentLibraries

    public java.lang.String[] getCurrentLibraries()

  Gets the list of current libraries loaded

  Returns:
    the list of the library names

### unloadLibrary

    public void unloadLibrary(java.lang.String name)
                       throws InvalidLibraryException

  Unloads a previously loaded library

  Parameters:
    `name` - of the library to be unloaded
  Throws:
    `InvalidLibraryException` - if name is not a valid loaded library

### getLibrary

    public Library getLibrary(java.lang.String name)

  Gets the reference to a loaded library

  Parameters:
    `name` - the name of the library already loaded
  Returns:
    the reference to the library loaded, null if the library is not found

### getLibraryPredicate

    protected Library getLibraryPredicate(java.lang.String name,
                                          int nArgs)

### getLibraryFunctor

    protected Library getLibraryFunctor(java.lang.String name,
                                        int nArgs)

### getCurrentOperatorList

    public java.util.List getCurrentOperatorList()

  Gets the list of the operators currently defined

  Returns:
    the list of the operators

### solve

    public SolveInfo solve(Term g)

  Solves a query

  Parameters:
    `g` - the term representing the goal to be demonstrated
  Returns:
    the result of the demonstration
  See Also:
    `SolveInfo`

### solve

    public SolveInfo solve(java.lang.String st)
                    throws MalformedGoalException

  Solves a query

  Parameters:
    `st` - the string representing the goal to be demonstrated
  Returns:
    the result of the demonstration
  Throws:
    `MalformedGoalException`
  See Also:
    `SolveInfo`

### solveNext

    public SolveInfo solveNext()
                        throws NoMoreSolutionException

  Gets next solution

  Returns:
    the result of the demonstration
  Throws:
    `NoMoreSolutionException` - if no more solutions are present
  See Also:
    `SolveInfo`

### solveHalt

    public void solveHalt()

  Halts current solve computation

### solveEnd

    public void solveEnd()

  Accepts current solution

### hasOpenAlternatives

    public boolean hasOpenAlternatives()

  Asks for the presence of open alternatives to be explored in current demostration process.

  Returns:
    true if open alternatives are present

### isHalted

    public boolean isHalted()

  Checks if the demonstration process was stopped by an halt command.

  Returns:
    true if the demonstration was stopped

### match

    public boolean match(Term t0,
                         Term t1)

  Unifies two terms using current demonstration context.

  Parameters:
    `t0` - first term to be unified
    `t1` - second term to be unified
  Returns:
    true if the unification was successful

### unify

    public boolean unify(Term t0,
                         Term t1)

  Unifies two terms using current demonstration context.

  Parameters:
    `t0` - first term to be unified
    `t1` - second term to be unified
  Returns:
    true if the unification was successful

### identifyFunctor

    public void identifyFunctor(Term term)

  Identify functors

  Parameters:
    `term` - term to identify

### toTerm

    public Term toTerm(java.lang.String st)
                throws InvalidTermException

  Gets a term from a string, using the operators currently defined by the engine

  Parameters:
    `st` - the string representing a term
  Returns:
    the term parsed from the string
  Throws:
    `InvalidTermException` - if the string does not represent a valid term

### toString

    public java.lang.String toString(Term term)

  Gets the string representation of a term, using operators currently defined by engine

  Parameters:
    `term` - the term to be represented as a string
  Returns:
    the string representing the term

### setSpy

    public void setSpy(boolean state)

  Switches on/off the notification of spy information events

  Parameters:
    `state` - - true for enabling the notification of spy event

### isSpy

    public boolean isSpy()

  Checks the spy state of the engine

  Returns:
    true if the engine emits spy information

### spy

    protected void spy(java.lang.String s)

  Notifies a spy information event

### spy

    protected void spy(java.lang.String s,
                       Engine e)

  Notifies a spy information event

  Parameters:
    `s` - TODO

### setWarning

    public void setWarning(boolean state)

  Switches on/off the notification of warning information events

  Parameters:
    `state` - - true for enabling warning information notification

### isWarning

    public boolean isWarning()

  Checks if warning information are notified

  Returns:
    true if the engine emits warning information

### warn

    public void warn(java.lang.String m)

  Notifies a warn information event

  Parameters:
    `m` - the warning message

### stdOutput

    public void stdOutput(java.lang.String m)

  Produces an output information event

  Parameters:
    `m` - the output string

### addOutputListener

    public void addOutputListener(OutputListener l)

  Adds a listener to ouput events

  Parameters:
    `l` - the listener

### addTheoryListener

    public void addTheoryListener(TheoryListener l)

  Adds a listener to theory events

  Parameters:
    `l` - the listener

### addLibraryListener

    public void addLibraryListener(LibraryListener l)

  Adds a listener to library events

  Parameters:
    `l` - the listener

### addQueryListener

    public void addQueryListener(QueryListener l)

  Adds a listener to theory events

  Parameters:
    `l` - the listener

### addSpyListener

    public void addSpyListener(SpyListener l)

  Adds a listener to spy events

  Parameters:
    `l` - the listener

### addWarningListener

    public void addWarningListener(WarningListener l)

  Adds a listener to warning events

  Parameters:
    `l` - the listener

### removeOutputListener

    public void removeOutputListener(OutputListener l)

  Removes a listener to ouput events

  Parameters:
    `l` - the listener

### removeAllOutputListeners

    public void removeAllOutputListeners()

  Removes all output event listeners

### removeTheoryListener

    public void removeTheoryListener(TheoryListener l)

  Removes a listener to theory events

  Parameters:
    `l` - the listener

### removeLibraryListener

    public void removeLibraryListener(LibraryListener l)

  Removes a listener to library events

  Parameters:
    `l` - the listener

### removeQueryListener

    public void removeQueryListener(QueryListener l)

  Removes a listener to query events

  Parameters:
    `l` - the listener

### removeSpyListener

    public void removeSpyListener(SpyListener l)

  Removes a listener to spy events

  Parameters:
    `l` - the listener

### removeAllSpyListeners

    public void removeAllSpyListeners()

  Removes all spy event listeners

### removeWarningListener

    public void removeWarningListener(WarningListener l)

  Removes a listener to warning events

  Parameters:
    `l` - the listener

### removeAllWarningListeners

    public void removeAllWarningListeners()

  Removes all warning event listeners

### getOutputListenerList

    public java.util.List getOutputListenerList()

  Gets a copy of current listener list to output events

### getWarningListenerList

    public java.util.List getWarningListenerList()

  Gets a copy of current listener list to warning events

### getSpyListenerList

    public java.util.List getSpyListenerList()

  Gets a copy of current listener list to spy events

### getTheoryListenerList

    public java.util.List getTheoryListenerList()

  Gets a copy of current listener list to theory events

### getLibraryListenerList

    public java.util.List getLibraryListenerList()

  Gets a copy of current listener list to library events

### getQueryListenerList

    public java.util.List getQueryListenerList()

  Gets a copy of current listener list to query events

### notifyOutput

    protected void notifyOutput(OutputEvent e)

  Notifies an ouput information event

  Parameters:
    `e` - the event

### notifySpy

    protected void notifySpy(SpyEvent e)

  Notifies a spy information event

  Parameters:
    `e` - the event

### notifyWarning

    protected void notifyWarning(WarningEvent e)

  Notifies a warning information event

  Parameters:
    `e` - the event

### notifyChangedTheory

    protected void notifyChangedTheory(TheoryEvent e)

  Notifies a new theory set or updated event

  Parameters:
    `e` - the event

### notifyLoadedLibrary

    protected void notifyLoadedLibrary(LibraryEvent e)

  Notifies a library loaded event

  Parameters:
    `e` - the event

### notifyUnloadedLibrary

    protected void notifyUnloadedLibrary(LibraryEvent e)

  Notifies a library unloaded event

  Parameters:
    `e` - the event

### notifyNewQueryResultAvailable

    protected void notifyNewQueryResultAvailable(QueryEvent e)

  Notifies a library loaded event

  Parameters:
    `e` - the event

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD