Package org.prolog4j
Interface Prover
-
- All Known Implementing Classes:
AbstractProver
,SWIPrologProver
,TuPrologProver
public interface Prover
A Prover object represents a Prolog knowledge base, on which you can create and solve queries. The implementations of this interface should not provide public constructors. The Prover instances should be created throughProverManager#getProver()
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addTheory(String theory)
Adds a Prolog theory to the knowledge base.void
addTheory(String... theory)
Adds a Prolog theory to the knowledge base.void
assertz(String fact, Object... args)
Asserts a Prolog fact or rule to the knowledge base.ConversionPolicy
getConversionPolicy()
Returns the conversion policy used by the prover.void
loadLibrary(String library)
Loads in a Prolog library of the specified name.void
loadTheory(InputStream input)
Loads a Prolog theory from a stream.void
loadTheory(String input)
Loads a Prolog theory from a string.Query
query(String goal)
Creates a Prolog query that can be solved later.void
retract(String fact)
Retracts a Prolog fact or rule from the knowledge base.<A> Solution<A>
solve(String goal, Object... actualArgs)
Solves a Prolog goal and returns an object using which the individual solutions can be iterated over.
-
-
-
Method Detail
-
solve
<A> Solution<A> solve(String goal, Object... actualArgs)
Solves a Prolog goal and returns an object using which the individual solutions can be iterated over. It is equivalent with the following:query(goal).solve(actualArgs)
- Type Parameters:
A
- the type of an element of the solutions- Parameters:
goal
- the Prolog goalactualArgs
- the actual arguments of the goal- Returns:
- an object for traversing the solutions
- See Also:
Query.solve(Object...)
-
query
Query query(String goal)
Creates a Prolog query that can be solved later.- Parameters:
goal
- the Prolog goal- Returns:
- a query object to be solved later
-
loadLibrary
void loadLibrary(String library)
Loads in a Prolog library of the specified name.- Parameters:
library
- the name of the library
-
loadTheory
void loadTheory(InputStream input) throws IOException
Loads a Prolog theory from a stream.- Parameters:
input
- the stream- Throws:
IOException
-
loadTheory
void loadTheory(String input)
Loads a Prolog theory from a string.- Parameters:
input
- the string
-
addTheory
void addTheory(String theory)
Adds a Prolog theory to the knowledge base.- Parameters:
theory
- the Prolog theory
-
addTheory
void addTheory(String... theory)
Adds a Prolog theory to the knowledge base. The elements of the arguments must represent individual Prolog facts and rules.- Parameters:
theory
- the Prolog theory
-
assertz
void assertz(String fact, Object... args)
Asserts a Prolog fact or rule to the knowledge base.- Parameters:
fact
- the Prolog factargs
- the arguments of the fact
-
retract
void retract(String fact)
Retracts a Prolog fact or rule from the knowledge base.- Parameters:
fact
- the Prolog fact
-
getConversionPolicy
ConversionPolicy getConversionPolicy()
Returns the conversion policy used by the prover.- Returns:
- the conversion policy
-
-