--- a
+++ b/doc/html/using_pyke/other_functions.html
@@ -0,0 +1,258 @@
+<!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">
+    <title>Other Functions</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <link rel="stylesheet" href="../stylesheets/pyke.css" type="text/css" />
+  <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><a href="index.html">Using Pyke</a></li>
+<li>Other functions</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="normal-nav"><a href="../knowledge_bases/index.html">Knowledge Bases</a></div>
+<div class="normal-nav"><a href="../pyke_syntax/index.html">Pyke Syntax</a></div>
+<div class="title-nav"><a href="index.html">Using Pyke</a></div><div class="nav-branch">
+<div class="normal-nav"><a href="creating_engine.html">Creating an Engine</a></div>
+<div class="normal-nav"><a href="adding_facts.html">Asserting Facts</a></div>
+<div class="normal-nav"><a href="proving_goals.html">Proving Goals</a></div>
+<div class="normal-nav"><a href="other_functions.html">Other functions</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 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="other-functions">
+<h1 class="title">Other Functions</h1>
+<div class="section" id="running-and-pickling-plans">
+<h2>Running and Pickling Plans</h2>
+<!-- this code is hidden and will set __file__ to the doc/examples directory.
+>>> import os
+>>> __file__ = \
+...   os.path.join(os.path.dirname(os.path.dirname(os.getcwd())),
+...                'examples')
+>>> from pyke import knowledge_engine
+>>> my_engine = knowledge_engine.engine(__file__)
+>>> my_engine.activate('bc_father_son') -->
+<p>Once you've obtained a <a class="reference external" href="../logic_programming/plans.html">plan</a> from <tt class="docutils literal"><span class="pre">prove_1</span></tt> or <tt class="docutils literal"><span class="pre">prove_n</span></tt>, you just call
+it like a normal Python function.  The arguments required are simply those
+specified, if any, in the <a class="reference external" href="../pyke_syntax/krb_syntax/bc_rule.html#taking-clause">taking clause</a> of the <a class="reference external" href="pyke_syntax/krb_syntax/bc_rule.html">rule</a> proving the top-level
+<p>You may call the plan function any number of times.  You may even pickle
+the plan for later use.  But the plans are constructed out of
+<a class="reference external" href="http://docs.python.org/library/functools.html">functools.partial</a> functions, so you need to register this with <a class="reference external" href="http://docs.python.org/library/copy_reg.html">copy_reg</a>
+before pickling the plan:</p>
+<pre class="doctest-block">
+&gt;&gt;&gt; import copy_reg
+&gt;&gt;&gt; import functools
+&gt;&gt;&gt; copy_reg.pickle(functools.partial,
+...                 lambda p: (functools.partial, (p.func,) + p.args))
+<p>No special code is required to unpickle a plan.  Just unpickle and call it.
+(Unpickling the plan only imports one small Pyke module to be able to run
+the plan).</p>
+<div class="section" id="tracing-rules">
+<h2>Tracing Rules</h2>
+<p>Individual rules may be traced to aid in debugging.  The <tt class="docutils literal"><span class="pre">trace</span></tt> function
+takes two arguments: the rule base name, and the name of the rule to trace:</p>
+<pre class="doctest-block">
+&gt;&gt;&gt; my_engine.trace('bc_father_son', 'grand_father_son')
+&gt;&gt;&gt; my_engine.prove_1_goal('bc_father_son.father_son(thomas, david, $depth)')
+bc_father_son.grand_father_son('thomas', 'david', '$depth')
+bc_father_son.grand_father_son succeeded with ('thomas', 'david', ('grand',))
+({'depth': ('grand',)}, None)
+<p>This can be done either before or after rule base activation and will remain
+in effect until you call <tt class="docutils literal"><span class="pre">untrace</span></tt>:</p>
+<pre class="doctest-block">
+&gt;&gt;&gt; my_engine.untrace('bc_father_son', 'grand_father_son')
+&gt;&gt;&gt; my_engine.prove_1_goal('bc_father_son.father_son(thomas, david, $depth)')
+({'depth': ('grand',)}, None)
+<div class="section" id="krb-traceback">
+<p>A handy traceback module is provided to convert Python functions, lines and
+line numbers to the <a class="reference external" href="../pyke_syntax/krb_syntax/index.html">.krb file</a> rule names, lines and line numbers in a
+Python traceback.  This makes it much easier to read the tracebacks that occur
+during proofs.</p>
+<p>The <tt class="docutils literal"><span class="pre">krb_traceback</span></tt> module has exactly the same functions as the standard
+Python <a class="reference external" href="http://docs.python.org/library/traceback.html">traceback</a> module, but they convert the generated Python function
+information into .krb file information.  They also delete the intervening
+Python functions between subgoal proofs.</p>
+<pre class="doctest-block">
+&gt;&gt;&gt; import sys
+&gt;&gt;&gt; from pyke import knowledge_engine
+&gt;&gt;&gt; from pyke import krb_traceback
+&gt;&gt;&gt; my_engine = knowledge_engine.engine(__file__)
+&gt;&gt;&gt; my_engine.activate('error_test')
+&gt;&gt;&gt; try:                                            # doctest: +ELLIPSIS
+...     my_engine.prove_1_goal('error_test.goal()')
+... except:
+...     krb_traceback.print_exc(None, sys.stdout)   # sys.stdout needed for doctest
+Traceback (most recent call last):
+  File &quot;&lt;doctest other_functions.txt[12]&gt;&quot;, line 2, in &lt;module&gt;
+    my_engine.prove_1_goal('error_test.goal()')
+  File &quot;...knowledge_engine.py&quot;, line 359, in prove_1_goal
+    return goal.compile(goal_str).prove_1(self, **args)
+  File &quot;...goal.py&quot;, line 47, in prove_1
+    return iter(it).next()
+  File &quot;...rule_base.py&quot;, line 50, in next
+    return self.iterator.next()
+  File &quot;...knowledge_engine.py&quot;, line 41, in from_iterable
+    for x in iterable: yield x
+  File &quot;...knowledge_engine.py&quot;, line 41, in from_iterable
+    for x in iterable: yield x
+  File &quot;...error_test.krb&quot;, line 26, in rule1
+    goal2()
+  File &quot;...error_test.krb&quot;, line 31, in rule2
+    goal3()
+  File &quot;...error_test.krb&quot;, line 36, in rule3
+    goal4()
+  File &quot;...error_test.krb&quot;, line 41, in rule4
+    check $bar &gt; 0
+  File &quot;...contexts.py&quot;, line 231, in lookup_data
+    raise KeyError(&quot;$%s not bound&quot; % var_name)
+KeyError: '$bar not bound'
+<div class="section" id="miscellaneous">
+<p>There are a few more functions that may be useful in special situations.</p>
+<dl class="docutils">
+<dt><em>some_engine</em>.add_case_specific_fact(kb_name, fact_name, args)</dt>
+<dd>This is an alternate to the <tt class="docutils literal"><span class="pre">assert_</span></tt> function.</dd>
+<dd>Finds and returns the <a class="reference external" href="../knowledge_bases/index.html">knowledge base</a> by the name <tt class="docutils literal"><span class="pre">kb_name</span></tt>.  Raises
+<tt class="docutils literal"><span class="pre">KeyError</span></tt> if not found.  Note that for <a class="reference external" href="../knowledge_bases/rule_bases.html">rule bases</a>, this returns the
+active <a class="reference external" href="../knowledge_bases/rule_bases.html">rule base</a> where <tt class="docutils literal"><span class="pre">kb_name</span></tt> is the <a class="reference external" href="../knowledge_bases/rule_bases.html#rule-base-categories">rule base category</a> name.
+Thus, not all <a class="reference external" href="../knowledge_bases/rule_bases.html">rule bases</a> are accessible through this call.</dd>
+<dd>Finds and returns the <a class="reference external" href="../knowledge_bases/rule_bases.html">rule base</a> by the name <tt class="docutils literal"><span class="pre">rb_name</span></tt>.  Raises
+<tt class="docutils literal"><span class="pre">KeyError</span></tt> if not found.  This works for any <a class="reference external" href="../knowledge_bases/rule_bases.html">rule base</a>, whether it
+is <a class="reference external" href="../knowledge_bases/rule_bases.html#rule-base-activation">active</a> or not.</dd>
+<dt><em>some_engine</em>.print_stats([f = sys.stdout])</dt>
+<dd>Prints a brief set of statistics for each knowledge base to file <tt class="docutils literal"><span class="pre">f</span></tt>.
+These are reset by the <tt class="docutils literal"><span class="pre">reset</span></tt> function.  This will show how many facts
+were asserted, and counts of how many forward-chaining rules were fired
+and rerun, as well as counts of how many backward-chaining goals were
+tried, and how many backward-chaining rules matched, succeeded and failed.
+Note that one backward-chaining rule may succeed many times through
+                <!-- <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="creating_engine.html">Creating an Inference Engine Object</a><p>How to create a Pyke <em>inference engine</em> object.</p>
+<div class="right-item"><a href="adding_facts.html">Asserting New Facts</a><p>How to dynamically assert new <em>facts</em> from your Python program.</p>
+<div class="right-item"><a href="proving_goals.html">Proving Goals</a><p>Using Pyke's API to prove goals from your Python program.</p>
+<div class="right-item"><a href="other_functions.html">Other Functions</a><p>Other miscellaneous functions available that you might be interested
+            </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
+    Fri, Mar 05 2010.
+  </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>