001    package com.hammurapi.reasoning;
002    
003    import java.lang.reflect.Method;
004    import java.util.List;
005    
006    /**
007     * Information about how conclusion was derived.
008     * @author Pavel Vlasov
009     *
010     */
011    public interface Derivation<F> {
012            
013            /**
014             * @return Rule name.
015             */
016            String getRuleName();
017            
018            /**
019             * @return Rule description.
020             */
021            String getRuleDescription();
022            
023            /**
024             * @return Rule instance.
025             */
026            Object getRuleInstance();
027            
028            /**
029             * @return Inference method which posted given conclusion.
030             */
031            Method getInferenceMethod();
032    
033            /**
034             * @return Handles of inference method inputs.
035             */
036            List<Handle<F>> getInputHandles();
037            
038            List<F> getInputs();
039            
040            /**
041             * @param fact 
042             * @return True if the fact is source of this derivation or derivations of
043             * one of source conclusions.
044             */
045            boolean isDerivedFrom(F fact);
046            
047            /**
048             * @return true if all source facts in this derivation
049             * are valid (has not been removed from the knowledge base).
050             */
051            boolean isValid();
052            
053            /**
054             * @return Length of the inference chain.
055             */
056            int getDepth();
057            
058            /**
059             * @return Total number of rules fired to come to this conclusion.
060             */
061            int getCardinality();
062            
063    }