|
|
||
|---|---|---|
| data | ||
| .gitignore | ||
| README.md | ||
| __init__.py | ||
| actions.py | ||
| kb.py | ||
| sample.py | ||
| test_actions.py | ||
| test_kb.py | ||
| util.py | ||
README.md
AQE: A Query Engine
This is an implementation of a knowledge base, hacked together in Python 3 (it won't work in Python 2 for reasons of modules) for now to quickly iterate on ideas.
There are a few key points:
- A
KnowledgeBasecontains facts. - A fact is a tuple: (relationship, subject, object). For example,
('is', 'sky', 'blue'). - A
KnowledgeBasehas three core methods: ask, retract, and tell. - The
askmethod queries theKnowledgeBaseto ascertain whether a fact is true. Either the subject or the object may beNone, in which case all satisifiable facts are returned. - The
retractmethod tells theKnowledgeBasethat the fact is no longer true. If it's rainy, we might retract our fact about the sky being blue. - The
tellmethod tells theKnowledgeBasethat the fact is now true. For example, if it's rainy (and we've retracted the previous 'sky is blue' fact), we might tell theKnowledgeBasethat('is', 'sky', 'grey'). - A
KnowledgeBasecan also perform substitutions. - An action contains positive and negative preconditions, retractions, and updates. The positive condition list contains facts that must be true for a knowledge base, and the negative condition list contains facts that must be false. If these preconditions hold, the retractions are applied, followed by the updates.
- See
test_actions.pyfor an example.
Limitations
- Singleton facts aren't supported; that is, there is no way to make a
KnowledgeBaseassert that there is only one relationship → subject mapping. For example, theKnowledgeBasewill admit that('is', 'shrödingers cat', 'alive')and `('is', 'schrödingers cat', 'dead') are both true simultaneously.
TODO
- Rewrite in C++?