This section lists all blog posts, regardless of topic.
Milestone: Working implementation of rulesSeptember 16, 2008
As of today I now having a working implementation of rules. There are still some details to be fleshed out, but the value derivation engine works.
http://www.platoai.com/plato1.18/This represents a major milestone for a fledgling AI project: The ability to use rules to derive facts about the world using what it has already been told.
The two working examples are:
"My first name is Daniel"
"My last name is Bigham"
"What is my full name?"
And:
"I was born in Canada"
"What is my nationality?"
The next thing on my agenda is to be able to use math in rules. For example:
"I have two sisters"
"I don't have a brother"
"How many siblings do I have?"
rule: $1 is_a person $1 has(count:$2) sister $1 has(count:$3) brother $count = # $2 + $3 -> $1 has(count:$count) sibling |
|
Exercise 18: Completed rule implementationSeptember 12, 2008
Implement
SolveRule and
Derive:
SolveRuleSolveRule Input:
  | A rule. |
  | The derivation target: An ITransOutput that represents what is trying to be derived. |
SolveRule Output:
A list of entities. For relationship rules, this will be either null to represent failure or the
true entity to represent success. For assignment rules, this will be a list of entities that satisfy the value of the assignment.
SolveRule Algorithm:
  | Run SolveConditions. |
  | If the resultant list is empty, return an empty list. |
  | If the resultant list isn't empty and the conclusion type is a relation, then return the true entity. |
  | If the resultant list isn't empty and the conclusion type is a property value, then process each result iteratively. Use the conclusion's value specifier to create the result. This can be accomplished by implementing an Eval function for IValueToken which takes a dictionary of variable values, substitutes them, and returns the resultant entity. |
For each result:
  | Add the resultant token to the output list. |
DeriveDerive is called with a
PropertyToken or
RelationshipToken.
Algorithm:
  | Look up rules that might be able to derive the value/relationship. |
  | For each potential rule, determine whether it is really a match. In the process, determine the value of any variables in the conclusion by doing a token-by-token comparison of the conclusion with the derivation target. Implement this functionality as RuleSolver.Match. |
  | Attempt to solve any rules that match. |
  | If any rules can be solved, return the resulting value, which will be an IEntity for derived property values or a bool for derived relationships. |
Test Cases...
Web UI  | Add a new text area to the web UI that allows rules to be specified. |
  | If the answer to a user's question is a property whose value is not known, try to derive it. If it can be derived, return the result. Always indicate whether a value was derived. |
Exercise 17: Implement SolveConditionsSeptember 12, 2008
SummaryInput:
  | A rule, with 1 or more conditions. |
  | A hash to be used to store variable values. Initially it is only populated with the values of variables that could be determined by comparing the rule conclusion to what is to be derived. |
Output:
  | A list of hashes. Each hash represents a complete set of variable values that satisfy all conditions. |
Step 1:
Iteratively solve all conditions that have only variables with known values. If any of the conditions fails, then return an empty list.
Step 2:
Iteratively solve all conditions with a single unresolved variable using
SolveCondition. For each hash returned from
SolveCondition, recurse. Add each hash returned from our recurse to our output.
Step 3:
Iteratively solve all conditions with two unresolved variables. If a condition fails to solve, then try the next one, so on and so forth. If none of the two-variable conditions resolve, then return an empty list.
older >>