public bool isPremiseInKB(String symbol) { foreach (HornClauseClass clause in KnowledgeBase.Where(s => s.GetType().Name != "HornClauseFactClass")) { List <String> temp = clause.GetPremiseSymbols(); foreach (String str in temp) { if (str == symbol) { return(true); } } } return(false); }
/// <summary> /// Checks if the symboo is the conclusion of an implication or fact /// </summary> /// <param name="symbol">The string you wish to look for in the KB</param> /// <returns>if symbol is found in as a conclusion or fact it will return the clause. /// If it isn't found it returns null (error code)</returns> public HornClauseClass isConclusionOrFact(String symbol) { foreach (HornClauseClass clause in KnowledgeBase.Where(s => s.GetType().Name == "HornClauseImplicationClass" || s.GetType().Name == "HornClauseFactClass")) { if (clause.GetType().Name == "HornClauseImplicationClass") { if (clause.GetConclusionSymbol() == symbol) { return(clause); } } else if (clause.GetType().Name == "HornClauseFactClass") { if (clause.GetSymbols()[0] == symbol) { return(clause); } } } return(null); }