Skip to content
Patrick Hammer edited this page Feb 17, 2026 · 22 revisions

Welcome to the PLN wiki!

Installation

First install

  1. PeTTa: git clone https://github.com/trueagi-io/PeTTa

  2. Then chekout PLN into PeTTa as follows:

cd PeTTa
mkdir repos
cd repos
git clone https://github.com/trueagi-io/PLN

Run example file

Running an example (the famous Tuffy Smokes) from the PeTTa root folder:

sh ./run.sh ./repos/PLN/examples/Smokes.metta

Run tests:

cd ./repos/PLN
sh test.sh

Import to MeTTa code

Import it to your code via the import mechanisms of your MeTTa interpreter.

!(import! &self (library lib_import))
!(git-import! "https://github.com/trueagi-io/PLN.git")
!(import! &self (library PLN lib_pln))

that way it will install automatically if others run your code.

Usage

To interact with PLN in your MeTTa code, use the following functions:

!(PLN.Derive $Tasks $Beliefs $queryTerm $maxsteps $taskqueuesize $beliefqueuesize)): Returning all tasks and beliefs after $maxsteps inference steps.

!(PLN.Query $Tasks $Beliefs $queryTerm $maxsteps $taskqueuesize $beliefqueuesize)): Returning truth value and evidential base of the $queryTerm sentence only, using PLN.Derive under the hood.

$Tasks / $Beliefs: A tuple of additional sentences (Sentence_1 ... Sentence_n) not known at compile-time.

$Tasks: Active sentences (Sentence_1 ... Sentence_n) not known at compile-time.

$Beliefs: Additional pieces of knowledge (Sentence_1 ... Sentence_n) not known at compile-time.

Sentence_i: (Sentence ($Term (stv $Strength $Confidence) ($EvidenceID))

$Term: The term of the item of knowledge

$queryTerm: The term the derived sentence should have

$maxsteps: Maximum inference steps (in terms of task selections)

$taskqueuesize: Size of task PQ used for inference control

$beliefqueuesize: Size of belief buffer used in inference

$EvidenceID: Running ID, so for Sentence_i assign evidence ID i. Except if one knows 2 inputs are statistically dependent, one can give them the same ID to increase the accuracy of the uncertainty reasoning.

Once this call is formulated your PLN call from your MeTTa code is complete. In most cases $Tasks can be set to $Beliefs (in which case the distinction is made under the hood after multiple task selections), however if one wants only some active pieces of knowledge in the knowledge base to lead to derivations then the distinction becomes useful.

Clone this wiki locally