.. Copyright ÂŠ 2007 Bruce Frederiksen
.. Permission is hereby granted, free of charge, to any person obtaining a copy
.. of this software and associated documentation files (the "Software"), to deal
.. in the Software without restriction, including without limitation the rights
.. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
.. copies of the Software, and to permit persons to whom the Software is
.. furnished to do so, subject to the following conditions:
.. The above copyright notice and this permission notice shall be included in
.. all copies or substantial portions of the Software.
.. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
.. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
.. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
.. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
.. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
.. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
.. THE SOFTWARE.
crumb: Rule Bases
Explanation of rule bases, overview of .krb files and how these files
are of compiled and loaded into your python program.
Rule bases are collections of rules_. A single rule base may contain both
forward-chaining_ and backward-chaining_ rules.
Rule bases are created by writing a *knowledge rule base* (or `.krb`_) file
with your favorite text editor. Place all of your `.krb files`_ into a
directory structure. Then load_ this directory in your python program.
The load_ will walk the directory structure recursively and
automatically compile any `.krb files`_ that have changed into python source
files. These python modules are then automatically imported to define the
The name of each rule base is the filename of the `.krb file`_ (with the .krb
suffix removed). This must be a legal python identifier.
Rule Base Activation
Loading_ the rule bases only makes the rule bases available for use. It
does not automatically activate_ any rule bases. This must be done by your
python program. Your program may decide to activate_ different rule bases
in different situations. Additionally,
forward-chaining_ rules_ may be used to activate_ more specific rule bases,
based on their inferencing.
Rule Base Inheritance
Rule bases use single inheritance to inherit_ the rules_ from another rule
base. This can go on to any depth. Both forward-chaining_ and
backward-chaining_ rules_ are inherited_.
Rule Base Categories
Each root rule base implicitly defines a *rule base category*.
Each rule base category may only have one active rule base. Once a rule
base has been activated_ in a rule base category, only children of the
currently active rule base may be activated_ from that point on.
Because these children inherit_ the rules_ of the currently active rule base;
activating_ rule bases only adds new rules_, and doesn't take any away.
.. _activate: ../../using_pyke.html#setting-up-each-case
.. _activated: activate_
.. _activating: activate_
.. _backward-chaining: ../rules/backward_chaining.html
.. _forward-chaining: ../rules/forward_chaining.html
.. _inherit: ../../krb_syntax/index.html#extending-clause
.. _inherits: inherit_
.. _inherited: inherit_
.. _.krb: ../../krb_syntax/index.html
.. _.krb file: `.krb`_
.. _.krb files: `.krb`_
.. _load: ../../using_pyke.html#initializing-pyke
.. _loading: load_
.. _rules: ../rules/index.html