Class 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.
    • 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)