示例#1
0
    //Allows a user to query the knowledge base and determines if a logical sentence entails the KB
    public bool checkEntailment(Sentence newSentence)
    {
        if (kBase.Count == 0)
        {
            return(true);
        }
        // if there are any new variables in the new sentence
        truthTable.GenerateTable(kBase, newSentence);
        kProps = truthTable.InvovledProps;
        List <bool[]> criticalVals = truthTable.valuesToMatch(true);

        for (int i = 0; i < criticalVals.Count; i++)
        {
            GlobalProps.setPropositions(criticalVals[i], kProps);
            if (newSentence.getValue() == false)
            {
                return(false);
            }
        }
        if (criticalVals.Count == 0)
        {
            return(false);
        }
        return(true);
    }