/* * Returns null if the query doesn't succeed, and a binding (which will be a Symbol or a Structure) if it does. If the variable on the left hand * side of the colon expression doesn't appear in the query, the Symbol will be a gensym. * If the query isn't a colon expression, will return the bool true to indicate query success, and null to indicate failure. */ public object SolveForParsed(string query) { object parsedQuery = ISOPrologReader.Read(query); if (parsedQuery is Structure colonExpression && colonExpression.IsFunctor(Symbol.Colon, 2)) { // The parsedQuery is a colon expression. Use KB.solveFor to generate a binding. return(PrologKB.SolveFor((LogicVariable)colonExpression.Argument(0), colonExpression.Argument(1), null, false)); }
/* * Given a prolog expression, evaluate it against the KB. */ public bool IsTrueParsed(string query) { return(PrologKB.IsTrue(ISOPrologReader.Read(query))); }
/* * Given a path to a file containing a prolog program, consult the file to assert all facts and rules in the KB. */ public void Consult(string path) { PrologKB.Consult(path); }