Package ai.libs.jaicore.logic.fol.util
Class ForwardChainer
- java.lang.Object
-
- ai.libs.jaicore.basic.algorithm.AAlgorithm<ForwardChainingProblem,java.util.Collection<java.util.Map<VariableParam,LiteralParam>>>
-
- ai.libs.jaicore.logic.fol.util.ForwardChainer
-
- All Implemented Interfaces:
java.lang.Iterable<org.api4.java.algorithm.events.IAlgorithmEvent>
,java.util.concurrent.Callable<java.util.Collection<java.util.Map<VariableParam,LiteralParam>>>
,java.util.Iterator<org.api4.java.algorithm.events.IAlgorithmEvent>
,org.api4.java.algorithm.IAlgorithm<ForwardChainingProblem,java.util.Collection<java.util.Map<VariableParam,LiteralParam>>>
,org.api4.java.common.control.ICancelable
,org.api4.java.common.control.ILoggingCustomizable
public class ForwardChainer extends ai.libs.jaicore.basic.algorithm.AAlgorithm<ForwardChainingProblem,java.util.Collection<java.util.Map<VariableParam,LiteralParam>>>
This algorithm answers the question for which groundings G of the variables in $premise, G[$premise] follows from $factbase. This method does NOT adopt the closed world assumption, i.e. !L in the premise can only be followed if L is provably wrong in the factbase.
-
-
Constructor Summary
Constructors Constructor Description ForwardChainer(ForwardChainingProblem problem)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<java.util.Map<VariableParam,LiteralParam>>
call()
boolean
doesConclusionContainAGroundLiteralThatIsNotInFactBase(java.util.Collection<Literal> factbase, java.util.Collection<Literal> conclusion)
boolean
doesCWADeductionFail(java.util.Collection<Literal> factbase, java.util.Collection<Literal> conclusion)
java.util.List<java.util.Map<VariableParam,LiteralParam>>
getGroundingsUnderWhichALiteralAppearsInFactBase(java.util.Collection<Literal> factbase, Literal l, int maxSubstitutions)
java.util.Collection<java.util.Map<VariableParam,LiteralParam>>
getSubstitutionsThatEnableForwardChaining(java.util.Collection<Literal> factbase, java.util.Collection<Literal> conclusion)
NextBindingFoundEvent
nextBinding()
org.api4.java.algorithm.events.IAlgorithmEvent
nextWithException()
boolean
verifyThatGroundingEnablesConclusion(java.util.Collection<Literal> factbase, java.util.Collection<Literal> conclusion, java.util.Map<VariableParam,LiteralParam> grounding)
-
Methods inherited from class ai.libs.jaicore.basic.algorithm.AAlgorithm
activate, announceTimeoutDetected, avoidReinterruptionOnShutdownOnCurrentThread, cancel, checkAndConductTermination, checkTermination, computeTimeoutAware, getActivationTime, getConfig, getId, getInput, getLoggerName, getNumCPUs, getRemainingTimeToDeadline, getState, getTimeout, getTimeoutPrecautionOffset, hasNext, hasThreadBeenInterruptedDuringShutdown, interruptThreadAsPartOfShutdown, isCanceled, isShutdownInitialized, isStopCriterionSatisfied, isTimeouted, iterator, next, post, registerActiveThread, registerListener, resolveShutdownInterruptOnCurrentThread, setConfig, setDeadline, setLoggerName, setMaxNumThreads, setNumCPUs, setState, setTimeout, setTimeout, setTimeoutPrecautionOffset, shutdown, terminate, unregisterActiveThread, unregisterThreadAndShutdown
-
-
-
-
Constructor Detail
-
ForwardChainer
public ForwardChainer(ForwardChainingProblem problem)
-
-
Method Detail
-
nextWithException
public org.api4.java.algorithm.events.IAlgorithmEvent nextWithException() throws java.lang.InterruptedException, org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException, org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException
- Throws:
java.lang.InterruptedException
org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException
org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException
-
call
public java.util.Collection<java.util.Map<VariableParam,LiteralParam>> call() throws java.lang.InterruptedException, org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException, org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException
- Throws:
java.lang.InterruptedException
org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException
org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException
-
nextBinding
public NextBindingFoundEvent nextBinding() throws java.lang.InterruptedException, org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException, org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException
- Throws:
java.lang.InterruptedException
org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException
org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException
-
getSubstitutionsThatEnableForwardChaining
public java.util.Collection<java.util.Map<VariableParam,LiteralParam>> getSubstitutionsThatEnableForwardChaining(java.util.Collection<Literal> factbase, java.util.Collection<Literal> conclusion)
-
doesConclusionContainAGroundLiteralThatIsNotInFactBase
public boolean doesConclusionContainAGroundLiteralThatIsNotInFactBase(java.util.Collection<Literal> factbase, java.util.Collection<Literal> conclusion)
-
doesCWADeductionFail
public boolean doesCWADeductionFail(java.util.Collection<Literal> factbase, java.util.Collection<Literal> conclusion)
- Parameters:
factbase
-conclusion
-- Returns:
- true iff the conclusion contains a positive ground literal that is NOT in the factbase or a negative ground literal that positively occurs in the factbase
-
getGroundingsUnderWhichALiteralAppearsInFactBase
public java.util.List<java.util.Map<VariableParam,LiteralParam>> getGroundingsUnderWhichALiteralAppearsInFactBase(java.util.Collection<Literal> factbase, Literal l, int maxSubstitutions)
-
verifyThatGroundingEnablesConclusion
public boolean verifyThatGroundingEnablesConclusion(java.util.Collection<Literal> factbase, java.util.Collection<Literal> conclusion, java.util.Map<VariableParam,LiteralParam> grounding)
-
-