Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[d43b93]: doc / source / overview / knowledge_bases / fact_bases.txt Maximize Restore History

Download this file

fact_bases.txt    90 lines (69 with data), 3.2 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
.. $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: Fact Bases
page-description:
Explanation of facts and fact bases.
/description
format: rest
encoding: utf8
output-encoding: utf8
include: yes
initialheaderlevel: 1
/restindex
=============================================
Fact Bases
=============================================
Facts are organized into fact bases. The fact bases are created
automatically as new facts are asserted.
Facts
================================
Think of a fact as a simple statement. It has a name and a set of
arguments. The arguments may be:
- strings
- proper identifiers don't need quotes: ``Fred`` is the same as ``'Fred'``
- numbers
- None, True or False
- tuples of any of these (including nested tuples)
- singleton tuples don't require a comma: ``(1)`` is the same as ``(1,)``
Duplicate facts are not allowed. An attempt to assert a fact that already
exists is silently ignored. But note that to be a duplicate, all of the
arguments must be the same too!
Facts are immutable. They may not be changed or retracted. That's why
dictionaries, lists and user-defined objects are not allowed as arguments.
Case Specific Facts
---------------------
Most facts are case specific facts. This means that they will be deleted
when a reset_ is done to prepare for another run of the inference engine.
Case specific facts are asserted through either::
*some_engine*.assert_(kb_name, fact_name, arguments)
*some_engine*.add_case_specific_fact(kb_name, fact_name, arguments)
They may also be asserted by forward-chaining_ rules.
Universal Facts
---------------------
Universal facts are never deleted, specifically, when a reset_ is done. Add
universal facts by calling::
*some_engine*.add_universal_fact(kb_name, fact_name, arguments)
Typically, all universal facts are added once at `program startup`_.
.. _forward-chaining: ../rules/forward_chaining.html
.. _program startup: ../../using_pyke.html#initializing-pyke
.. _reset: ../../using_pyke.html#setting-up-each-case