PLN usage
From OpenCog
Below follows an example of how to use PLN. PLN stands for Probabilistic Logic Networks, and is basically a backwards chainer that can make use of indefinite probabilities. Other examples, for representing data, and working with the shell, can be found in the cookbook.
Firstly, use the cogserver shell to set the PLN log level you want. If you want a lot of debugging output, try:
pln log 5
otherwise use something like:
pln log -5
Then make or load some data for PLN to work on (you can optionally do this before setting the log level). Use the "load" command or the Scheme shell. For this demo, use:
load ../tests/reasoning/pln/smalldemo.xml
(Assuming you've run the cogserver in a bin subdirectory under the root of the opencog src, otherwise you'll have to alter the path to the test file.)
Then set the target for PLN inference (currently only backward-chaining inference is available, forward chaining is another task).
Enter the Scheme shell:
scm
And then use the "pln-bc" command:
(pln-bc test-target nsteps)
Where target is a scheme expression for the atom you want to set as the target, and nsteps is the number of inference steps. For example, after loading tests/reasoning/smalldemo.xml, try
(define y (InheritanceLink (ConceptNode "Osama") (ConceptNode "Abu"))) (display y) (pln-bc y 200) (display y)
If the inference is successful, that is, if the truth value of the target was changed, then the pln-bc command will return #t, else it will return #f. In addition, the server will print:
Target produced!
and list the atom that resulted. There may be more than one result. Internally, PLN (currently) uses separate atoms for different truth values; these are converted into a CompositeTruthValue associated to the target atom. The new, composite truth value is printed when y is displayed. Revision of these different TruthValues, so that the default/main TV changes, has yet to be implemented.
Note that if you run pln-bc multiple times in a row with the same target, it will continue exploring with the same backward inference tree. So if you choose too few steps, just run it some more.

