FormulaTruthValue

From OpenCog
Jump to: navigation, search

The FormulaTruthValue is a kind of TruthValue that holds a numeric formula within it. Whenever it is polled for it's current numeric value, that formula is automatically executed to obtain those numbers. Functionally, it always returns a SimpleTruthValue as the result.

The FormulaStream generalizes this idea to arbitrary FloatValues. That is, a FormulaTruthValue returns a vector of length two (the strength and confidence), whereas the FormulaStream can be used to compute vectors of arbitrary length.

Example

The following defines a FormulaTruthValue that computes a new SimpleTruthValue based on the TruthValues on (Concept "A") and (Concept "B").

(FormulaTruthValue 
   (PredicateFormula
      (Minus
         (Number 1)
         (Times
            (StrengthOf (Concept "A"))
            (StrengthOf (Concept "B"))))
      (Times
         (ConfidenceOf (Concept "A"))
         (ConfidenceOf (Concept "B")))))

Usually, FormulaTruthValues are not used directly, but are instead created by the DynamicFormulaLink, which will take a formula, create the TV, and install it into place.

A more detailed exploration can be found in the /examples/atomspace/flow-formulas.scm file.