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

[e6e990]: doc / html / knowledge_bases / fact_bases.html Maximize Restore History

Download this file

fact_bases.html    180 lines (167 with data), 7.8 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
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Fact Bases</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../stylesheets/pyke.css" type="text/css" />
</head>
<body>
<table id="page-table">
<thead class="head">
<tr id="header1"><th id="header" colspan="3">
&nbsp;
</th></tr>
<tr id="header2">
<th id="crumb-left"></th>
<th id="crumb-line">
<div id="nav">
<ul>
<li><a href="../index.html">Home</a></li>
<li>&gt;</li>
<li><a href="index.html">Knowledge Bases</a></li>
<li>&gt;</li>
<li>Fact Bases</li>
</ul>
</div>
</th>
<th id="crumb-right"></th>
</tr>
</thead>
<tbody id="body">
<tr id="body-tr">
<td id="left-nav">
<div id="left-nav-div">
<div class="title-nav"><a href="../index.html">Home</a></div><div class="nav-branch">
<div class="normal-nav"><a href="../about_pyke/index.html">About Pyke</a></div>
<div class="normal-nav"><a href="../logic_programming/index.html">Logic Programming</a></div>
<div class="title-nav"><a href="index.html">Knowledge Bases</a></div><div class="nav-branch">
<div class="normal-nav"><a href="fact_bases.html">Fact Bases</a></div>
<div class="normal-nav"><a href="rule_bases.html">Rule Bases</a></div>
<div class="normal-nav"><a href="question_bases.html">Question Bases</a></div>
<div class="normal-nav"><a href="special.html">Special</a></div>
</div>
<div class="normal-nav"><a href="../pyke_syntax/index.html">Pyke Syntax</a></div>
<div class="normal-nav"><a href="../using_pyke.html">Using Pyke</a></div>
<div class="normal-nav"><a href="../examples.html">Examples</a></div>
<div class="normal-nav"><a href="../PyCon2008-paper.html">PyCon 2008 Paper</a></div>
</div>
</div>
<div id="icons">
<div id="project-page">
<a href="http://sourceforge.net/projects/pyke/">Pyke Project Page</a>
</div>
Please Make a Donation:<br />
<a href="http://sourceforge.net/donate/index.php?group_id=207724">
<img src="http://images.sourceforge.net/images/project-support.jpg"
width="88" height="32" border="0"
alt="Support This Project" /> </a> <br /><br />
Hosted by: <br />
<a href="http://sourceforge.net/projects/pyke">
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=207724&amp;type=14"
width="150" height="40"
alt="Get Python Knowledge Engine (PyKE) at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a>
</div>
</td>
<td id="main-td">
<div id="main">
<a name="startcontent" id="startcontent"></a>
<div class="document" id="fact-bases">
<h1 class="title">Fact Bases</h1>
<p>When statements of fact are stored in Pyke, they are stored in <em>fact bases</em>.
Pyke allows you to have as many fact bases as you like to help you organize
your facts. The fact bases are created automatically, as needed, as new facts
are asserted.</p>
<div class="section" id="facts">
<h2>Facts</h2>
<p>Think of a fact as a simple <a class="reference external" href="../logic_programming/statements.html">statement</a>. It has a name and a set of
arguments. The arguments may be:</p>
<ul class="simple">
<li>strings<ul>
<li>proper identifiers don't need quotes: <tt class="docutils literal"><span class="pre">Fred</span></tt> is the same as <tt class="docutils literal"><span class="pre">'Fred'</span></tt></li>
</ul>
</li>
<li>numbers</li>
<li>None, True or False</li>
<li>tuples of any of these (including nested tuples)<ul>
<li>singleton tuples don't require a comma: <tt class="docutils literal"><span class="pre">(1)</span></tt> is the same as <tt class="docutils literal"><span class="pre">(1,)</span></tt></li>
</ul>
</li>
</ul>
<p>Duplicate facts are not allowed. An attempt to assert a fact that already
exists is silently ignored. But note that to be a duplicate, <em>all</em> of the
arguments must be the same!</p>
<p>Currently facts are thought to be immutable, meaning that they may not be
changed or retracted. That's why dictionaries, lists and user-defined
objects are not recommended as arguments.</p>
<div class="section" id="case-specific-facts">
<h3>Case Specific Facts</h3>
<p>Most facts are <em>case specific</em> facts. This means that they will be deleted
when an <a class="reference external" href="../using_pyke.html#initializing-pyke">engine</a> <a class="reference external" href="../using_pyke.html#setting-up-each-case">reset</a> is done to prepare for another run of the inference
engine. Case specific facts are asserted through either:</p>
<pre class="literal-block">
some_engine.assert_(kb_name, fact_name, arguments)
some_engine.add_case_specific_fact(kb_name, fact_name, arguments)
</pre>
<p>They may also be asserted by <a class="reference external" href="../logic_programming/rules/forward_chaining.html">forward-chaining</a> rules.</p>
</div>
<div class="section" id="universal-facts">
<h3>Universal Facts</h3>
<p>Universal facts are never deleted (specifically, when a <a class="reference external" href="../using_pyke.html#setting-up-each-case">reset</a> is done). You
can specify universal facts in a <a class="reference external" href="../pyke_syntax/kfb_syntax.html">.kfb file</a>, or add universal facts by
calling:</p>
<pre class="literal-block">
some_engine.add_universal_fact(kb_name, fact_name, arguments)
</pre>
<p>Typically, all universal facts are added once at <a class="reference external" href="../using_pyke.html#initializing-pyke">program startup</a>.</p>
<!-- ADD_LINKS MARKER -->
</div>
</div>
</div>
<!-- <div id="return-to-top">
<a href="#">Return to Top</a>
</div>
-->
</div>
</td>
<td id="right-nav">
<div id="right-nav-div">
<h3>More:</h3>
<div class="right-item"><a href="fact_bases.html">Fact Bases</a><p>Explanation of facts and fact bases.</p>
</div>
<div class="right-item"><a href="rule_bases.html">Rule Bases</a><p>Explanation of rule bases, overview of .krb files and how these files
are compiled and loaded into your Python program.</p>
</div>
<div class="right-item"><a href="question_bases.html">Question Bases</a><p>Explanation of question bases and .kqb files.</p>
</div>
<div class="right-item"><a href="special.html">Special</a><p>Explanation of the <tt class="docutils literal"><span class="pre">special</span></tt> knowledge base.</p>
</div>
</div>
</td>
</tr>
</tbody>
<tfoot id="foot">
<tr id="foot2">
<td id="copyright" colspan="3">
Copyright &copy; 2007-2009 Bruce Frederiksen
</td>
</tr>
</tfoot>
</table>
<div id="last-modified">
Page last modified
Mon, Oct 27 2008.
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ?
"https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost +
"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-6310805-1");
pageTracker._trackPageview();
} catch(err) {}
</script>
</body>
</html>