DynamicFormulaLink

From OpenCog

The DynamicFormulaLink is an evaluatable Link that can be used to specify arithmetic formulas that compute SimpleTruthValues. That is, they allow truth value formulas to be symbolically represented in the AtomSpace, and also be used for performing the actual computation that they represent. It is similar to the PredicateFormulaLink, except that it installs the formula into a FormulaTruthValue, so that the numeric truth value is updated every time that the TruthValue is accessed.

Examples

The following defines a dynamic formula that computes a SimpleTruthValue, and installs that formula into a FormulaTruthValue on the (Concept "foo"). From this point onwards, whenever the TV on (Concept "foo") is accessed, the numeric value of that TV will be recomputed, based on the current values of the TV on (Concept "A") and (Concept "B").

(cog-execute!
   (SetTV
      (Concept "foo")
      (DynamicFormula
         (Minus
            (Number 1)
            (Times
               (StrengthOf (Concept "A"))
               (StrengthOf (Concept "B"))))
         (Times
            (ConfidenceOf (Concept "A"))
            (ConfidenceOf (Concept "B"))))))


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