Please Make a Donation:
Support This Project

Hosted by:
Get Python Knowledge Engine (PyKE) at Fast, secure and Free Open Source software downloads

Knowledge Bases

Knowledge is organized into named repositories called knowledge bases. A knowledge base is like a directory for files on disk, except that knowledge bases may not be nested. Therefore, the entities within a knowledge base always have a two-level name: knowledge_base_name.knowledge_entity_name.

Here are some examples of facts you might see in a web server application:

request.path_segment(0, my)
request.path_segment(1, 'site.html')
request.path_segment(-2, my)
request.path_segment(-1, 'site.html')

Note that three different knowledge bases (all fact bases) are shown here named header, cookie, and request; each with multiple facts.

The second part of the two-part name is the name of the knowledge entity. You can think of knowledge entities as statement types or topics. So:

request:is the name of the knowledge base.
 is the name of the knowledge entity, or statement topic.
request.path_segment(-1, 'site.html'):
 is a specific statement about the topic of request.path_segments.

What do Knowledge Bases Do?

Ultimately Pyke is interested in proving statements, or answering the question "Is statement X true"? There are several different types of knowledge bases. Each type of knowledge base represents a different way of doing this:

  • Those that contain simple lists of statements of fact (as you see in the example above) are called fact bases.
    • These determine whether a statement is true by simply checking to see if that statement is in their list of known facts.
  • Those that contain if-then rules are called rule bases.
    • These determine whether a statement is true by running their if-then rules to try to construct a proof for that statement.
    • Rule bases may include both forward-chaining and backward-chaining rules.
  • It is also possible to create other kinds of knowledge bases that determine the truth of statements in other ways. Pyke provides two of these:
    • The question base which just poses the statement to an end user as a question.
    • The special knowledge base which has several special one-off knowledge entities to do different things like run a command on the underlying system and examine its output and/or exit status.
      • There is only has one instance of this knowledge base -- called special.


All knowledge bases share the same name space. So no two of them, regardless of their type, may have the same name.


Fact Bases

Explanation of facts and fact bases.

Rule Bases

Explanation of rule bases, overview of .krb files and how these files are compiled and loaded into your Python program.

Question Bases

Explanation of question bases and .kqb files.


Explanation of the special knowledge base.

Page last modified Mon, Oct 27 2008.