[05a128]: / doc / source / overview / knowledge_bases / rule_bases.txt  Maximize  Restore  History

Download this file

97 lines (82 with data), 3.9 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
.. $Id$
..
.. 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.
restindex
crumb: Rule Bases
page-description:
Explanation of rule bases, overview of .krb files and how these files
are of compiled and loaded into your python program.
/description
format: rest
encoding: utf8
output-encoding: utf8
include: yes
initialheaderlevel: 1
/restindex
=============================================
Rule Bases
=============================================
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
rule base.
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